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';
|
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
|
|
|
|
2019-10-08 11:22:28 +02:00
|
|
|
import { Wrapper } from './Components';
|
2017-11-07 19:58:08 +01:00
|
|
|
|
2020-08-03 16:49:40 +02:00
|
|
|
function EditForm({ onChange, showLoaders, values }) {
|
2019-09-17 18:48:28 +02:00
|
|
|
const { roles, settings } = values;
|
|
|
|
|
|
|
|
const generateSelectOptions = () =>
|
|
|
|
Object.keys(get(values, 'roles', [])).reduce((acc, current) => {
|
2018-03-12 15:56:25 +01:00
|
|
|
const option = {
|
2019-09-17 18:48:28 +02:00
|
|
|
id: get(roles, [current, 'name']),
|
|
|
|
value: get(roles, [current, 'type']),
|
2018-03-12 15:56:25 +01:00
|
|
|
};
|
|
|
|
acc.push(option);
|
|
|
|
return acc;
|
2019-04-16 16:55:53 +02:00
|
|
|
}, []);
|
2018-03-12 15:56:25 +01:00
|
|
|
|
2019-09-17 18:48:28 +02:00
|
|
|
return (
|
|
|
|
<Wrapper className={showLoaders && 'load-container'}>
|
|
|
|
{showLoaders ? (
|
|
|
|
<LoadingIndicator />
|
|
|
|
) : (
|
|
|
|
<div>
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
|
|
|
inputDescription={{
|
|
|
|
id: 'users-permissions.EditForm.inputSelect.description.role',
|
|
|
|
}}
|
|
|
|
label={{
|
|
|
|
id: 'users-permissions.EditForm.inputSelect.label.role',
|
|
|
|
}}
|
|
|
|
name="advanced.settings.default_role"
|
|
|
|
onChange={onChange}
|
|
|
|
selectOptions={generateSelectOptions()}
|
|
|
|
type="select"
|
|
|
|
value={get(settings, 'default_role')}
|
|
|
|
/>
|
2019-10-08 11:22:28 +02:00
|
|
|
<div className="col-6"></div>
|
2019-09-17 18:48:28 +02:00
|
|
|
<Input
|
|
|
|
label={{
|
|
|
|
id: 'users-permissions.EditForm.inputToggle.label.email',
|
|
|
|
}}
|
|
|
|
inputDescription={{
|
|
|
|
id: 'users-permissions.EditForm.inputToggle.description.email',
|
|
|
|
}}
|
|
|
|
name="advanced.settings.unique_email"
|
|
|
|
onChange={onChange}
|
|
|
|
type="toggle"
|
|
|
|
value={get(settings, 'unique_email')}
|
|
|
|
/>
|
2019-10-08 11:22:28 +02:00
|
|
|
<div className="col-6"></div>
|
2019-09-17 18:48:28 +02:00
|
|
|
<Input
|
|
|
|
label={{
|
|
|
|
id: 'users-permissions.EditForm.inputToggle.label.sign-up',
|
|
|
|
}}
|
|
|
|
inputDescription={{
|
2020-06-12 12:39:34 +02:00
|
|
|
id: 'users-permissions.EditForm.inputToggle.description.sign-up',
|
2019-09-17 18:48:28 +02:00
|
|
|
}}
|
|
|
|
name="advanced.settings.allow_register"
|
|
|
|
onChange={onChange}
|
|
|
|
type="toggle"
|
|
|
|
value={get(settings, 'allow_register')}
|
|
|
|
/>
|
2019-10-08 11:22:28 +02:00
|
|
|
<div className="col-6"></div>
|
2019-10-15 14:09:11 +02:00
|
|
|
<Input
|
|
|
|
label={{
|
2020-06-12 12:39:34 +02:00
|
|
|
id: 'users-permissions.EditForm.inputToggle.label.email-reset-password',
|
2019-10-15 14:09:11 +02:00
|
|
|
}}
|
|
|
|
inputDescription={{
|
2020-06-12 12:39:34 +02:00
|
|
|
id: 'users-permissions.EditForm.inputToggle.description.email-reset-password',
|
2019-10-15 14:09:11 +02:00
|
|
|
}}
|
|
|
|
name="advanced.settings.email_reset_password"
|
|
|
|
onChange={onChange}
|
|
|
|
type="text"
|
|
|
|
value={get(settings, 'email_reset_password')}
|
|
|
|
/>
|
|
|
|
<div className="col-6"></div>
|
2019-09-17 18:48:28 +02:00
|
|
|
<Input
|
|
|
|
label={{
|
2020-06-12 12:39:34 +02:00
|
|
|
id: 'users-permissions.EditForm.inputToggle.label.email-confirmation',
|
2019-09-17 18:48:28 +02:00
|
|
|
}}
|
|
|
|
inputDescription={{
|
2020-06-12 12:39:34 +02:00
|
|
|
id: 'users-permissions.EditForm.inputToggle.description.email-confirmation',
|
2019-09-17 18:48:28 +02:00
|
|
|
}}
|
|
|
|
name="advanced.settings.email_confirmation"
|
|
|
|
onChange={onChange}
|
|
|
|
type="toggle"
|
|
|
|
value={get(settings, 'email_confirmation')}
|
|
|
|
/>
|
2019-10-08 11:22:28 +02:00
|
|
|
<div className="col-6"></div>
|
2019-09-17 18:48:28 +02:00
|
|
|
<Input
|
|
|
|
label={{
|
2020-06-12 12:39:34 +02:00
|
|
|
id: 'users-permissions.EditForm.inputToggle.label.email-confirmation-redirection',
|
2019-09-17 18:48:28 +02:00
|
|
|
}}
|
|
|
|
inputDescription={{
|
|
|
|
id:
|
|
|
|
'users-permissions.EditForm.inputToggle.description.email-confirmation-redirection',
|
|
|
|
}}
|
|
|
|
name="advanced.settings.email_confirmation_redirection"
|
|
|
|
onChange={onChange}
|
|
|
|
type="text"
|
|
|
|
value={get(settings, 'email_confirmation_redirection')}
|
|
|
|
/>
|
2019-09-16 19:18:35 +02:00
|
|
|
</div>
|
2019-09-17 18:48:28 +02:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Wrapper>
|
|
|
|
);
|
2017-11-07 19:58:08 +01:00
|
|
|
}
|
|
|
|
|
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;
|