diff --git a/packages/strapi-plugin-content-type-builder/services/ContentTypes.js b/packages/strapi-plugin-content-type-builder/services/ContentTypes.js index f231cbde9b..e0399e0969 100644 --- a/packages/strapi-plugin-content-type-builder/services/ContentTypes.js +++ b/packages/strapi-plugin-content-type-builder/services/ContentTypes.js @@ -174,7 +174,7 @@ const editContentType = async (uid, { contentType, components = [] }) => { try { await apiHandler.clear(uid); - // generate new api squeleton + // generate new api skeleton await generateAPI({ name: updatedContentType.schema.info.name, kind: updatedContentType.schema.kind, diff --git a/packages/strapi-plugin-content-type-builder/services/schema-builder/index.js b/packages/strapi-plugin-content-type-builder/services/schema-builder/index.js index 8dc84312fe..868443979a 100644 --- a/packages/strapi-plugin-content-type-builder/services/schema-builder/index.js +++ b/packages/strapi-plugin-content-type-builder/services/schema-builder/index.js @@ -93,7 +93,7 @@ function createSchemaBuilder({ components, contentTypes }) { via, allowedTypes: attribute.allowedTypes, plugin: 'upload', - required: attribute.required ? true : false, + required: !!attribute.required, configurable: configurable === false ? false : undefined, }; } else { diff --git a/packages/strapi-plugin-content-type-builder/services/schema-builder/schema-handler.js b/packages/strapi-plugin-content-type-builder/services/schema-builder/schema-handler.js index 1a12cc9a71..c669a6f25a 100644 --- a/packages/strapi-plugin-content-type-builder/services/schema-builder/schema-handler.js +++ b/packages/strapi-plugin-content-type-builder/services/schema-builder/schema-handler.js @@ -51,6 +51,10 @@ module.exports = function createSchemaHandler(infos) { return state.uid; }, + get writable() { + return _.get(state, 'plugin') !== 'admin'; + }, + setUID(val) { modified = true; @@ -201,6 +205,10 @@ module.exports = function createSchemaHandler(infos) { // save the schema to disk async flush() { + if (!this.writable) { + return; + } + const initialPath = path.join(initialState.dir, initialState.filename); const filePath = path.join(state.dir, state.filename); @@ -244,6 +252,10 @@ module.exports = function createSchemaHandler(infos) { // reset the schema to its initial value async rollback() { + if (!this.writable) { + return; + } + const initialPath = path.join(initialState.dir, initialState.filename); const filePath = path.join(state.dir, state.filename);