/** * * Controller * */ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { get, map } from 'lodash'; import { FormattedMessage } from 'react-intl'; import pluginId from '../../pluginId'; import InputCheckbox from '../InputCheckboxPlugin'; import { Header, Label, Separator, Wrapper } from './Components'; function Controller({ actions, inputNamePath, isOpen, name }, context) { const [inputSelected, setInputSelected] = useState(''); const areAllActionsSelected = () => { return Object.keys(actions).every( action => actions[action].enabled === true ); }; const handleChange = () => { context.selectAllActions( `${inputNamePath}.controllers.${name}`, !areAllActionsSelected() ); }; const hasSomeActionsSelected = () => { return Object.keys(actions).some( action => actions[action].enabled === true ); }; const setNewInputSelected = name => { setInputSelected(name); }; const labelId = areAllActionsSelected() ? 'unselectAll' : 'selectAll'; return (
{name}
{map(Object.keys(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;