From 790eaef5c23a0675244770b456389167937012c5 Mon Sep 17 00:00:00 2001 From: ronronscelestes Date: Tue, 5 Oct 2021 18:01:47 +0200 Subject: [PATCH 1/3] fixed remove header button misalignment --- .../Webhooks/EditView/components/HeadersInput/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js b/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js index 02436d6622..d20b4e5e31 100644 --- a/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js +++ b/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js @@ -1,4 +1,5 @@ import React from 'react'; +import styled from 'styled-components'; import { RemoveRoundedButton } from '@strapi/helper-plugin'; import AddIcon from '@strapi/icons/AddIcon'; import { Box } from '@strapi/parts/Box'; @@ -11,6 +12,10 @@ import { TextButton } from '@strapi/parts/TextButton'; import { Field, FieldArray, useFormikContext } from 'formik'; import { useIntl } from 'react-intl'; +const RemoveButtonContainer = styled(Box)` + transform: translateY(50%); +`; + const HeadersInput = () => { const { formatMessage } = useIntl(); const { values, errors } = useFormikContext(); @@ -70,7 +75,7 @@ const HeadersInput = () => { } /> - + values.headers.length !== 1 && remove(i)} label={formatMessage( @@ -81,7 +86,7 @@ const HeadersInput = () => { { number: i + 1 } )} /> - + From 7cc8feaeaa62b60699cf2d6f14f09b6198ca910f Mon Sep 17 00:00:00 2001 From: ronronscelestes Date: Wed, 6 Oct 2021 09:16:13 +0200 Subject: [PATCH 2/3] feedback fix - removed translateY --- .../Webhooks/EditView/components/HeadersInput/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js b/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js index d20b4e5e31..aa5b027231 100644 --- a/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js +++ b/packages/core/admin/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/HeadersInput/index.js @@ -12,8 +12,8 @@ import { TextButton } from '@strapi/parts/TextButton'; import { Field, FieldArray, useFormikContext } from 'formik'; import { useIntl } from 'react-intl'; -const RemoveButtonContainer = styled(Box)` - transform: translateY(50%); +const RemoveButtonContainer = styled(Row)` + height: ${({ theme }) => theme.sizes.input.M}; `; const HeadersInput = () => { @@ -56,7 +56,7 @@ const HeadersInput = () => { /> - + Date: Thu, 7 Oct 2021 09:44:56 +0200 Subject: [PATCH 3/3] Move GenericInput into helper-plugin Signed-off-by: soupette --- .../components/Inputs/GenericInput.js | 347 ------------------ .../components/Inputs/index.js | 2 +- .../src/pages/ProfilePage/tests/index.test.js | 24 +- .../tests/__snapshots__/index.test.js.snap | 164 ++++----- .../tests/__snapshots__/index.test.js.snap | 164 ++++----- .../lib/src/components/GenericInput/index.js | 331 ++++++++++++++--- .../AdvancedSettings/tests/index.test.js | 16 +- 7 files changed, 466 insertions(+), 582 deletions(-) delete mode 100644 packages/core/admin/admin/src/content-manager/components/Inputs/GenericInput.js diff --git a/packages/core/admin/admin/src/content-manager/components/Inputs/GenericInput.js b/packages/core/admin/admin/src/content-manager/components/Inputs/GenericInput.js deleted file mode 100644 index c87dcdbaea..0000000000 --- a/packages/core/admin/admin/src/content-manager/components/Inputs/GenericInput.js +++ /dev/null @@ -1,347 +0,0 @@ -/** - * - * GenericInput - * This is a temp file move it to the helper plugin when ready - */ - -import React, { useState } from 'react'; -import PropTypes from 'prop-types'; -import { useIntl } from 'react-intl'; -import cloneDeep from 'lodash/cloneDeep'; -import { formatISO } from 'date-fns'; -import { DatePicker } from '@strapi/parts/DatePicker'; -import { NumberInput } from '@strapi/parts/NumberInput'; -import { Select, Option } from '@strapi/parts/Select'; -import { Textarea } from '@strapi/parts/Textarea'; -import { TextInput } from '@strapi/parts/TextInput'; -import { TimePicker } from '@strapi/parts/TimePicker'; -import { ToggleInput } from '@strapi/parts/ToggleInput'; -import Hide from '@strapi/icons/Hide'; -import Show from '@strapi/icons/Show'; - -const GenericInput = ({ - autoComplete, - customInputs, - description, - disabled, - intlLabel, - labelAction, - error, - name, - onChange, - options, - placeholder, - step, - type, - value, - ...rest -}) => { - const { formatMessage } = useIntl(); - const [showPassword, setShowPassword] = useState(false); - - const CustomInput = customInputs ? customInputs[type] : null; - - if (CustomInput) { - return ( - - ); - } - - const label = intlLabel.id - ? formatMessage( - { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage }, - { ...intlLabel.values } - ) - : name; - - const hint = description - ? formatMessage( - { id: description.id, defaultMessage: description.defaultMessage }, - { ...description.values } - ) - : ''; - - const formattedPlaceholder = placeholder - ? formatMessage( - { id: placeholder.id, defaultMessage: placeholder.defaultMessage }, - { ...placeholder.values } - ) - : ''; - - const errorMessage = error ? formatMessage({ id: error, defaultMessage: error }) : ''; - - switch (type) { - case 'bool': { - return ( - { - onChange({ target: { name, value: e.target.checked } }); - }} - /> - ); - } - case 'date': { - return ( - { - const formattedDate = formatISO(cloneDeep(date), { representation: 'date' }); - - onChange({ target: { name, value: formattedDate, type } }); - }} - onClear={() => onChange({ target: { name, value: '', type } })} - placeholder={formattedPlaceholder} - selectedDate={value ? new Date(value) : null} - selectedDateLabel={formattedDate => `Date picker, current is ${formattedDate}`} - /> - ); - } - case 'number': { - return ( - { - onChange({ target: { name, value, type } }); - }} - placeholder={formattedPlaceholder} - step={step} - value={value || undefined} - /> - ); - } - case 'email': - case 'text': - case 'string': { - return ( - - ); - } - case 'password': { - return ( - { - setShowPassword(prev => !prev); - }} - style={{ - border: 'none', - padding: 0, - background: 'transparent', - }} - type="button" - > - {showPassword ? : } - - } - label={label} - labelAction={labelAction} - id={name} - hint={hint} - name={name} - onChange={onChange} - placeholder={formattedPlaceholder} - type={showPassword ? 'text' : 'password'} - value={value || ''} - /> - ); - } - case 'select': { - return ( - - ); - } - case 'textarea': { - return ( - - ); - } - case 'time': { - let time = value; - - // The backend send a value which has the following format: '00:45:00.000' - // or the time picker only supports hours & minutes so we need to mutate the value - if (value && value.split(':').length > 2) { - time = time.split(':'); - time.pop(); - time = time.join(':'); - } - - return ( - { - onChange({ target: { name, value: `${time}`, type } }); - }} - onClear={() => { - onChange({ target: { name, value: null, type } }); - }} - placeholder={formattedPlaceholder} - step={step} - value={time} - /> - ); - } - default: { - return
{type} is not supported
; - } - } -}; - -GenericInput.defaultProps = { - autoComplete: undefined, - customInputs: null, - description: null, - disabled: false, - error: '', - labelAction: undefined, - placeholder: null, - options: [], - step: 1, - value: '', -}; - -GenericInput.propTypes = { - autoComplete: PropTypes.string, - customInputs: PropTypes.object, - description: PropTypes.shape({ - id: PropTypes.string.isRequired, - defaultMessage: PropTypes.string.isRequired, - values: PropTypes.object, - }), - disabled: PropTypes.bool, - error: PropTypes.string, - intlLabel: PropTypes.shape({ - id: PropTypes.string.isRequired, - defaultMessage: PropTypes.string.isRequired, - values: PropTypes.object, - }).isRequired, - labelAction: PropTypes.element, - name: PropTypes.string.isRequired, - onChange: PropTypes.func.isRequired, - options: PropTypes.arrayOf( - PropTypes.shape({ - metadatas: PropTypes.shape({ - intlLabel: PropTypes.shape({ - id: PropTypes.string.isRequired, - defaultMessage: PropTypes.string.isRequired, - }).isRequired, - disabled: PropTypes.bool, - hidden: PropTypes.bool, - }).isRequired, - key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - }).isRequired - ), - placeholder: PropTypes.shape({ - id: PropTypes.string.isRequired, - defaultMessage: PropTypes.string.isRequired, - values: PropTypes.object, - }), - step: PropTypes.number, - type: PropTypes.string.isRequired, - value: PropTypes.any, -}; - -export default GenericInput; diff --git a/packages/core/admin/admin/src/content-manager/components/Inputs/index.js b/packages/core/admin/admin/src/content-manager/components/Inputs/index.js index 593365a965..5116cdc605 100644 --- a/packages/core/admin/admin/src/content-manager/components/Inputs/index.js +++ b/packages/core/admin/admin/src/content-manager/components/Inputs/index.js @@ -5,6 +5,7 @@ import omit from 'lodash/omit'; import take from 'lodash/take'; import isEqual from 'react-fast-compare'; import { + GenericInput, NotAllowedInput, // useLibrary } from '@strapi/helper-plugin'; @@ -13,7 +14,6 @@ import { getFieldName } from '../../utils'; import Wysiwyg from '../Wysiwyg'; import InputJSON from '../InputJSON'; import ComingSoonInput from './ComingSoonInput'; -import GenericInput from './GenericInput'; import InputUID from '../InputUID'; import SelectWrapper from '../SelectWrapper'; diff --git a/packages/core/admin/admin/src/pages/ProfilePage/tests/index.test.js b/packages/core/admin/admin/src/pages/ProfilePage/tests/index.test.js index dc6f007514..9ea4ff45c2 100644 --- a/packages/core/admin/admin/src/pages/ProfilePage/tests/index.test.js +++ b/packages/core/admin/admin/src/pages/ProfilePage/tests/index.test.js @@ -792,7 +792,7 @@ describe('ADMIN | Pages | Profile page', () => { > @@ -804,7 +804,7 @@ describe('ADMIN | Pages | Profile page', () => { aria-disabled="false" aria-invalid="false" class="c27" - id="textinput-1" + id="firstname" name="firstname" placeholder="" type="text" @@ -832,7 +832,7 @@ describe('ADMIN | Pages | Profile page', () => { > @@ -844,7 +844,7 @@ describe('ADMIN | Pages | Profile page', () => { aria-disabled="false" aria-invalid="false" class="c27" - id="textinput-2" + id="lastname" name="lastname" placeholder="" type="text" @@ -872,7 +872,7 @@ describe('ADMIN | Pages | Profile page', () => { > @@ -884,7 +884,7 @@ describe('ADMIN | Pages | Profile page', () => { aria-disabled="false" aria-invalid="false" class="c27" - id="textinput-3" + id="email" name="email" placeholder="" type="email" @@ -912,7 +912,7 @@ describe('ADMIN | Pages | Profile page', () => { > @@ -924,7 +924,7 @@ describe('ADMIN | Pages | Profile page', () => { aria-disabled="false" aria-invalid="false" class="c27" - id="textinput-4" + id="username" name="username" placeholder="" type="text" @@ -969,7 +969,7 @@ describe('ADMIN | Pages | Profile page', () => { > @@ -981,7 +981,7 @@ describe('ADMIN | Pages | Profile page', () => { aria-disabled="false" aria-invalid="false" class="c28" - id="textinput-5" + id="textinput-1" name="password" type="password" value="" @@ -1030,7 +1030,7 @@ describe('ADMIN | Pages | Profile page', () => { > @@ -1042,7 +1042,7 @@ describe('ADMIN | Pages | Profile page', () => { aria-disabled="false" aria-invalid="false" class="c28" - id="textinput-6" + id="textinput-2" name="confirmPassword" type="password" value="" diff --git a/packages/core/admin/admin/src/pages/SettingsPage/pages/Roles/EditPage/tests/__snapshots__/index.test.js.snap b/packages/core/admin/admin/src/pages/SettingsPage/pages/Roles/EditPage/tests/__snapshots__/index.test.js.snap index d39f5ee125..88458d8863 100644 --- a/packages/core/admin/admin/src/pages/SettingsPage/pages/Roles/EditPage/tests/__snapshots__/index.test.js.snap +++ b/packages/core/admin/admin/src/pages/SettingsPage/pages/Roles/EditPage/tests/__snapshots__/index.test.js.snap @@ -486,88 +486,6 @@ exports[` renders and matches the snapshot 1`] = ` margin-top: 4px; } -.c37 { - height: 100vh; -} - -.c1 { - background: #f6f6f9; - padding-top: 56px; - padding-right: 56px; - padding-bottom: 56px; - padding-left: 56px; -} - -.c13 { - padding-right: 56px; - padding-left: 56px; -} - -.c2 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c3 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c4 { - font-weight: 600; - font-size: 2rem; - line-height: 1.25; - color: #32324d; -} - -.c11 { - font-weight: 400; - font-size: 0.875rem; - line-height: 1.43; - color: #666687; -} - -.c12 { - font-size: 1rem; - line-height: 1.5; -} - -.c0 { - outline: none; -} - -.c22 { - display: grid; - grid-template-columns: repeat(12,1fr); - gap: 16px; -} - -.c23 { - grid-column: span 6; -} - .c33 { font-weight: 500; font-size: 0.75rem; @@ -700,6 +618,88 @@ exports[` renders and matches the snapshot 1`] = ` opacity: 1; } +.c37 { + height: 100vh; +} + +.c1 { + background: #f6f6f9; + padding-top: 56px; + padding-right: 56px; + padding-bottom: 56px; + padding-left: 56px; +} + +.c13 { + padding-right: 56px; + padding-left: 56px; +} + +.c2 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c3 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c4 { + font-weight: 600; + font-size: 2rem; + line-height: 1.25; + color: #32324d; +} + +.c11 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #666687; +} + +.c12 { + font-size: 1rem; + line-height: 1.5; +} + +.c0 { + outline: none; +} + +.c22 { + display: grid; + grid-template-columns: repeat(12,1fr); + gap: 16px; +} + +.c23 { + grid-column: span 6; +} + @media (max-width:68.75rem) { .c23 { grid-column: span; diff --git a/packages/core/admin/ee/admin/pages/SettingsPage/pages/Roles/CreatePage/tests/__snapshots__/index.test.js.snap b/packages/core/admin/ee/admin/pages/SettingsPage/pages/Roles/CreatePage/tests/__snapshots__/index.test.js.snap index a0746380e8..2ddda3cc2e 100644 --- a/packages/core/admin/ee/admin/pages/SettingsPage/pages/Roles/CreatePage/tests/__snapshots__/index.test.js.snap +++ b/packages/core/admin/ee/admin/pages/SettingsPage/pages/Roles/CreatePage/tests/__snapshots__/index.test.js.snap @@ -479,88 +479,6 @@ exports[` renders and matches the snapshot 1`] = ` margin-top: 4px; } -.c37 { - height: 100vh; -} - -.c1 { - background: #f6f6f9; - padding-top: 56px; - padding-right: 56px; - padding-bottom: 56px; - padding-left: 56px; -} - -.c14 { - padding-right: 56px; - padding-left: 56px; -} - -.c2 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c3 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c4 { - font-weight: 600; - font-size: 2rem; - line-height: 1.25; - color: #32324d; -} - -.c12 { - font-weight: 400; - font-size: 0.875rem; - line-height: 1.43; - color: #666687; -} - -.c13 { - font-size: 1rem; - line-height: 1.5; -} - -.c22 { - display: grid; - grid-template-columns: repeat(12,1fr); - gap: 16px; -} - -.c23 { - grid-column: span 6; -} - -.c0 { - outline: none; -} - .c33 { font-weight: 500; font-size: 0.75rem; @@ -693,6 +611,88 @@ exports[` renders and matches the snapshot 1`] = ` opacity: 1; } +.c37 { + height: 100vh; +} + +.c1 { + background: #f6f6f9; + padding-top: 56px; + padding-right: 56px; + padding-bottom: 56px; + padding-left: 56px; +} + +.c14 { + padding-right: 56px; + padding-left: 56px; +} + +.c2 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c3 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.c4 { + font-weight: 600; + font-size: 2rem; + line-height: 1.25; + color: #32324d; +} + +.c12 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #666687; +} + +.c13 { + font-size: 1rem; + line-height: 1.5; +} + +.c22 { + display: grid; + grid-template-columns: repeat(12,1fr); + gap: 16px; +} + +.c23 { + grid-column: span 6; +} + +.c0 { + outline: none; +} + .c21 { border: 1px solid #d9d8ff; background: #f0f0ff; diff --git a/packages/core/helper-plugin/lib/src/components/GenericInput/index.js b/packages/core/helper-plugin/lib/src/components/GenericInput/index.js index eaa5804bcd..70606e74f8 100644 --- a/packages/core/helper-plugin/lib/src/components/GenericInput/index.js +++ b/packages/core/helper-plugin/lib/src/components/GenericInput/index.js @@ -1,32 +1,71 @@ /** * - * Input + * GenericInput * */ -import React from 'react'; -import { useIntl } from 'react-intl'; -import { ToggleInput } from '@strapi/parts/ToggleInput'; -import { TextInput } from '@strapi/parts/TextInput'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; +import { useIntl } from 'react-intl'; +import cloneDeep from 'lodash/cloneDeep'; +import { formatISO } from 'date-fns'; +import { DatePicker } from '@strapi/parts/DatePicker'; +import { NumberInput } from '@strapi/parts/NumberInput'; +import { Select, Option } from '@strapi/parts/Select'; +import { Textarea } from '@strapi/parts/Textarea'; +import { TextInput } from '@strapi/parts/TextInput'; +import { TimePicker } from '@strapi/parts/TimePicker'; +import { ToggleInput } from '@strapi/parts/ToggleInput'; +import Hide from '@strapi/icons/Hide'; +import Show from '@strapi/icons/Show'; -const Input = ({ +const GenericInput = ({ + autoComplete, + customInputs, description, disabled, intlLabel, + labelAction, error, name, onChange, + options, placeholder, + step, type, value, + ...rest }) => { const { formatMessage } = useIntl(); + const [showPassword, setShowPassword] = useState(false); + + const CustomInput = customInputs ? customInputs[type] : null; + + if (CustomInput) { + return ( + + ); + } + + const label = intlLabel.id + ? formatMessage( + { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage }, + { ...intlLabel.values } + ) + : name; - const label = formatMessage( - { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage }, - { ...intlLabel.values } - ); const hint = description ? formatMessage( { id: description.id, defaultMessage: description.defaultMessage }, @@ -34,29 +73,6 @@ const Input = ({ ) : ''; - if (type === 'bool') { - return ( - { - onChange({ target: { name, value: e.target.checked } }); - }} - /> - ); - } - const formattedPlaceholder = placeholder ? formatMessage( { id: placeholder.id, defaultMessage: placeholder.defaultMessage }, @@ -66,30 +82,229 @@ const Input = ({ const errorMessage = error ? formatMessage({ id: error, defaultMessage: error }) : ''; - return ( - - ); + switch (type) { + case 'bool': { + return ( + { + onChange({ target: { name, value: e.target.checked } }); + }} + /> + ); + } + case 'date': { + return ( + { + const formattedDate = formatISO(cloneDeep(date), { representation: 'date' }); + + onChange({ target: { name, value: formattedDate, type } }); + }} + onClear={() => onChange({ target: { name, value: '', type } })} + placeholder={formattedPlaceholder} + selectedDate={value ? new Date(value) : null} + selectedDateLabel={formattedDate => `Date picker, current is ${formattedDate}`} + /> + ); + } + case 'number': { + return ( + { + onChange({ target: { name, value, type } }); + }} + placeholder={formattedPlaceholder} + step={step} + value={value || undefined} + /> + ); + } + case 'email': + case 'text': + case 'string': { + return ( + + ); + } + case 'password': { + return ( + { + setShowPassword(prev => !prev); + }} + style={{ + border: 'none', + padding: 0, + background: 'transparent', + }} + type="button" + > + {showPassword ? : } + + } + label={label} + labelAction={labelAction} + id={name} + hint={hint} + name={name} + onChange={onChange} + placeholder={formattedPlaceholder} + type={showPassword ? 'text' : 'password'} + value={value || ''} + /> + ); + } + case 'select': { + return ( + + ); + } + case 'textarea': { + return ( + + ); + } + case 'time': { + let time = value; + + // The backend send a value which has the following format: '00:45:00.000' + // or the time picker only supports hours & minutes so we need to mutate the value + if (value && value.split(':').length > 2) { + time = time.split(':'); + time.pop(); + time = time.join(':'); + } + + return ( + { + onChange({ target: { name, value: `${time}`, type } }); + }} + onClear={() => { + onChange({ target: { name, value: null, type } }); + }} + placeholder={formattedPlaceholder} + step={step} + value={time} + /> + ); + } + default: { + return
{type} is not supported
; + } + } }; -Input.defaultProps = { +GenericInput.defaultProps = { + autoComplete: undefined, + customInputs: null, description: null, disabled: false, error: '', + labelAction: undefined, placeholder: null, + options: [], + step: 1, value: '', }; -Input.propTypes = { +GenericInput.propTypes = { + autoComplete: PropTypes.string, + customInputs: PropTypes.object, description: PropTypes.shape({ id: PropTypes.string.isRequired, defaultMessage: PropTypes.string.isRequired, @@ -102,15 +317,31 @@ Input.propTypes = { defaultMessage: PropTypes.string.isRequired, values: PropTypes.object, }).isRequired, + labelAction: PropTypes.element, name: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired, + options: PropTypes.arrayOf( + PropTypes.shape({ + metadatas: PropTypes.shape({ + intlLabel: PropTypes.shape({ + id: PropTypes.string.isRequired, + defaultMessage: PropTypes.string.isRequired, + }).isRequired, + disabled: PropTypes.bool, + hidden: PropTypes.bool, + }).isRequired, + key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + }).isRequired + ), placeholder: PropTypes.shape({ id: PropTypes.string.isRequired, defaultMessage: PropTypes.string.isRequired, values: PropTypes.object, }), + step: PropTypes.number, type: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), + value: PropTypes.any, }; -export default Input; +export default GenericInput; diff --git a/packages/plugins/users-permissions/admin/src/pages/AdvancedSettings/tests/index.test.js b/packages/plugins/users-permissions/admin/src/pages/AdvancedSettings/tests/index.test.js index 98196c3817..a65b222095 100644 --- a/packages/plugins/users-permissions/admin/src/pages/AdvancedSettings/tests/index.test.js +++ b/packages/plugins/users-permissions/admin/src/pages/AdvancedSettings/tests/index.test.js @@ -1115,7 +1115,7 @@ describe('ADMIN | Pages | Settings | Advanced Settings', () => { > @@ -1124,11 +1124,11 @@ describe('ADMIN | Pages | Settings | Advanced Settings', () => { class="c54 c55" > {

URL of your application's reset password page.

@@ -1232,7 +1232,7 @@ describe('ADMIN | Pages | Settings | Advanced Settings', () => { > @@ -1242,11 +1242,11 @@ describe('ADMIN | Pages | Settings | Advanced Settings', () => { disabled="" > {

After you confirmed your email, choose where you will be redirected.