2017-11-15 17:35:32 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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:35:32 +01:00
|
|
|
|
2017-11-15 17:48:30 +01:00
|
|
|
import InputCheckbox from 'components/InputCheckbox';
|
2017-11-15 17:35:32 +01:00
|
|
|
import styles from './styles.scss';
|
|
|
|
|
2017-11-16 13:43:55 +01:00
|
|
|
function Controller({ actions, name, inputNamePath }) {
|
2017-11-15 17:35:32 +01:00
|
|
|
return (
|
|
|
|
<div className={styles.controller}>
|
|
|
|
<div className={styles.controllerHeader}>
|
|
|
|
<span>{name}</span>
|
|
|
|
</div>
|
|
|
|
<div className="row">
|
2017-11-16 13:43:55 +01:00
|
|
|
{map(Object.keys(actions).sort(), (actionKey) => (
|
2017-11-15 17:48:30 +01:00
|
|
|
<InputCheckbox
|
2017-11-16 13:43:55 +01:00
|
|
|
key={actionKey}
|
|
|
|
name={`${inputNamePath}.controllers.${name}.actions.${actionKey}.enabled`}
|
|
|
|
label={actionKey}
|
|
|
|
value={get(actions[actionKey], 'enabled')}
|
2017-11-15 17:35:32 +01:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller.defaultProps = {
|
|
|
|
actions: {},
|
2017-11-16 13:43:55 +01:00
|
|
|
inputNamePath: 'permissions.application',
|
2017-11-15 17:35:32 +01:00
|
|
|
name: '',
|
|
|
|
};
|
|
|
|
|
|
|
|
Controller.propTypes = {
|
|
|
|
actions: PropTypes.object,
|
2017-11-16 13:43:55 +01:00
|
|
|
inputNamePath: PropTypes.string,
|
2017-11-15 17:35:32 +01:00
|
|
|
name: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Controller;
|