2017-11-07 19:58:08 +01:00
|
|
|
/**
|
2019-04-16 16:55:53 +02:00
|
|
|
*
|
|
|
|
* EditForm
|
|
|
|
*
|
|
|
|
*/
|
2017-11-07 19:58:08 +01:00
|
|
|
|
|
|
|
import React from 'react';
|
2017-11-08 16:06:21 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { get } from 'lodash';
|
2018-06-18 12:19:22 +02:00
|
|
|
import cn from 'classnames';
|
2017-11-07 19:58:08 +01:00
|
|
|
|
2019-04-16 16:55:53 +02:00
|
|
|
import { InputsIndex as Input, LoadingIndicator } from 'strapi-helper-plugin';
|
2017-11-07 19:58:08 +01:00
|
|
|
|
|
|
|
import styles from './styles.scss';
|
|
|
|
|
2019-04-16 16:55:53 +02:00
|
|
|
class EditForm extends React.Component {
|
|
|
|
// eslint-disable-line react/prefer-stateless-function
|
|
|
|
generateSelectOptions = () =>
|
2018-03-12 15:56:25 +01:00
|
|
|
Object.keys(get(this.props.values, 'roles', [])).reduce((acc, current) => {
|
|
|
|
const option = {
|
|
|
|
id: get(this.props.values.roles, [current, 'name']),
|
|
|
|
value: get(this.props.values.roles, [current, 'type']),
|
|
|
|
};
|
|
|
|
acc.push(option);
|
|
|
|
return acc;
|
2019-04-16 16:55:53 +02:00
|
|
|
}, []);
|
2018-03-12 15:56:25 +01:00
|
|
|
|
2017-11-07 19:58:08 +01:00
|
|
|
render() {
|
2018-06-14 12:33:57 +02:00
|
|
|
if (this.props.showLoaders) {
|
|
|
|
return (
|
2019-04-16 16:55:53 +02:00
|
|
|
<div
|
|
|
|
className={cn(
|
|
|
|
styles.editForm,
|
|
|
|
this.props.showLoaders && styles.loadIndicatorContainer,
|
|
|
|
)}
|
|
|
|
>
|
2018-06-14 12:33:57 +02:00
|
|
|
<LoadingIndicator />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2018-08-08 17:57:02 +02:00
|
|
|
|
2017-11-07 19:58:08 +01:00
|
|
|
return (
|
|
|
|
<div className={styles.editForm}>
|
2018-03-12 15:56:25 +01:00
|
|
|
<div className="row">
|
|
|
|
<Input
|
2019-04-16 16:55:53 +02:00
|
|
|
inputDescription={{
|
|
|
|
id: 'users-permissions.EditForm.inputSelect.description.role',
|
|
|
|
}}
|
2018-03-12 15:56:25 +01:00
|
|
|
inputClassName={styles.inputStyle}
|
|
|
|
label={{ id: 'users-permissions.EditForm.inputSelect.label.role' }}
|
2018-07-31 13:33:45 +02:00
|
|
|
name="advanced.settings.default_role"
|
2018-03-12 15:56:25 +01:00
|
|
|
onChange={this.props.onChange}
|
|
|
|
selectOptions={this.generateSelectOptions()}
|
|
|
|
type="select"
|
|
|
|
value={get(this.props.values.settings, 'default_role')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.separator} />
|
2017-11-07 19:58:08 +01:00
|
|
|
<div className="row">
|
|
|
|
<Input
|
2018-02-05 17:24:15 +01:00
|
|
|
label={{ id: 'users-permissions.EditForm.inputToggle.label.email' }}
|
2019-04-16 16:55:53 +02:00
|
|
|
inputDescription={{
|
|
|
|
id: 'users-permissions.EditForm.inputToggle.description.email',
|
|
|
|
}}
|
2018-07-31 13:33:45 +02:00
|
|
|
name="advanced.settings.unique_email"
|
2017-11-08 16:06:21 +01:00
|
|
|
onChange={this.props.onChange}
|
2017-11-07 19:58:08 +01:00
|
|
|
type="toggle"
|
2018-03-12 15:56:25 +01:00
|
|
|
value={get(this.props.values.settings, 'unique_email')}
|
2017-11-07 19:58:08 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.separator} />
|
2018-01-18 15:26:33 +01:00
|
|
|
{/*}
|
2017-11-07 19:58:08 +01:00
|
|
|
<div className="row">
|
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-3"
|
|
|
|
label="users-permissions.EditForm.inputSelect.subscriptions.label"
|
|
|
|
inputDescription="users-permissions.EditForm.inputSelect.subscriptions.description"
|
|
|
|
name="subscriptions"
|
2017-11-08 16:06:21 +01:00
|
|
|
onChange={this.props.onChange}
|
2017-11-14 10:59:57 +01:00
|
|
|
type="number"
|
2017-11-07 19:58:08 +01:00
|
|
|
validations={{}}
|
2017-11-08 16:06:21 +01:00
|
|
|
value={get(this.props.values, 'subscriptions')}
|
2017-11-07 19:58:08 +01:00
|
|
|
/>
|
2017-11-08 16:06:21 +01:00
|
|
|
<div className="col-md-3" />
|
2017-11-07 19:58:08 +01:00
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-3"
|
|
|
|
label="users-permissions.EditForm.inputSelect.durations.label"
|
|
|
|
inputDescription="users-permissions.EditForm.inputSelect.durations.description"
|
|
|
|
name="durations"
|
2017-11-08 16:06:21 +01:00
|
|
|
onChange={this.props.onChange}
|
2017-11-14 10:59:57 +01:00
|
|
|
type="number"
|
2017-11-07 19:58:08 +01:00
|
|
|
validations={{}}
|
2017-11-08 16:06:21 +01:00
|
|
|
value={get(this.props.values, 'durations')}
|
2017-11-07 19:58:08 +01:00
|
|
|
/>
|
|
|
|
</div>
|
2018-01-18 15:26:33 +01:00
|
|
|
<div className={styles.separator} />
|
|
|
|
*/}
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
2019-04-16 16:55:53 +02:00
|
|
|
label={{
|
|
|
|
id: 'users-permissions.EditForm.inputToggle.label.sign-up',
|
|
|
|
}}
|
|
|
|
inputDescription={{
|
|
|
|
id: 'users-permissions.EditForm.inputToggle.description.sign-up',
|
|
|
|
}}
|
2018-07-31 13:33:45 +02:00
|
|
|
name="advanced.settings.allow_register"
|
2018-01-18 15:26:33 +01:00
|
|
|
onChange={this.props.onChange}
|
|
|
|
type="toggle"
|
2018-03-12 15:56:25 +01:00
|
|
|
value={get(this.props.values.settings, 'allow_register')}
|
2018-01-18 15:26:33 +01:00
|
|
|
/>
|
|
|
|
</div>
|
2018-08-08 17:57:02 +02:00
|
|
|
<div className={styles.separator} />
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
2019-04-16 16:55:53 +02:00
|
|
|
label={{
|
|
|
|
id:
|
|
|
|
'users-permissions.EditForm.inputToggle.label.email-confirmation',
|
|
|
|
}}
|
|
|
|
inputDescription={{
|
|
|
|
id:
|
|
|
|
'users-permissions.EditForm.inputToggle.description.email-confirmation',
|
|
|
|
}}
|
2018-08-08 17:57:02 +02:00
|
|
|
name="advanced.settings.email_confirmation"
|
|
|
|
onChange={this.props.onChange}
|
|
|
|
type="toggle"
|
|
|
|
value={get(this.props.values.settings, 'email_confirmation')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
2019-04-16 16:55:53 +02:00
|
|
|
label={{
|
|
|
|
id:
|
|
|
|
'users-permissions.EditForm.inputToggle.label.email-confirmation-redirection',
|
|
|
|
}}
|
|
|
|
inputDescription={{
|
|
|
|
id:
|
|
|
|
'users-permissions.EditForm.inputToggle.description.email-confirmation-redirection',
|
|
|
|
}}
|
2018-08-08 17:57:02 +02:00
|
|
|
name="advanced.settings.email_confirmation_redirection"
|
|
|
|
onChange={this.props.onChange}
|
|
|
|
type="text"
|
2019-04-16 16:55:53 +02:00
|
|
|
value={get(
|
|
|
|
this.props.values.settings,
|
|
|
|
'email_confirmation_redirection',
|
|
|
|
)}
|
2018-08-08 17:57:02 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2017-11-07 19:58:08 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 16:06:21 +01:00
|
|
|
EditForm.propTypes = {
|
|
|
|
onChange: PropTypes.func.isRequired,
|
2018-06-14 12:33:57 +02:00
|
|
|
showLoaders: PropTypes.bool.isRequired,
|
2017-11-08 16:06:21 +01:00
|
|
|
values: PropTypes.object.isRequired,
|
|
|
|
};
|
2017-11-07 19:58:08 +01:00
|
|
|
|
|
|
|
export default EditForm;
|