diff --git a/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/MenuList.js b/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/MenuList.js deleted file mode 100644 index 570ed274d6..0000000000 --- a/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/MenuList.js +++ /dev/null @@ -1,115 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { components } from 'react-select'; -import { useIntl } from 'react-intl'; -import { CheckboxWrapper, Label } from '@buffetjs/styles'; -import getTrad from '../../utils/getTrad'; -import SelectCheckbox from '../SelectCheckbox'; -import SubUl from '../SelectMenuSubUl'; -import UpperFirst from '../UpperFirst'; -import Ul from '../SelectMenuUl'; -import Text from './Text'; - -const MenuList = ({ selectProps: { changeMediaAllowedTypes, value }, ...rest }) => { - const { formatMessage } = useIntl(); - const Component = components.MenuList; - const areAllAllowedTypesSelected = value.value && value.value.length === 3; - const someChecked = value.value && !areAllAllowedTypesSelected && value.value.length > 0; - const options = [ - { - name: 'images', - infos: '(JPEG, PNG, GIF, SVG, TIFF, ICO, DVU)', - }, - { - name: 'videos', - infos: '(MPEG, MP4, Quicktime, WMV, AVI, FLV)', - }, - - { - name: 'files', - infos: '(CSV, ZIP, MP3, PDF, Excel, JSON, ...)', - }, - ]; - - return ( - - - - ); -}; - -MenuList.defaultProps = { - selectProps: { - value: {}, - }, -}; - -MenuList.propTypes = { - selectProps: PropTypes.shape({ - changeMediaAllowedTypes: PropTypes.func.isRequired, - value: PropTypes.object, - }), -}; - -export default MenuList; diff --git a/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/Text.js b/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/Text.js deleted file mode 100644 index 6bcc8e0055..0000000000 --- a/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/Text.js +++ /dev/null @@ -1,26 +0,0 @@ -import styled from 'styled-components'; -import PropTypes from 'prop-types'; - -const Text = styled.p` - display: contents; - color: ${({ theme, color }) => theme.main.colors[color] || color}; - font-size: ${({ theme, fontSize }) => theme.main.sizes.fonts[fontSize]}; - font-weight: ${({ theme, fontWeight }) => theme.main.fontWeights[fontWeight]}; - text-transform: ${({ textTransform }) => textTransform}; -`; - -Text.defaultProps = { - color: 'black', - fontSize: 'md', - fontWeight: 'regular', - textTransform: 'none', -}; - -Text.propTypes = { - color: PropTypes.string, - fontSize: PropTypes.string, - fontWeight: PropTypes.string, - textTransform: PropTypes.string, -}; - -export default Text; diff --git a/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/index.js b/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/index.js index c9d6b617d5..c7ecf0fe94 100644 --- a/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/index.js +++ b/packages/core/content-type-builder/admin/src/components/AllowedTypesSelect/index.js @@ -1,18 +1,23 @@ -import React, { useRef } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; -import Select from 'react-select'; import { useIntl } from 'react-intl'; +import { MultiSelectNested } from '@strapi/parts/Select'; import upperFirst from 'lodash/upperFirst'; -import MenuList from './MenuList'; import getTrad from '../../utils/getTrad'; -const AllowedTypesSelect = ({ name, changeMediaAllowedTypes, styles, value }) => { +const options = [ + { + label: 'All', + children: [ + { label: 'images (JPEG, PNG, GIF, SVG, TIFF, ICO, DVU)', value: 'images' }, + { label: 'videos (MPEG, MP4, Quicktime, WMV, AVI, FLV)', value: 'videos' }, + { label: 'files (CSV, ZIP, MP3, PDF, Excel, JSON, ...)', value: 'files' }, + ], + }, +]; + +const AllowedTypesSelect = ({ intlLabel, name, onChange, value }) => { const { formatMessage } = useIntl(); - // Create a ref in order to access the StateManager - // So we can close the menu after clicking on a menu item - // This allows us to get rid of the menuIsOpen state management - // So we let the custom components taking care of it - const ref = useRef(); /* eslint-disable indent */ @@ -26,17 +31,24 @@ const AllowedTypesSelect = ({ name, changeMediaAllowedTypes, styles, value }) => /* eslint-enable indent */ + const label = intlLabel.id + ? formatMessage({ id: intlLabel.id, defaultMessage: intlLabel.defaultMessage }) + : name; + return ( -