mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 09:00:19 +00:00
handle toggle i18n on CT and fields
This commit is contained in:
parent
2b342ec69d
commit
22d38b5ffc
@ -16,6 +16,7 @@ const createSchema = (types, relations, { modelType } = {}) => {
|
||||
.required('name.required'),
|
||||
description: yup.string(),
|
||||
draftAndPublish: yup.boolean(),
|
||||
pluginOptions: yup.object(),
|
||||
connection: yup.string(),
|
||||
collectionName: yup
|
||||
.string()
|
||||
@ -45,16 +46,13 @@ const createAttributesValidator = ({ types, modelType, relations }) => {
|
||||
}
|
||||
|
||||
if (_.has(attribute, 'type')) {
|
||||
return getTypeValidator(attribute, { types, modelType, attributes })
|
||||
.test(isValidKey(key))
|
||||
.noUnknown();
|
||||
return getTypeValidator(attribute, { types, modelType, attributes }).test(
|
||||
isValidKey(key)
|
||||
);
|
||||
}
|
||||
|
||||
if (_.has(attribute, 'target')) {
|
||||
return yup
|
||||
.object(getRelationValidator(attribute, relations))
|
||||
.test(isValidKey(key))
|
||||
.noUnknown();
|
||||
return yup.object(getRelationValidator(attribute, relations)).test(isValidKey(key));
|
||||
}
|
||||
|
||||
return typeOrRelationValidator;
|
||||
|
@ -51,5 +51,6 @@ module.exports = (obj, validNatures) => {
|
||||
.nullable(),
|
||||
targetColumnName: yup.string().nullable(),
|
||||
private: yup.boolean().nullable(),
|
||||
pluginOptions: yup.object(),
|
||||
};
|
||||
};
|
||||
|
@ -36,6 +36,7 @@ const getTypeValidator = (attribute, { types, modelType, attributes }) => {
|
||||
.required(),
|
||||
configurable: yup.boolean().nullable(),
|
||||
private: yup.boolean().nullable(),
|
||||
pluginOptions: yup.object(),
|
||||
...getTypeShape(attribute, { modelType, attributes }),
|
||||
});
|
||||
};
|
||||
|
@ -24,6 +24,7 @@ const formatComponent = component => {
|
||||
description: _.get(info, 'description', ''),
|
||||
connection,
|
||||
collectionName,
|
||||
pluginOptions: component.pluginOptions,
|
||||
attributes: formatAttributes(component),
|
||||
},
|
||||
};
|
||||
|
@ -49,6 +49,7 @@ const formatContentType = contentType => {
|
||||
name: getformattedName(contentType),
|
||||
description: _.get(info, 'description', ''),
|
||||
draftAndPublish: contentTypesUtils.hasDraftAndPublish({ options }),
|
||||
pluginOptions: contentType.pluginOptions,
|
||||
connection,
|
||||
kind: kind || 'collectionType',
|
||||
collectionName,
|
||||
|
@ -16,6 +16,11 @@ Object {
|
||||
"draftAndPublish": false,
|
||||
"kind": "singleType",
|
||||
"name": "My name",
|
||||
"pluginOptions": Object {
|
||||
"content-manager": Object {
|
||||
"visible": true,
|
||||
},
|
||||
},
|
||||
"restrictRelationsTo": null,
|
||||
"visible": true,
|
||||
},
|
||||
|
@ -18,6 +18,11 @@ describe('Content types service', () => {
|
||||
options: {
|
||||
draftAndPublish: false,
|
||||
},
|
||||
pluginOptions: {
|
||||
'content-manager': {
|
||||
visible: true,
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
|
@ -52,6 +52,7 @@ module.exports = function createComponentBuilder() {
|
||||
.set(['info', 'name'], infos.name)
|
||||
.set(['info', 'icon'], infos.icon)
|
||||
.set(['info', 'description'], infos.description)
|
||||
.set('pluginOptions', infos.pluginOptions)
|
||||
.setAttributes(this.convertAttributes(infos.attributes));
|
||||
|
||||
if (this.components.size === 0) {
|
||||
@ -101,6 +102,7 @@ module.exports = function createComponentBuilder() {
|
||||
.set(['info', 'name'], infos.name)
|
||||
.set(['info', 'icon'], infos.icon)
|
||||
.set(['info', 'description'], infos.description)
|
||||
.set('pluginOptions', infos.pluginOptions)
|
||||
.setAttributes(this.convertAttributes(newAttributes));
|
||||
|
||||
if (newUID !== uid) {
|
||||
|
@ -86,6 +86,7 @@ module.exports = function createComponentBuilder() {
|
||||
timestamps: true,
|
||||
draftAndPublish: infos.draftAndPublish || false,
|
||||
})
|
||||
.set('pluginOptions', infos.pluginOptions)
|
||||
.setAttributes(this.convertAttributes(infos.attributes));
|
||||
|
||||
Object.keys(infos.attributes).forEach(key => {
|
||||
@ -188,6 +189,7 @@ module.exports = function createComponentBuilder() {
|
||||
.set(['info', 'name'], infos.name)
|
||||
.set(['info', 'description'], infos.description)
|
||||
.set(['options', 'draftAndPublish'], infos.draftAndPublish || false)
|
||||
.set('pluginOptions', infos.pluginOptions)
|
||||
.setAttributes(this.convertAttributes(newAttributes));
|
||||
|
||||
return contentType;
|
||||
|
@ -52,9 +52,19 @@ describe('Content Type Builder - Components', () => {
|
||||
category: 'default',
|
||||
icon: 'default',
|
||||
name: 'Some Component',
|
||||
pluginOptions: {
|
||||
pluginName: {
|
||||
option: true,
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
pluginOptions: {
|
||||
pluginName: {
|
||||
option: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
pic: {
|
||||
type: 'media',
|
||||
@ -152,9 +162,19 @@ describe('Content Type Builder - Components', () => {
|
||||
description: '',
|
||||
connection: 'default',
|
||||
collectionName: 'components_default_some_components',
|
||||
pluginOptions: {
|
||||
pluginName: {
|
||||
option: true,
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
pluginOptions: {
|
||||
pluginName: {
|
||||
option: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
pic: {
|
||||
type: 'media',
|
||||
@ -212,6 +232,11 @@ describe('Content Type Builder - Components', () => {
|
||||
icon: 'default',
|
||||
name: 'New Component',
|
||||
attributes: {},
|
||||
pluginOptions: {
|
||||
pluginName: {
|
||||
option: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -236,6 +261,11 @@ describe('Content Type Builder - Components', () => {
|
||||
uid: 'default.some-component',
|
||||
schema: {
|
||||
name: 'New Component',
|
||||
pluginOptions: {
|
||||
pluginName: {
|
||||
option: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -51,9 +51,19 @@ describe('Content Type Builder - Content types', () => {
|
||||
body: {
|
||||
contentType: {
|
||||
name: 'Test Collection Type',
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -125,9 +135,19 @@ describe('Content Type Builder - Content types', () => {
|
||||
contentType: {
|
||||
kind: 'singleType',
|
||||
name: 'Test Single Type',
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -317,6 +317,11 @@ Object {
|
||||
"schema": Object {
|
||||
"attributes": Object {
|
||||
"title": Object {
|
||||
"pluginOptions": Object {
|
||||
"i18n": Object {
|
||||
"localized": true,
|
||||
},
|
||||
},
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
@ -326,6 +331,11 @@ Object {
|
||||
"draftAndPublish": false,
|
||||
"kind": "collectionType",
|
||||
"name": "Test Collection Type",
|
||||
"pluginOptions": Object {
|
||||
"i18n": Object {
|
||||
"localized": true,
|
||||
},
|
||||
},
|
||||
"restrictRelationsTo": null,
|
||||
"visible": true,
|
||||
},
|
||||
@ -365,6 +375,11 @@ Object {
|
||||
"schema": Object {
|
||||
"attributes": Object {
|
||||
"title": Object {
|
||||
"pluginOptions": Object {
|
||||
"i18n": Object {
|
||||
"localized": true,
|
||||
},
|
||||
},
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
@ -374,6 +389,11 @@ Object {
|
||||
"draftAndPublish": false,
|
||||
"kind": "singleType",
|
||||
"name": "Test Single Type",
|
||||
"pluginOptions": Object {
|
||||
"i18n": Object {
|
||||
"localized": true,
|
||||
},
|
||||
},
|
||||
"restrictRelationsTo": null,
|
||||
"visible": true,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user