55 lines
1.3 KiB
JavaScript
Raw Normal View History

/**
*
* Controller
*
*/
import React from 'react';
import PropTypes from 'prop-types';
2017-11-15 17:48:30 +01:00
import { get, map } from 'lodash';
2017-11-15 17:48:30 +01:00
import InputCheckbox from 'components/InputCheckbox';
import styles from './styles.scss';
2017-11-16 15:13:46 +01:00
class Controller extends React.Component {
state = { inputSelected: '' };
setNewInputSelected = (name) => this.setState({ inputSelected: name });
render() {
return (
<div className={styles.controller}>
<div className={styles.controllerHeader}>
<span>{this.props.name}</span>
</div>
<div className="row">
{map(Object.keys(this.props.actions).sort(), (actionKey) => (
<InputCheckbox
inputSelected={this.state.inputSelected}
key={actionKey}
label={actionKey}
2017-11-16 17:59:41 +01:00
name={`${this.props.inputNamePath}.controllers.${this.props.name}.${actionKey}.enabled`}
2017-11-16 15:13:46 +01:00
setNewInputSelected={this.setNewInputSelected}
value={get(this.props.actions[actionKey], 'enabled')}
/>
))}
</div>
</div>
2017-11-16 15:13:46 +01:00
);
}
}
Controller.defaultProps = {
actions: {},
inputNamePath: 'permissions.application',
name: '',
};
Controller.propTypes = {
actions: PropTypes.object,
inputNamePath: PropTypes.string,
name: PropTypes.string,
};
export default Controller;