diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/MultipleMenuList.js b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/MultipleMenuList.js index 1964cd6b3e..adac032b33 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/MultipleMenuList.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/MultipleMenuList.js @@ -14,7 +14,7 @@ const MultipleMenuList = ({ }) => { const { componentsGroupedByCategory } = useDataManager(); const Component = components.MenuList; - console.log({ menu: value.value }); + const allComponentsCategory = Object.keys(componentsGroupedByCategory).reduce( (acc, current) => { const categoryCompos = componentsGroupedByCategory[current].map(compo => { diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js index c7a20d658b..7c429dd82c 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js @@ -24,7 +24,7 @@ const Value = ({ children, ...props }) => { isMultiple, }, } = props; - console.log({ value }); + const displayedCategory = isCreatingComponent ? componentCategory : category; const displayedName = isCreatingComponent ? componentName : name; const style = { color: '#333740' }; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/reducer.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/reducer.js index 71e52310bb..becc286834 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/reducer.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/reducer.js @@ -2,6 +2,10 @@ import { fromJS } from 'immutable'; import pluralize from 'pluralize'; import makeUnique from '../../utils/makeUnique'; import { createComponentUid } from './utils/createUid'; +import { + shouldPluralizeName, + shouldPluralizeTargetAttribute, +} from './utils/relations'; const initialState = fromJS({ formErrors: {}, @@ -11,11 +15,6 @@ const initialState = fromJS({ isCreatingComponentWhileAddingAField: false, }); -export const shouldPluralizeTargetAttribute = nature => - ['manyToMany', 'manyToOne'].includes(nature) ? 2 : 1; -export const shouldPluralizeName = nature => - ['manyToMany', 'oneToMany', 'manyWay'].includes(nature) ? 2 : 1; - const reducer = (state, action) => { switch (action.type) { case 'ADD_COMPONENTS_TO_DYNAMIC_ZONE': { diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/utils/relations.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/utils/relations.js new file mode 100644 index 0000000000..dd249ac176 --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/utils/relations.js @@ -0,0 +1,7 @@ +const shouldPluralizeName = nature => + ['manyToMany', 'oneToMany', 'manyWay'].includes(nature) ? 2 : 1; + +const shouldPluralizeTargetAttribute = nature => + ['manyToMany', 'manyToOne'].includes(nature) ? 2 : 1; + +export { shouldPluralizeName, shouldPluralizeTargetAttribute };