2017-11-30 12:10:23 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Policies
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import cn from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2017-11-30 15:01:19 +01:00
|
|
|
import { get } from 'lodash';
|
|
|
|
|
|
|
|
import Input from 'components/Input';
|
2017-11-30 12:10:23 +01:00
|
|
|
|
|
|
|
import styles from './styles.scss';
|
|
|
|
|
|
|
|
class Policies extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
2017-11-30 15:01:19 +01:00
|
|
|
handleChange = (e) => this.context.onChange(e);
|
|
|
|
|
2017-11-30 12:10:23 +01:00
|
|
|
render() {
|
|
|
|
const baseTitle = 'users-permissions.Policies.header';
|
|
|
|
const title = this.props.shouldDisplayPoliciesHint ? 'hint' : 'title';
|
2017-11-30 15:01:19 +01:00
|
|
|
const value = get(this.props.values, this.props.inputSelectName);
|
|
|
|
|
2017-11-30 12:10:23 +01:00
|
|
|
return (
|
|
|
|
<div className={cn('col-md-5',styles.policies)}>
|
|
|
|
<div className="container-fluid">
|
|
|
|
<div className="row">
|
|
|
|
<div className={cn('col-md-12', styles.header)}>
|
|
|
|
<FormattedMessage id={`${baseTitle}.${title}`} />
|
|
|
|
</div>
|
2017-11-30 15:01:19 +01:00
|
|
|
{!this.props.shouldDisplayPoliciesHint ? (
|
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-12"
|
|
|
|
label="users-permissions.Policies.InputSelect.empty"
|
|
|
|
name={this.props.inputSelectName}
|
|
|
|
onChange={this.handleChange}
|
|
|
|
selectOptions={this.props.selectOptions}
|
|
|
|
type="select"
|
|
|
|
validations={{}}
|
|
|
|
value={value}
|
|
|
|
/>
|
|
|
|
) : ''}
|
2017-11-30 12:10:23 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-30 15:01:19 +01:00
|
|
|
Policies.contextTypes = {
|
|
|
|
onChange: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2017-11-30 12:10:23 +01:00
|
|
|
Policies.propTypes = {
|
2017-11-30 15:01:19 +01:00
|
|
|
inputSelectName: PropTypes.string.isRequired,
|
|
|
|
selectOptions: PropTypes.array.isRequired,
|
2017-11-30 12:10:23 +01:00
|
|
|
shouldDisplayPoliciesHint: PropTypes.bool.isRequired,
|
2017-11-30 15:01:19 +01:00
|
|
|
values: PropTypes.object.isRequired,
|
2017-11-30 12:10:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Policies;
|