From c29212aa2cbb06e3a90de7a6d986fee8ef3e0bcf Mon Sep 17 00:00:00 2001 From: soupette Date: Fri, 22 Nov 2019 10:15:34 +0100 Subject: [PATCH] Fix validations for allready taken attributes --- .../App/tests/__snapshots__/Loader.test.js.snap | 17 ----------------- .../admin/src/containers/FormModal/index.js | 15 +++++++++++---- 2 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/__snapshots__/Loader.test.js.snap diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/__snapshots__/Loader.test.js.snap b/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/__snapshots__/Loader.test.js.snap deleted file mode 100644 index 829555e417..0000000000 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/__snapshots__/Loader.test.js.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` should not crash 1`] = ` -
-
-
-
-
-
-
-`; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js index 1af9c0ac3a..853fa4ce96 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js @@ -122,18 +122,25 @@ const FormModal = () => { headerId = null; } + console.log({ allDataSchema }); + const checkFormValidity = async () => { let schema; if (state.modalType === 'contentType') { schema = forms[state.modalType].schema(Object.keys(contentTypes)); } else if ( - state.modalType === 'attribute' && - state.forTarget !== 'components' && - state.forTarget !== 'component' + state.modalType === 'attribute' + // && state.forTarget !== 'components' && + // state.forTarget !== 'component' ) { + const pathToSchemaAttributes = + state.forTarget === 'contentType' || state.forTarget === 'component' + ? [state.forTarget] + : [state.forTarget, state.targetUid]; + schema = forms[state.modalType].schema( - allDataSchema, + get(allDataSchema, pathToSchemaAttributes, {}), modifiedData.type, modifiedData );