/** * * Controller * */ import React from 'react'; import PropTypes from 'prop-types'; import { get, map, some } from 'lodash'; import cn from 'classnames'; import { FormattedMessage } from 'react-intl'; import InputCheckbox from 'components/InputCheckbox'; import styles from './styles.scss'; class Controller extends React.Component { state = { inputSelected: '', checked: false }; setNewInputSelected = (name) => { this.setState({ inputSelected: name, checked: false }); } handleChange = () => { this.setState({ checked: !this.state.checked }); this.context.selectAllActions(`${this.props.inputNamePath}.controllers.${this.props.name}`, !this.isAllActionsSelected()); } isAllActionsSelected = () => !some(this.props.actions, ['enabled', false]); render() { return (
{this.props.name}
{map(Object.keys(this.props.actions).sort(), (actionKey) => ( ))}
); } } Controller.contextTypes = { selectAllActions: PropTypes.func.isRequired, }; Controller.defaultProps = { actions: {}, inputNamePath: 'permissions.application', name: '', }; Controller.propTypes = { actions: PropTypes.object, inputNamePath: PropTypes.string, isOpen: PropTypes.bool.isRequired, name: PropTypes.string, }; export default Controller;