diff --git a/examples/getstarted/api/my-super-content-type/models/my-super-content-type.settings.json b/examples/getstarted/api/my-super-content-type/models/my-super-content-type.settings.json index f2c78089ab..dfa6d7af84 100644 --- a/examples/getstarted/api/my-super-content-type/models/my-super-content-type.settings.json +++ b/examples/getstarted/api/my-super-content-type/models/my-super-content-type.settings.json @@ -2,7 +2,7 @@ "connection": "default", "collectionName": "my_super_content_type", "info": { - "name": "My super content type ⚠️" + "name": "My super content type" }, "attributes": { "name": { diff --git a/packages/strapi-helper-plugin/lib/src/components/LeftMenuList/index.js b/packages/strapi-helper-plugin/lib/src/components/LeftMenuList/index.js index a32a0bac02..5d21690c54 100644 --- a/packages/strapi-helper-plugin/lib/src/components/LeftMenuList/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/LeftMenuList/index.js @@ -59,11 +59,11 @@ function LeftMenuList({ customLink, links, title }) { return links.map(link => { return { ...link, - links: matchSorter(link.links, search, { keys: ['name'] }), + links: matchSorter(link.links, search, { keys: ['title'] }), }; }); } - return matchSorter(links, search, { keys: ['name'] }); + return matchSorter(links, search, { keys: ['title'] }); }; const getTitle = () => diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js index f79d558be5..47ac3bf82d 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js @@ -1,6 +1,6 @@ import React, { memo, useEffect, useReducer, useState, useRef } from 'react'; import PropTypes from 'prop-types'; -import { get, groupBy, set, size, sortBy } from 'lodash'; +import { camelCase, get, groupBy, set, size, sortBy } from 'lodash'; import { request, LoadingIndicatorPage, @@ -349,7 +349,7 @@ const DataManagerProvider = ({ allIcons, children }) => { to: `/plugins/${pluginId}/content-types/${uid}`, })) .filter(obj => obj !== null), - obj => obj.title + obj => camelCase(obj.title) ); const shouldRedirect = () => { diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/reducer.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/reducer.js index 020db26abf..99333e690a 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/reducer.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/reducer.js @@ -401,20 +401,9 @@ const reducer = (state, action) => { ...pathToAttributes, attributeToRemoveName, ]; - console.log( - pathToAttributeToRemove, - state.getIn([ - 'modifiedData', - 'contentType', - 'schema', - 'attributes', - 'price_range', - ]) - ); - // return state; + const attributeToRemoveData = state.getIn(pathToAttributeToRemove); - // console.log(attributeToRemoveData); - // return state; + const isRemovingRelationAttribute = attributeToRemoveData.get('nature') !== undefined; // Only content types can have relations that with themselves since @@ -452,11 +441,11 @@ const reducer = (state, action) => { // Reset the state with the initial data // All created components and content types will be lost - // if (!action.hasJustCreatedSchema) { - // newState = newState - // .update('components', () => state.get('initialComponents')) - // .update('contentTypes', () => state.get('initialContentTypes')); - // } + if (!action.hasJustCreatedSchema) { + newState = newState + .update('components', () => state.get('initialComponents')) + .update('contentTypes', () => state.get('initialContentTypes')); + } return newState; } 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 ab5c8e003b..dbf54187f5 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 @@ -1,5 +1,6 @@ import { fromJS } from 'immutable'; import pluralize from 'pluralize'; +import { snakeCase } from 'lodash'; import makeUnique from '../../utils/makeUnique'; import { createComponentUid } from './utils/createUid'; import { @@ -52,7 +53,7 @@ const reducer = (state, action) => { return null; }) .update('name', oldValue => { - return pluralize(oldValue, shouldPluralizeName(value)); + return pluralize(snakeCase(oldValue), shouldPluralizeName(value)); }) .update('targetAttribute', oldValue => { if (['oneWay', 'manyWay'].includes(value)) { @@ -61,7 +62,7 @@ const reducer = (state, action) => { return pluralize( oldValue === '-' - ? oneThatIsCreatingARelationWithAnother + ? snakeCase(oneThatIsCreatingARelationWithAnother) : oldValue, shouldPluralizeTargetAttribute(value) ); @@ -80,7 +81,7 @@ const reducer = (state, action) => { .update('target', () => value) .update('name', () => { return pluralize( - selectedContentTypeFriendlyName, + snakeCase(selectedContentTypeFriendlyName), shouldPluralizeName(obj.get('nature')) ); }) @@ -90,7 +91,7 @@ const reducer = (state, action) => { } return pluralize( - oneThatIsCreatingARelationWithAnother, + snakeCase(oneThatIsCreatingARelationWithAnother), shouldPluralizeTargetAttribute(obj.get('nature')) ); }); @@ -187,7 +188,7 @@ const reducer = (state, action) => { dataToSet = { type: 'enumeration', enum: [] }; } else if (attributeType === 'relation') { dataToSet = { - name: nameToSetForRelation, + name: snakeCase(nameToSetForRelation), nature: 'oneWay', targetAttribute: '-', target: targetUid, diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ListView/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ListView/index.js index 0b3bd8a77b..6b0683f35b 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ListView/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ListView/index.js @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { Prompt, useHistory, useLocation } from 'react-router-dom'; import PropTypes from 'prop-types'; -import { get, isEqual } from 'lodash'; +import { get, has, isEqual } from 'lodash'; import { BackHeader, ListWrapper, @@ -67,6 +67,7 @@ const ListPage = () => { [firstMainDataPath, 'schema', 'name'], '' ); + const isFromPlugin = has(initialData, [firstMainDataPath, 'plugin']); const hasModelBeenModified = !isEqual(modifiedData, initialData); const forTarget = isInContentTypeView ? 'contentType' : 'component'; @@ -211,25 +212,26 @@ const ListPage = () => { : [], title: { label, - cta: isInDevelopmentMode - ? { - icon: 'pencil-alt', - onClick: async () => { - await wait(); + cta: + isInDevelopmentMode && !isFromPlugin + ? { + icon: 'pencil-alt', + onClick: async () => { + await wait(); - push({ - search: makeSearch({ - modalType: firstMainDataPath, - actionType: 'edit', - settingType: 'base', - forTarget: firstMainDataPath, - targetUid, - headerDisplayName: label, - }), - }); - }, - } - : null, + push({ + search: makeSearch({ + modalType: firstMainDataPath, + actionType: 'edit', + settingType: 'base', + forTarget: firstMainDataPath, + targetUid, + headerDisplayName: label, + }), + }); + }, + } + : null, }, content: getDescription(), };