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 {
await apiHandler.clear(uid);
// generate new api squeleton
// generate new api skeleton
await generateAPI({
name: updatedContentType.schema.info.name,
kind: updatedContentType.schema.kind,

View File

@ -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 {

View File

@ -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);