From 38b58c66b5638dc9a02767cde660e3f7a109dbd6 Mon Sep 17 00:00:00 2001 From: cyril lopez Date: Mon, 27 Sep 2021 15:09:33 +0200 Subject: [PATCH] Cm/coming soon input (#11075) --- .../components/Inputs/ComingSoonInput.js | 69 +++++++++++++++++++ .../components/Inputs/index.js | 15 +++- 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 packages/core/admin/admin/src/content-manager/components/Inputs/ComingSoonInput.js diff --git a/packages/core/admin/admin/src/content-manager/components/Inputs/ComingSoonInput.js b/packages/core/admin/admin/src/content-manager/components/Inputs/ComingSoonInput.js new file mode 100644 index 0000000000..fe3ac764e2 --- /dev/null +++ b/packages/core/admin/admin/src/content-manager/components/Inputs/ComingSoonInput.js @@ -0,0 +1,69 @@ +/** + * + * CominSoonInput + * + */ + +import React from 'react'; +import { useIntl } from 'react-intl'; +import { TextInput } from '@strapi/parts/TextInput'; +import PropTypes from 'prop-types'; + +const CominSoonInput = ({ description, intlLabel, labelAction, error, name }) => { + const { formatMessage } = useIntl(); + 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 errorMessage = error ? formatMessage({ id: error, defaultMessage: error }) : ''; + + return ( + {}} + placeholder="Coming soon" + type="text" + value="" + /> + ); +}; + +CominSoonInput.defaultProps = { + description: null, + error: '', + labelAction: undefined, +}; + +CominSoonInput.propTypes = { + description: PropTypes.shape({ + id: PropTypes.string.isRequired, + defaultMessage: PropTypes.string.isRequired, + values: PropTypes.object, + }), + 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, +}; + +export default CominSoonInput; 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 63e312c9e1..384e66ce51 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 @@ -12,6 +12,7 @@ import { useContentTypeLayout } from '../../hooks'; import { getFieldName } from '../../utils'; import Wysiwyg from '../Wysiwyg'; import InputJSON from '../InputJSON'; +import ComingSoonInput from './ComingSoonInput'; import GenericInput from './GenericInput'; // import SelectWrapper from '../SelectWrapper'; // import WysiwygWithErrors from '../WysiwygWithErrors'; @@ -188,7 +189,14 @@ function Inputs({ } if (type === 'relation') { - return 'RELATION'; + // return 'RELATION'; + return ( + + ); // return ( //
//
TODO media
, + // FIXME + datetime: ComingSoonInput, + media: ComingSoonInput, uid: () =>
TODO uid
, - // wysiwyg: () =>
TODO wysiwyg
, wysiwyg: Wysiwyg, }} multiple={fieldSchema.multiple || false}