mirror of
https://github.com/strapi/strapi.git
synced 2025-08-06 15:53:11 +00:00
Fix migration split ct & st
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
402b5db42b
commit
63f376e3fd
@ -180,7 +180,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
<PermissionName disabled>
|
||||
<Checkbox
|
||||
onChange={handleAllContentTypeActions}
|
||||
name={contentType.name}
|
||||
name={contentType.info.name}
|
||||
disabled={isSuperAdmin}
|
||||
someChecked={
|
||||
contentTypeActions.length > 0 &&
|
||||
@ -190,7 +190,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
value={allCurrentActionsSize === allActionsSize}
|
||||
/>
|
||||
<CollapseLabel
|
||||
title={contentType.name}
|
||||
title={contentType.info.name}
|
||||
alignItems="center"
|
||||
isCollapsable
|
||||
onClick={handleToggleAttributes}
|
||||
@ -203,7 +203,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
lineHeight="20px"
|
||||
textTransform="uppercase"
|
||||
>
|
||||
{contentType.name}
|
||||
{contentType.info.name}
|
||||
</Text>
|
||||
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
||||
</CollapseLabel>
|
||||
@ -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}`}
|
||||
/>
|
||||
) : (
|
||||
<PermissionCheckbox
|
||||
@ -225,7 +225,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
disabled
|
||||
value={hasContentTypeAction(permissionLayout.action)}
|
||||
someChecked={hasSomeAttributeByAction(permissionLayout.action)}
|
||||
name={`${contentType.name}-${permissionLayout.action}`}
|
||||
name={`${contentType.info.name}-${permissionLayout.action}`}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
|
@ -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 => {
|
||||
|
@ -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' },
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -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]
|
||||
);
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -210,7 +210,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
<PermissionName disabled={isSuperAdmin}>
|
||||
<Checkbox
|
||||
onChange={handleAllContentTypeActions}
|
||||
name={contentType.name}
|
||||
name={contentType.info.name}
|
||||
disabled={isSuperAdmin}
|
||||
someChecked={
|
||||
contentTypeActions.length > 0 &&
|
||||
@ -220,7 +220,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
value={allCurrentActionsSize === allActionsSize}
|
||||
/>
|
||||
<CollapseLabel
|
||||
title={contentType.name}
|
||||
title={contentType.info.name}
|
||||
alignItems="center"
|
||||
isCollapsable
|
||||
onClick={handleToggleAttributes}
|
||||
@ -233,7 +233,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
||||
lineHeight="20px"
|
||||
textTransform="uppercase"
|
||||
>
|
||||
{contentType.name}
|
||||
{contentType.info.name}
|
||||
</Text>
|
||||
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
||||
</CollapseLabel>
|
||||
@ -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)}
|
||||
/>
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user