diff --git a/packages/strapi-admin/admin/src/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js b/packages/strapi-admin/admin/src/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js index 498479bfd5..91bcd40533 100644 --- a/packages/strapi-admin/admin/src/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js +++ b/packages/strapi-admin/admin/src/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js @@ -180,7 +180,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { 0 && @@ -190,7 +190,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { value={allCurrentActionsSize === allActionsSize} /> { lineHeight="20px" textTransform="uppercase" > - {contentType.name} + {contentType.info.name} @@ -216,7 +216,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { hasConditions={checkConditions(permissionLayout.action)} disabled value={hasContentTypeAction(permissionLayout.action)} - name={`${contentType.name}-${permissionLayout.action}`} + name={`${contentType.info.name}-${permissionLayout.action}`} /> ) : ( { disabled value={hasContentTypeAction(permissionLayout.action)} someChecked={hasSomeAttributeByAction(permissionLayout.action)} - name={`${contentType.name}-${permissionLayout.action}`} + name={`${contentType.info.name}-${permissionLayout.action}`} /> ) )} diff --git a/packages/strapi-admin/admin/src/components/Roles/Permissions/reducer.js b/packages/strapi-admin/admin/src/components/Roles/Permissions/reducer.js index fba8d12fff..b87c16a2a6 100644 --- a/packages/strapi-admin/admin/src/components/Roles/Permissions/reducer.js +++ b/packages/strapi-admin/admin/src/components/Roles/Permissions/reducer.js @@ -448,7 +448,7 @@ const reducer = (state, action) => } case 'ON_GLOBAL_PUBLISH_ACTION_SELECT': { const contentTypesWithPublishAction = action.contentTypes - .filter(contentType => contentType.schema.options.draftAndPublish === true) + .filter(contentType => contentType.options.draftAndPublish === true) .map(contentType => contentType.uid); contentTypesWithPublishAction.forEach(contentTypeUID => { diff --git a/packages/strapi-admin/admin/src/components/Roles/Permissions/utils/tests/data.js b/packages/strapi-admin/admin/src/components/Roles/Permissions/utils/tests/data.js index 4f3fd14dd4..a346ce821f 100644 --- a/packages/strapi-admin/admin/src/components/Roles/Permissions/utils/tests/data.js +++ b/packages/strapi-admin/admin/src/components/Roles/Permissions/utils/tests/data.js @@ -56,39 +56,33 @@ export const permissions = { export const contentTypes = [ { uid: 'application::address.address', - schema: { - options: { - timestamps: ['updated_at', 'created_at'], - }, - modelType: 'contentType', - attributes: { - id: { type: 'integer' }, - city: { type: 'string', required: false }, - cover: { type: 'media', multiple: false, required: false }, - closing_period: { - component: 'default.closingperiod', - type: 'component', - }, - label: { type: 'string' }, - updated_at: { type: 'timestamp' }, + options: { + timestamps: ['updated_at', 'created_at'], + }, + attributes: { + id: { type: 'integer' }, + city: { type: 'string', required: false }, + cover: { type: 'media', multiple: false, required: false }, + closing_period: { + component: 'default.closingperiod', + type: 'component', }, + label: { type: 'string' }, + updated_at: { type: 'timestamp' }, }, }, { uid: 'application::places.places', - schema: { - options: { - timestamps: ['updated_at', 'created_at'], - }, - modelType: 'contentType', - attributes: { - id: { type: 'integer' }, - like: { type: 'string', required: false }, - country: { type: 'string', required: false }, - image: { type: 'media', multiple: false, required: false }, - custom_label: { type: 'string' }, - updated_at: { type: 'timestamp' }, - }, + options: { + timestamps: ['updated_at', 'created_at'], + }, + attributes: { + id: { type: 'integer' }, + like: { type: 'string', required: false }, + country: { type: 'string', required: false }, + image: { type: 'media', multiple: false, required: false }, + custom_label: { type: 'string' }, + updated_at: { type: 'timestamp' }, }, }, ]; @@ -96,36 +90,30 @@ export const contentTypes = [ export const components = [ { uid: 'default.closingperiod', - schema: { - attributes: { - id: { type: 'integer' }, - start_date: { type: 'date', required: true }, - dish: { - component: 'default.dish', - type: 'component', - }, - media: { type: 'media', multiple: false, required: false }, + attributes: { + id: { type: 'integer' }, + start_date: { type: 'date', required: true }, + dish: { + component: 'default.dish', + type: 'component', }, + media: { type: 'media', multiple: false, required: false }, }, }, { uid: 'default.dish', - schema: { - attributes: { - description: { type: 'text' }, - id: { type: 'integer' }, - name: { type: 'string', required: true, default: 'My super dish' }, - }, + attributes: { + description: { type: 'text' }, + id: { type: 'integer' }, + name: { type: 'string', required: true, default: 'My super dish' }, }, }, { uid: 'default.restaurantservice', - schema: { - attributes: { - is_available: { type: 'boolean', required: true, default: true }, - id: { type: 'integer' }, - name: { type: 'string', required: true, default: 'something' }, - }, + attributes: { + is_available: { type: 'boolean', required: true, default: true }, + id: { type: 'integer' }, + name: { type: 'string', required: true, default: 'something' }, }, }, ]; diff --git a/packages/strapi-admin/admin/src/containers/Webhooks/EditView/index.js b/packages/strapi-admin/admin/src/containers/Webhooks/EditView/index.js index 335ab3dba2..2f7bc0bcd1 100644 --- a/packages/strapi-admin/admin/src/containers/Webhooks/EditView/index.js +++ b/packages/strapi-admin/admin/src/containers/Webhooks/EditView/index.js @@ -363,7 +363,7 @@ function EditView() { }; const shouldShowDPEvents = useMemo( - () => collectionTypes.some(ct => ct.schema.options.draftAndPublish === true), + () => collectionTypes.some(ct => ct.options.draftAndPublish === true), [collectionTypes] ); diff --git a/packages/strapi-admin/admin/src/utils/getAttributesToDisplay.js b/packages/strapi-admin/admin/src/utils/getAttributesToDisplay.js index 9d5f014100..94d2c5358c 100644 --- a/packages/strapi-admin/admin/src/utils/getAttributesToDisplay.js +++ b/packages/strapi-admin/admin/src/utils/getAttributesToDisplay.js @@ -1,13 +1,13 @@ import { get } from 'lodash'; const getAttributesToDisplay = contentType => { - const timestamps = get(contentType, ['schema', 'options', 'timestamps']); + const timestamps = get(contentType, ['options', 'timestamps']); // Sometimes timestamps is false let timestampsArray = Array.isArray(timestamps) ? timestamps : []; const idsAttributes = ['id', '_id']; // For both SQL and mongo const unwritableAttributes = [...idsAttributes, ...timestampsArray, 'published_at']; - const schemaAttributes = get(contentType, ['schema', 'attributes'], {}); + const schemaAttributes = get(contentType, ['attributes'], {}); return Object.keys(schemaAttributes).reduce((acc, current) => { if (!unwritableAttributes.includes(current)) { diff --git a/packages/strapi-admin/admin/src/utils/tests/getAttributesToDisplay.test.js b/packages/strapi-admin/admin/src/utils/tests/getAttributesToDisplay.test.js index 76f4c7974e..a88dfd36c6 100644 --- a/packages/strapi-admin/admin/src/utils/tests/getAttributesToDisplay.test.js +++ b/packages/strapi-admin/admin/src/utils/tests/getAttributesToDisplay.test.js @@ -3,18 +3,16 @@ import { getAttributesToDisplay } from '../index'; describe('ADMIN | utils | getAttributesToDisplay', () => { it('should return attributes without id and timestamps', () => { const contentType = { - schema: { - attributes: { - id: { type: 'number' }, - title: { type: 'string' }, - description: { type: 'string' }, - created_at: { type: 'timestamp' }, - updated_at: { type: 'timestamp' }, - published_at: { type: 'timestamp' }, - }, - options: { - timestamps: ['created_at', 'updated_at'], - }, + attributes: { + id: { type: 'number' }, + title: { type: 'string' }, + description: { type: 'string' }, + created_at: { type: 'timestamp' }, + updated_at: { type: 'timestamp' }, + published_at: { type: 'timestamp' }, + }, + options: { + timestamps: ['created_at', 'updated_at'], }, }; const actual = getAttributesToDisplay(contentType); diff --git a/packages/strapi-admin/ee/admin/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js b/packages/strapi-admin/ee/admin/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js index 0896828366..f35e3906f6 100644 --- a/packages/strapi-admin/ee/admin/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js +++ b/packages/strapi-admin/ee/admin/components/Roles/Permissions/ContentTypes/ContentTypesRow/index.js @@ -210,7 +210,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { 0 && @@ -220,7 +220,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { value={allCurrentActionsSize === allActionsSize} /> { lineHeight="20px" textTransform="uppercase" > - {contentType.name} + {contentType.info.name} @@ -246,7 +246,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { hasConditions={checkConditions(permissionLayout.action)} disabled={isSuperAdmin} value={hasContentTypeAction(permissionLayout.action)} - name={`${contentType.name}-${permissionLayout.action}`} + name={`${contentType.info.name}-${permissionLayout.action}`} onChange={() => handleContentTypeActionSelect(permissionLayout.action)} /> ) : ( @@ -256,7 +256,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => { disabled={isSuperAdmin} value={hasContentTypeAction(permissionLayout.action)} someChecked={hasSomeAttributeByAction(permissionLayout.action)} - name={`${contentType.name}-${permissionLayout.action}`} + name={`${contentType.info.name}-${permissionLayout.action}`} onChange={() => handleActionSelect(permissionLayout.action)} /> )