Fix unwanted extension folder creation for admin schemas

Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu>
This commit is contained in:
Convly 2020-09-22 10:47:43 +02:00 committed by Pierre Noël
parent a5cd2fe6d1
commit d1b543f5cf
3 changed files with 14 additions and 2 deletions

View File

@ -174,7 +174,7 @@ const editContentType = async (uid, { contentType, components = [] }) => {
try { try {
await apiHandler.clear(uid); await apiHandler.clear(uid);
// generate new api squeleton // generate new api skeleton
await generateAPI({ await generateAPI({
name: updatedContentType.schema.info.name, name: updatedContentType.schema.info.name,
kind: updatedContentType.schema.kind, kind: updatedContentType.schema.kind,

View File

@ -93,7 +93,7 @@ function createSchemaBuilder({ components, contentTypes }) {
via, via,
allowedTypes: attribute.allowedTypes, allowedTypes: attribute.allowedTypes,
plugin: 'upload', plugin: 'upload',
required: attribute.required ? true : false, required: !!attribute.required,
configurable: configurable === false ? false : undefined, configurable: configurable === false ? false : undefined,
}; };
} else { } else {

View File

@ -51,6 +51,10 @@ module.exports = function createSchemaHandler(infos) {
return state.uid; return state.uid;
}, },
get writable() {
return _.get(state, 'plugin') !== 'admin';
},
setUID(val) { setUID(val) {
modified = true; modified = true;
@ -201,6 +205,10 @@ module.exports = function createSchemaHandler(infos) {
// save the schema to disk // save the schema to disk
async flush() { async flush() {
if (!this.writable) {
return;
}
const initialPath = path.join(initialState.dir, initialState.filename); const initialPath = path.join(initialState.dir, initialState.filename);
const filePath = path.join(state.dir, state.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 // reset the schema to its initial value
async rollback() { async rollback() {
if (!this.writable) {
return;
}
const initialPath = path.join(initialState.dir, initialState.filename); const initialPath = path.join(initialState.dir, initialState.filename);
const filePath = path.join(state.dir, state.filename); const filePath = path.join(state.dir, state.filename);