From e4f9f808e4e767d744d12b06c3a474d83b66a6c5 Mon Sep 17 00:00:00 2001 From: soupette Date: Tue, 8 Oct 2019 11:22:28 +0200 Subject: [PATCH] Update modals --- .../components/InputSelectWithErrors/index.js | 11 +++ .../admin/src/components/EditForm/index.js | 17 ++-- .../admin/src/components/PopUpForm/index.js | 90 ++++++++++--------- .../admin/src/containers/HomePage/index.js | 46 +++++----- .../admin/src/translations/ar.json | 2 +- .../admin/src/translations/de.json | 2 +- .../admin/src/translations/en.json | 2 +- .../admin/src/translations/es.json | 2 +- .../admin/src/translations/fr.json | 2 +- .../admin/src/translations/it.json | 2 +- .../admin/src/translations/ja.json | 2 +- .../admin/src/translations/ko.json | 2 +- .../admin/src/translations/nl.json | 2 +- .../admin/src/translations/pl.json | 2 +- .../admin/src/translations/pt-BR.json | 2 +- .../admin/src/translations/pt.json | 2 +- .../admin/src/translations/ru.json | 2 +- .../admin/src/translations/tr.json | 2 +- .../admin/src/translations/zh-Hans.json | 2 +- .../admin/src/translations/zh.json | 2 +- 20 files changed, 105 insertions(+), 91 deletions(-) diff --git a/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js b/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js index e4ad11c580..cd5ba4d506 100644 --- a/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/InputSelectWithErrors/index.js @@ -14,6 +14,7 @@ import Label from '../Label'; import InputDescription from '../InputDescription'; import InputErrors from '../InputErrors'; import InputSelect from '../InputSelect'; +import InputSpacer from '../InputSpacer'; import styles from './styles.scss'; @@ -72,6 +73,7 @@ class InputSelectWithErrors extends React.Component { labelClassName, labelStyle, name, + noErrorsDescription, onBlur, onChange, onFocus, @@ -82,6 +84,12 @@ class InputSelectWithErrors extends React.Component { withOptionPlaceholder, } = this.props; + let spacer = !isEmpty(inputDescription) ? :
; + + if (!noErrorsDescription && !isEmpty(this.state.errors)) { + spacer =
; + } + return (
+ {spacer}
); } @@ -148,6 +157,7 @@ InputSelectWithErrors.defaultProps = { labelClassName: '', labelStyle: {}, onBlur: false, + noErrorsDescription: false, onFocus: () => {}, selectOptions: [], style: {}, @@ -189,6 +199,7 @@ InputSelectWithErrors.propTypes = { labelClassName: PropTypes.string, labelStyle: PropTypes.object, name: PropTypes.string.isRequired, + noErrorsDescription: PropTypes.bool, onBlur: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), onChange: PropTypes.func.isRequired, onFocus: PropTypes.func, diff --git a/packages/strapi-plugin-users-permissions/admin/src/components/EditForm/index.js b/packages/strapi-plugin-users-permissions/admin/src/components/EditForm/index.js index 6fd57d2cc7..a6ba733d83 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/components/EditForm/index.js +++ b/packages/strapi-plugin-users-permissions/admin/src/components/EditForm/index.js @@ -10,7 +10,7 @@ import { get } from 'lodash'; import { InputsIndex as Input, LoadingIndicator } from 'strapi-helper-plugin'; -import { Separator, Wrapper } from './Components'; +import { Wrapper } from './Components'; function EditForm({ onChange, showLoaders, values }) { const { roles, settings } = values; @@ -45,9 +45,7 @@ function EditForm({ onChange, showLoaders, values }) { type="select" value={get(settings, 'default_role')} /> -
- -
+
-
- -
+
-
- -
+
-
-
+
+ <> - {form.length > 1 && } - {map(tail(form), (value, key) => ( )} - + ); } @@ -222,7 +226,7 @@ class PopUpForm extends React.Component { }; return ( -
+ <> {map(take(form, 3), (value, key) => ( ))} -
+ ); }; @@ -296,39 +300,43 @@ class PopUpForm extends React.Component { ); } - if (display && en[display]) { - header = ; - } + let subHeader = + display && en[display] ? ( + + ) : ( + {capitalize(dataToEdit)} + ); return ( - - - -
{header}
-
- -
{this.renderForm()}
-
- - - - -
-
+ + +
+ {header} +
+
+ {subHeader} +
+
+
+
+ + {this.renderForm()} + + +
+ + +
+
+
); } diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js index 80b87ea0fb..b3f7c258ff 100644 --- a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js +++ b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js @@ -169,6 +169,10 @@ export class HomePage extends React.Component { }, ]; + isAdvanded = () => { + return this.getEndPoint() === 'advanced'; + }; + pluginHeaderActions = [ { label: 'users-permissions.EditPage.cancel', @@ -186,14 +190,13 @@ export class HomePage extends React.Component { showLoaders = () => { const { data, isLoading, modifiedData } = this.props; - const isAdvanded = this.getEndPoint() === 'advanced'; return ( (isLoading && get(data, this.getEndPoint()) === undefined && - !isAdvanded) || + !this.isAdvanded()) || (isLoading && - isAdvanded && + this.isAdvanded() && get(modifiedData, this.getEndPoint()) === undefined) ); }; @@ -216,24 +219,7 @@ export class HomePage extends React.Component { const noButtonList = match.params.settingType === 'email-templates' || match.params.settingType === 'providers'; - const component = - match.params.settingType === 'advanced' ? ( - - ) : ( - - ); + const values = get(modifiedData, this.getEndPoint(), {}); return ( - {component} + {!this.isAdvanded() ? ( + + ) : ( + + )}