Skip to content

Commit

Permalink
Fixes strapi#3472
Browse files Browse the repository at this point in the history
  • Loading branch information
soupette committed Jun 19, 2019
1 parent 2537401 commit 37ed213
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,9 @@ packages/strapi-generate-new/files/public/
############################

# *.cache

############################
# Visual Studio Code
############################

front-workspace.code-workspace
1 change: 0 additions & 1 deletion examples/getstarted/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"strapi-middleware-views": "3.0.0-beta.5",
"strapi-plugin-content-manager": "3.0.0-beta.5",
"strapi-plugin-content-type-builder": "3.0.0-beta.5",
"strapi-plugin-documentation": "3.0.0-beta.5",
"strapi-plugin-email": "3.0.0-beta.5",
"strapi-plugin-graphql": "3.0.0-beta.5",
"strapi-plugin-settings-manager": "3.0.0-beta.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ module.exports = {
`environments.${env}.request.router.prefix`,
null
),
validations: {
required: true,
},
validations: {},
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,95 @@
/**
*
* Controller
*
*/
*
* 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 pluginId from '../../pluginId';

import InputCheckbox from '../InputCheckboxPlugin';
import styles from './styles.scss';

class Controller extends React.Component {
state = { inputSelected: '', checked: false };
state = { inputSelected: '' };

setNewInputSelected = (name) => {
this.setState({ inputSelected: name, checked: false });
}
setNewInputSelected = name => {
this.setState({ inputSelected: name });
};

handleChange = () => {
this.setState({ checked: !this.state.checked });
this.context.selectAllActions(`${this.props.inputNamePath}.controllers.${this.props.name}`, !this.isAllActionsSelected());
}
this.context.selectAllActions(
`${this.props.inputNamePath}.controllers.${this.props.name}`,
!this.areAllActionsSelected()
);
};

isAllActionsSelected = () => !some(this.props.actions, ['enabled', false]);
hasSomeActionsSelected = () => {
const { actions } = this.props;

return Object.keys(actions).some(
action => actions[action].enabled === true
);
};

areAllActionsSelected = () => {
const { actions } = this.props;

return Object.keys(actions).every(
action => actions[action].enabled === true
);
};

render() {
const labelId = this.areAllActionsSelected() ? 'unselectAll' : 'selectAll';

return (
<div className={styles.controller}>
<div className={styles.controllerHeader}>
<div>{this.props.name}</div>
<div className={styles.separator}></div>
<div className={styles.separator} />
<div>
<div className={cn(styles.inputCheckbox)}>
<div className="form-check">
<label className={cn('form-check-label', styles.label, this.state.checked ? styles.checked : '')} htmlFor={this.props.name}>
<label
className={cn(
'form-check-label',
styles.label,
this.areAllActionsSelected() && styles.checked,
!this.areAllActionsSelected() &&
this.hasSomeActionsSelected() &&
styles.someChecked
)}
htmlFor={this.props.name}
>
<input
className="form-check-input"
checked={this.state.checked}
checked={this.areAllActionsSelected()}
id={this.props.name}
name={this.props.name}
onChange={this.handleChange}
type="checkbox"
/>
<FormattedMessage id="users-permissions.Controller.selectAll" />
<FormattedMessage id={`${pluginId}.Controller.${labelId}`} />
</label>
</div>
</div>
</div>
</div>
<div className="row">
{map(Object.keys(this.props.actions).sort(), (actionKey) => (
{map(Object.keys(this.props.actions).sort(), actionKey => (
<InputCheckbox
inputSelected={this.state.inputSelected}
isOpen={this.props.isOpen}
key={actionKey}
label={actionKey}
name={`${this.props.inputNamePath}.controllers.${this.props.name}.${actionKey}.enabled`}
name={`${this.props.inputNamePath}.controllers.${
this.props.name
}.${actionKey}.enabled`}
setNewInputSelected={this.setNewInputSelected}
value={get(this.props.actions[actionKey], 'enabled')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@

}
}
.someChecked {
&:after {
content: '\f068';
position: absolute;
top: 0px; left: 3px;
font-size: 10px;
font-family: 'FontAwesome';
font-weight: 100;
color: #1C5DE7;
}
}

.controller {
padding: 1px 43px 0 28px;
Expand Down Expand Up @@ -67,3 +78,4 @@
margin-left: 15px;
background-color: #F6F6F6;
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
*
* Plugins
*
*/
*
* Plugins
*
*/

import React from 'react';
import { FormattedMessage } from 'react-intl';
Expand All @@ -17,7 +17,7 @@ import styles from './styles.scss';
class Plugins extends React.Component {
state = { pluginSelected: '' };

changePluginSelected = (name) => this.setState({ pluginSelected: name });
changePluginSelected = name => this.setState({ pluginSelected: name });

render() {
return (
Expand All @@ -31,8 +31,13 @@ class Plugins extends React.Component {
<FormattedMessage id="users-permissions.Plugins.header.description" />
</div>
</div>
<div className={cn(styles.pluginsContainer, !has(this.props.plugins, 'application') && styles.pluginsGradient)}>
{map(Object.keys(this.props.plugins).sort(), (plugin) => (
<div
className={cn(
styles.pluginsContainer,
!has(this.props.plugins, 'application') && styles.pluginsGradient
)}
>
{map(Object.keys(this.props.plugins).sort(), plugin => (
<Plugin
changePluginSelected={this.changePluginSelected}
key={plugin}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"BoundRoute.title": "Bound route to",
"Controller.input.label": "{label} ",
"Controller.selectAll": "Select all",
"Controller.unselectAll": "Unselect all",
"EditForm.inputSelect.description.role": "It will attach the new authenticated user to the selected role.",
"EditForm.inputSelect.durations.description": "Number of hours during which the user can't subscribe.",
"EditForm.inputSelect.durations.label": "Duration",
Expand Down Expand Up @@ -151,4 +152,4 @@
"notification.success.submit": "Settings have been updated",
"plugin.description.long": "Protect your API with a full authentication process based on JWT. This plugin comes also with an ACL strategy that allows you to manage the permissions between the groups of users.",
"plugin.description.short": "Protect your API with a full authentication process based on JWT"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"BoundRoute.title": "Route associée à",
"Controller.input.label": "{label} ",
"Controller.selectAll": "Tout cocher",
"Controller.unselectAll": "Tout décocher",
"EditForm.inputSelect.description.role": "Choisissez le rôle qui sera lié aux utilisateurs lors de leur enregistrement.",
"EditForm.inputSelect.durations.description": "Nombre d'heure pendant lesquelles un utilisateur ne peut pas s'inscrire.",
"EditForm.inputSelect.durations.label": "Durée",
Expand Down

0 comments on commit 37ed213

Please sign in to comment.