mirror of
https://github.com/strapi/strapi.git
synced 2025-08-07 00:09:23 +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>
|
<PermissionName disabled>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
onChange={handleAllContentTypeActions}
|
onChange={handleAllContentTypeActions}
|
||||||
name={contentType.name}
|
name={contentType.info.name}
|
||||||
disabled={isSuperAdmin}
|
disabled={isSuperAdmin}
|
||||||
someChecked={
|
someChecked={
|
||||||
contentTypeActions.length > 0 &&
|
contentTypeActions.length > 0 &&
|
||||||
@ -190,7 +190,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
value={allCurrentActionsSize === allActionsSize}
|
value={allCurrentActionsSize === allActionsSize}
|
||||||
/>
|
/>
|
||||||
<CollapseLabel
|
<CollapseLabel
|
||||||
title={contentType.name}
|
title={contentType.info.name}
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
isCollapsable
|
isCollapsable
|
||||||
onClick={handleToggleAttributes}
|
onClick={handleToggleAttributes}
|
||||||
@ -203,7 +203,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
lineHeight="20px"
|
lineHeight="20px"
|
||||||
textTransform="uppercase"
|
textTransform="uppercase"
|
||||||
>
|
>
|
||||||
{contentType.name}
|
{contentType.info.name}
|
||||||
</Text>
|
</Text>
|
||||||
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
||||||
</CollapseLabel>
|
</CollapseLabel>
|
||||||
@ -216,7 +216,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
hasConditions={checkConditions(permissionLayout.action)}
|
hasConditions={checkConditions(permissionLayout.action)}
|
||||||
disabled
|
disabled
|
||||||
value={hasContentTypeAction(permissionLayout.action)}
|
value={hasContentTypeAction(permissionLayout.action)}
|
||||||
name={`${contentType.name}-${permissionLayout.action}`}
|
name={`${contentType.info.name}-${permissionLayout.action}`}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<PermissionCheckbox
|
<PermissionCheckbox
|
||||||
@ -225,7 +225,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
disabled
|
disabled
|
||||||
value={hasContentTypeAction(permissionLayout.action)}
|
value={hasContentTypeAction(permissionLayout.action)}
|
||||||
someChecked={hasSomeAttributeByAction(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': {
|
case 'ON_GLOBAL_PUBLISH_ACTION_SELECT': {
|
||||||
const contentTypesWithPublishAction = action.contentTypes
|
const contentTypesWithPublishAction = action.contentTypes
|
||||||
.filter(contentType => contentType.schema.options.draftAndPublish === true)
|
.filter(contentType => contentType.options.draftAndPublish === true)
|
||||||
.map(contentType => contentType.uid);
|
.map(contentType => contentType.uid);
|
||||||
|
|
||||||
contentTypesWithPublishAction.forEach(contentTypeUID => {
|
contentTypesWithPublishAction.forEach(contentTypeUID => {
|
||||||
|
@ -56,39 +56,33 @@ export const permissions = {
|
|||||||
export const contentTypes = [
|
export const contentTypes = [
|
||||||
{
|
{
|
||||||
uid: 'application::address.address',
|
uid: 'application::address.address',
|
||||||
schema: {
|
options: {
|
||||||
options: {
|
timestamps: ['updated_at', 'created_at'],
|
||||||
timestamps: ['updated_at', 'created_at'],
|
},
|
||||||
},
|
attributes: {
|
||||||
modelType: 'contentType',
|
id: { type: 'integer' },
|
||||||
attributes: {
|
city: { type: 'string', required: false },
|
||||||
id: { type: 'integer' },
|
cover: { type: 'media', multiple: false, required: false },
|
||||||
city: { type: 'string', required: false },
|
closing_period: {
|
||||||
cover: { type: 'media', multiple: false, required: false },
|
component: 'default.closingperiod',
|
||||||
closing_period: {
|
type: 'component',
|
||||||
component: 'default.closingperiod',
|
|
||||||
type: 'component',
|
|
||||||
},
|
|
||||||
label: { type: 'string' },
|
|
||||||
updated_at: { type: 'timestamp' },
|
|
||||||
},
|
},
|
||||||
|
label: { type: 'string' },
|
||||||
|
updated_at: { type: 'timestamp' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: 'application::places.places',
|
uid: 'application::places.places',
|
||||||
schema: {
|
options: {
|
||||||
options: {
|
timestamps: ['updated_at', 'created_at'],
|
||||||
timestamps: ['updated_at', 'created_at'],
|
},
|
||||||
},
|
attributes: {
|
||||||
modelType: 'contentType',
|
id: { type: 'integer' },
|
||||||
attributes: {
|
like: { type: 'string', required: false },
|
||||||
id: { type: 'integer' },
|
country: { type: 'string', required: false },
|
||||||
like: { type: 'string', required: false },
|
image: { type: 'media', multiple: false, required: false },
|
||||||
country: { type: 'string', required: false },
|
custom_label: { type: 'string' },
|
||||||
image: { type: 'media', multiple: false, required: false },
|
updated_at: { type: 'timestamp' },
|
||||||
custom_label: { type: 'string' },
|
|
||||||
updated_at: { type: 'timestamp' },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -96,36 +90,30 @@ export const contentTypes = [
|
|||||||
export const components = [
|
export const components = [
|
||||||
{
|
{
|
||||||
uid: 'default.closingperiod',
|
uid: 'default.closingperiod',
|
||||||
schema: {
|
attributes: {
|
||||||
attributes: {
|
id: { type: 'integer' },
|
||||||
id: { type: 'integer' },
|
start_date: { type: 'date', required: true },
|
||||||
start_date: { type: 'date', required: true },
|
dish: {
|
||||||
dish: {
|
component: 'default.dish',
|
||||||
component: 'default.dish',
|
type: 'component',
|
||||||
type: 'component',
|
|
||||||
},
|
|
||||||
media: { type: 'media', multiple: false, required: false },
|
|
||||||
},
|
},
|
||||||
|
media: { type: 'media', multiple: false, required: false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: 'default.dish',
|
uid: 'default.dish',
|
||||||
schema: {
|
attributes: {
|
||||||
attributes: {
|
description: { type: 'text' },
|
||||||
description: { type: 'text' },
|
id: { type: 'integer' },
|
||||||
id: { type: 'integer' },
|
name: { type: 'string', required: true, default: 'My super dish' },
|
||||||
name: { type: 'string', required: true, default: 'My super dish' },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: 'default.restaurantservice',
|
uid: 'default.restaurantservice',
|
||||||
schema: {
|
attributes: {
|
||||||
attributes: {
|
is_available: { type: 'boolean', required: true, default: true },
|
||||||
is_available: { type: 'boolean', required: true, default: true },
|
id: { type: 'integer' },
|
||||||
id: { type: 'integer' },
|
name: { type: 'string', required: true, default: 'something' },
|
||||||
name: { type: 'string', required: true, default: 'something' },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -363,7 +363,7 @@ function EditView() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const shouldShowDPEvents = useMemo(
|
const shouldShowDPEvents = useMemo(
|
||||||
() => collectionTypes.some(ct => ct.schema.options.draftAndPublish === true),
|
() => collectionTypes.some(ct => ct.options.draftAndPublish === true),
|
||||||
[collectionTypes]
|
[collectionTypes]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
|
|
||||||
const getAttributesToDisplay = contentType => {
|
const getAttributesToDisplay = contentType => {
|
||||||
const timestamps = get(contentType, ['schema', 'options', 'timestamps']);
|
const timestamps = get(contentType, ['options', 'timestamps']);
|
||||||
|
|
||||||
// Sometimes timestamps is false
|
// Sometimes timestamps is false
|
||||||
let timestampsArray = Array.isArray(timestamps) ? timestamps : [];
|
let timestampsArray = Array.isArray(timestamps) ? timestamps : [];
|
||||||
const idsAttributes = ['id', '_id']; // For both SQL and mongo
|
const idsAttributes = ['id', '_id']; // For both SQL and mongo
|
||||||
const unwritableAttributes = [...idsAttributes, ...timestampsArray, 'published_at'];
|
const unwritableAttributes = [...idsAttributes, ...timestampsArray, 'published_at'];
|
||||||
const schemaAttributes = get(contentType, ['schema', 'attributes'], {});
|
const schemaAttributes = get(contentType, ['attributes'], {});
|
||||||
|
|
||||||
return Object.keys(schemaAttributes).reduce((acc, current) => {
|
return Object.keys(schemaAttributes).reduce((acc, current) => {
|
||||||
if (!unwritableAttributes.includes(current)) {
|
if (!unwritableAttributes.includes(current)) {
|
||||||
|
@ -3,18 +3,16 @@ import { getAttributesToDisplay } from '../index';
|
|||||||
describe('ADMIN | utils | getAttributesToDisplay', () => {
|
describe('ADMIN | utils | getAttributesToDisplay', () => {
|
||||||
it('should return attributes without id and timestamps', () => {
|
it('should return attributes without id and timestamps', () => {
|
||||||
const contentType = {
|
const contentType = {
|
||||||
schema: {
|
attributes: {
|
||||||
attributes: {
|
id: { type: 'number' },
|
||||||
id: { type: 'number' },
|
title: { type: 'string' },
|
||||||
title: { type: 'string' },
|
description: { type: 'string' },
|
||||||
description: { type: 'string' },
|
created_at: { type: 'timestamp' },
|
||||||
created_at: { type: 'timestamp' },
|
updated_at: { type: 'timestamp' },
|
||||||
updated_at: { type: 'timestamp' },
|
published_at: { type: 'timestamp' },
|
||||||
published_at: { type: 'timestamp' },
|
},
|
||||||
},
|
options: {
|
||||||
options: {
|
timestamps: ['created_at', 'updated_at'],
|
||||||
timestamps: ['created_at', 'updated_at'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const actual = getAttributesToDisplay(contentType);
|
const actual = getAttributesToDisplay(contentType);
|
||||||
|
@ -210,7 +210,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
<PermissionName disabled={isSuperAdmin}>
|
<PermissionName disabled={isSuperAdmin}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
onChange={handleAllContentTypeActions}
|
onChange={handleAllContentTypeActions}
|
||||||
name={contentType.name}
|
name={contentType.info.name}
|
||||||
disabled={isSuperAdmin}
|
disabled={isSuperAdmin}
|
||||||
someChecked={
|
someChecked={
|
||||||
contentTypeActions.length > 0 &&
|
contentTypeActions.length > 0 &&
|
||||||
@ -220,7 +220,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
value={allCurrentActionsSize === allActionsSize}
|
value={allCurrentActionsSize === allActionsSize}
|
||||||
/>
|
/>
|
||||||
<CollapseLabel
|
<CollapseLabel
|
||||||
title={contentType.name}
|
title={contentType.info.name}
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
isCollapsable
|
isCollapsable
|
||||||
onClick={handleToggleAttributes}
|
onClick={handleToggleAttributes}
|
||||||
@ -233,7 +233,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
lineHeight="20px"
|
lineHeight="20px"
|
||||||
textTransform="uppercase"
|
textTransform="uppercase"
|
||||||
>
|
>
|
||||||
{contentType.name}
|
{contentType.info.name}
|
||||||
</Text>
|
</Text>
|
||||||
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
||||||
</CollapseLabel>
|
</CollapseLabel>
|
||||||
@ -246,7 +246,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
hasConditions={checkConditions(permissionLayout.action)}
|
hasConditions={checkConditions(permissionLayout.action)}
|
||||||
disabled={isSuperAdmin}
|
disabled={isSuperAdmin}
|
||||||
value={hasContentTypeAction(permissionLayout.action)}
|
value={hasContentTypeAction(permissionLayout.action)}
|
||||||
name={`${contentType.name}-${permissionLayout.action}`}
|
name={`${contentType.info.name}-${permissionLayout.action}`}
|
||||||
onChange={() => handleContentTypeActionSelect(permissionLayout.action)}
|
onChange={() => handleContentTypeActionSelect(permissionLayout.action)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@ -256,7 +256,7 @@ const ContentTypeRow = ({ index, contentType, permissionsLayout }) => {
|
|||||||
disabled={isSuperAdmin}
|
disabled={isSuperAdmin}
|
||||||
value={hasContentTypeAction(permissionLayout.action)}
|
value={hasContentTypeAction(permissionLayout.action)}
|
||||||
someChecked={hasSomeAttributeByAction(permissionLayout.action)}
|
someChecked={hasSomeAttributeByAction(permissionLayout.action)}
|
||||||
name={`${contentType.name}-${permissionLayout.action}`}
|
name={`${contentType.info.name}-${permissionLayout.action}`}
|
||||||
onChange={() => handleActionSelect(permissionLayout.action)}
|
onChange={() => handleActionSelect(permissionLayout.action)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user