mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
Remove immutable CTB
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
24083dee44
commit
21e22313a4
@ -351,7 +351,6 @@ const DataManagerProvider = ({
|
||||
}
|
||||
};
|
||||
|
||||
// TODO
|
||||
const getAllComponentsThatHaveAComponentInTheirAttributes = () => {
|
||||
// We need to create an object with all the non modified compos
|
||||
// plus the ones that are created on the fly
|
||||
@ -370,7 +369,6 @@ const DataManagerProvider = ({
|
||||
return makeUnique(composWithCompos);
|
||||
};
|
||||
|
||||
// TODO
|
||||
const getAllNestedComponents = () => {
|
||||
const appNestedCompo = retrieveNestedComponents(components);
|
||||
const editingDataNestedCompos = retrieveNestedComponents(modifiedData.components || {});
|
||||
|
||||
@ -185,7 +185,6 @@ const reducer = (state = initialState, action) =>
|
||||
].components = updatedComponents;
|
||||
|
||||
// Retrieve all the components that needs to be added to the modifiedData.components
|
||||
// TODO check if it works
|
||||
const nestedComponents = retrieveComponentsFromSchema(
|
||||
current(draftState.modifiedData.contentType.schema.attributes),
|
||||
state.components
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { get, has, isEqual, omit, sortBy, camelCase } from 'lodash';
|
||||
import { get, isEqual, omit, sortBy, camelCase } from 'lodash';
|
||||
|
||||
import pluginId from '../../../pluginId';
|
||||
import makeUnique from '../../../utils/makeUnique';
|
||||
@ -18,7 +18,7 @@ const getCreatedAndModifiedComponents = (allComponents, initialComponents) => {
|
||||
|
||||
const formatComponent = (component, mainDataUID, isCreatingData = false) => {
|
||||
const formattedAttributes = formatAttributes(
|
||||
get(component, 'schema.attributes', {}),
|
||||
get(component, 'schema.attributes', []),
|
||||
mainDataUID,
|
||||
isCreatingData,
|
||||
true
|
||||
@ -48,7 +48,7 @@ const formatMainDataType = (data, isComponent = false) => {
|
||||
const mainDataUID = get(data, 'uid', null);
|
||||
|
||||
const formattedAttributes = formatAttributes(
|
||||
get(data, 'schema.attributes', {}),
|
||||
get(data, 'schema.attributes', []),
|
||||
mainDataUID,
|
||||
isCreatingData,
|
||||
false
|
||||
@ -75,10 +75,10 @@ const formatMainDataType = (data, isComponent = false) => {
|
||||
* @param {Boolean} isComponent
|
||||
*/
|
||||
const formatAttributes = (attributes, mainDataUID, isCreatingMainData, isComponent) => {
|
||||
return Object.keys(attributes).reduce((acc, current) => {
|
||||
const currentAttribute = get(attributes, current, {});
|
||||
return attributes.reduce((acc, { name, ...rest }) => {
|
||||
const currentAttribute = rest;
|
||||
const hasARelationWithMainDataUID = currentAttribute.target === mainDataUID;
|
||||
const isRelationType = has(currentAttribute, 'nature');
|
||||
const isRelationType = currentAttribute.type === 'relation';
|
||||
const currentTargetAttribute = get(currentAttribute, 'targetAttribute', null);
|
||||
|
||||
if (!hasARelationWithMainDataUID) {
|
||||
@ -87,12 +87,14 @@ const formatAttributes = (attributes, mainDataUID, isCreatingMainData, isCompone
|
||||
targetAttribute: formatRelationTargetAttribute(currentTargetAttribute),
|
||||
});
|
||||
|
||||
acc[current] = removeNullKeys(relationAttr);
|
||||
acc[name] = removeNullKeys(relationAttr);
|
||||
} else {
|
||||
acc[current] = removeNullKeys(currentAttribute);
|
||||
acc[name] = removeNullKeys(currentAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO check with @alexandrebodin if needed
|
||||
// Not sure this is needed
|
||||
if (hasARelationWithMainDataUID) {
|
||||
let target = currentAttribute.target;
|
||||
|
||||
@ -105,7 +107,7 @@ const formatAttributes = (attributes, mainDataUID, isCreatingMainData, isCompone
|
||||
targetAttribute: formatRelationTargetAttribute(currentTargetAttribute),
|
||||
});
|
||||
|
||||
acc[current] = removeNullKeys(formattedRelationAttribute);
|
||||
acc[name] = removeNullKeys(formattedRelationAttribute);
|
||||
}
|
||||
|
||||
return acc;
|
||||
|
||||
@ -9,24 +9,22 @@ const expectedData = {
|
||||
type: 'string',
|
||||
},
|
||||
address: {
|
||||
nature: 'oneWay',
|
||||
relation: 'oneToOne',
|
||||
target: 'application::address.address',
|
||||
unique: false,
|
||||
required: false,
|
||||
// targetAttribute: null,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentTypes: {
|
||||
nature: 'oneToMany',
|
||||
relation: 'oneToMany',
|
||||
targetAttribute: 'testContentType',
|
||||
target: '__self__',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'manyToOne',
|
||||
relation: 'manyToOne',
|
||||
target: '__self__',
|
||||
unique: false,
|
||||
required: false,
|
||||
targetAttribute: 'testContentTypes',
|
||||
type: 'relation',
|
||||
},
|
||||
mainCompoField: {
|
||||
type: 'component',
|
||||
@ -55,24 +53,21 @@ const expectedData = {
|
||||
type: 'string',
|
||||
},
|
||||
address: {
|
||||
nature: 'oneWay',
|
||||
relation: 'oneToOne',
|
||||
target: 'application::address.address',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentTypes: {
|
||||
nature: 'oneToMany',
|
||||
relation: 'oneToMany',
|
||||
targetAttribute: 'testContentType',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'manyToOne',
|
||||
relation: 'manyToOne',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
required: false,
|
||||
targetAttribute: 'testContentTypes',
|
||||
type: 'relation',
|
||||
},
|
||||
mainCompoField: {
|
||||
type: 'component',
|
||||
@ -146,10 +141,9 @@ const expectedData = {
|
||||
type: 'string',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'oneWay',
|
||||
relation: 'oneToOne',
|
||||
target: '__contentType__',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
subCompoField: {
|
||||
type: 'component',
|
||||
@ -185,9 +179,7 @@ const expectedData = {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
author: {
|
||||
model: 'user',
|
||||
},
|
||||
|
||||
link_to_biography: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
@ -206,10 +198,9 @@ const expectedData = {
|
||||
type: 'string',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'oneWay',
|
||||
relation: 'oneToOne',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
subCompoField: {
|
||||
type: 'component',
|
||||
@ -245,9 +236,6 @@ const expectedData = {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
author: {
|
||||
model: 'user',
|
||||
},
|
||||
link_to_biography: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
@ -266,10 +254,9 @@ const expectedData = {
|
||||
type: 'string',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'oneWay',
|
||||
relation: 'oneToOne',
|
||||
target: '__contentType__',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
subCompoField: {
|
||||
type: 'component',
|
||||
@ -305,9 +292,6 @@ const expectedData = {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
author: {
|
||||
model: 'user',
|
||||
},
|
||||
link_to_biography: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
@ -326,10 +310,9 @@ const expectedData = {
|
||||
type: 'string',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'oneWay',
|
||||
relation: 'oneToOne',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
subCompoField: {
|
||||
type: 'component',
|
||||
@ -365,9 +348,6 @@ const expectedData = {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
author: {
|
||||
model: 'user',
|
||||
},
|
||||
link_to_biography: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
|
||||
@ -9,18 +9,20 @@ const data = {
|
||||
description: '',
|
||||
connection: 'default',
|
||||
collectionName: 'components_metas',
|
||||
attributes: {
|
||||
meta: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'meta',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: 'title',
|
||||
},
|
||||
value: {
|
||||
{
|
||||
name: 'value',
|
||||
type: 'text',
|
||||
required: true,
|
||||
default: 'A title',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
'blog.quote': {
|
||||
@ -32,20 +34,19 @@ const data = {
|
||||
icon: 'anchor',
|
||||
connection: 'default',
|
||||
collectionName: 'components_quotes',
|
||||
attributes: {
|
||||
quote: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'quote',
|
||||
type: 'text',
|
||||
required: true,
|
||||
},
|
||||
author: {
|
||||
model: 'user',
|
||||
plugin: 'users-permissions',
|
||||
},
|
||||
link_to_biography: {
|
||||
|
||||
{
|
||||
name: 'link_to_biography',
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -58,26 +59,25 @@ const data = {
|
||||
schema: {
|
||||
name: 'mainCompo',
|
||||
icon: 'ad',
|
||||
attributes: {
|
||||
name: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
testContentType: {
|
||||
dominant: null,
|
||||
columnName: null,
|
||||
nature: 'oneWay',
|
||||
targetAttribute: '-',
|
||||
{
|
||||
name: 'testContentType',
|
||||
relation: 'oneToOne',
|
||||
targetAttribute: null,
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
targetColumnName: null,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
subCompoField: {
|
||||
{
|
||||
name: 'subCompoField',
|
||||
type: 'component',
|
||||
repeatable: false,
|
||||
component: 'default.nested-compo',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
'default.nested-compo': {
|
||||
@ -87,15 +87,17 @@ const data = {
|
||||
schema: {
|
||||
name: 'nestedCompo',
|
||||
icon: 'address-book',
|
||||
attributes: {
|
||||
name: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
email: {
|
||||
{
|
||||
name: 'email',
|
||||
type: 'email',
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
'default.metas': {
|
||||
@ -107,18 +109,20 @@ const data = {
|
||||
description: '',
|
||||
connection: 'default',
|
||||
collectionName: 'components_metas',
|
||||
attributes: {
|
||||
meta: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'meta',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: 'title',
|
||||
},
|
||||
value: {
|
||||
{
|
||||
name: 'value',
|
||||
type: 'text',
|
||||
required: true,
|
||||
default: 'A title',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
'blog.quote': {
|
||||
@ -130,20 +134,18 @@ const data = {
|
||||
icon: 'anchor',
|
||||
connection: 'default',
|
||||
collectionName: 'components_quotes',
|
||||
attributes: {
|
||||
quote: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'quote',
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
author: {
|
||||
model: 'user',
|
||||
plugin: 'users-permissions',
|
||||
},
|
||||
link_to_biography: {
|
||||
{
|
||||
name: 'link_to_biography',
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -185,10 +187,7 @@ const data = {
|
||||
},
|
||||
},
|
||||
},
|
||||
// TODO add test for component
|
||||
// componentToCreate: {
|
||||
|
||||
// },
|
||||
contentTypeToCreate: {
|
||||
uid: 'application::test-content-type.test-content-type',
|
||||
isTemporary: true,
|
||||
@ -197,56 +196,51 @@ const data = {
|
||||
collectionName: 'test-content-types',
|
||||
connection: 'default',
|
||||
description: '',
|
||||
attributes: {
|
||||
name: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
address: {
|
||||
dominant: null,
|
||||
columnName: null,
|
||||
nature: 'oneWay',
|
||||
targetAttribute: '-',
|
||||
{
|
||||
name: 'address',
|
||||
relation: 'oneToOne',
|
||||
targetAttribute: null,
|
||||
target: 'application::address.address',
|
||||
unique: false,
|
||||
targetColumnName: null,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentTypes: {
|
||||
dominant: null,
|
||||
columnName: null,
|
||||
nature: 'oneToMany',
|
||||
{
|
||||
name: 'testContentTypes',
|
||||
relation: 'oneToMany',
|
||||
targetAttribute: 'testContentType',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
targetColumnName: null,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'manyToOne',
|
||||
{
|
||||
name: 'testContentType',
|
||||
relation: 'manyToOne',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
required: false,
|
||||
dominant: null,
|
||||
targetAttribute: 'testContentTypes',
|
||||
columnName: null,
|
||||
targetColumnName: null,
|
||||
type: 'relation',
|
||||
},
|
||||
mainCompoField: {
|
||||
{
|
||||
name: 'mainCompoField',
|
||||
type: 'component',
|
||||
repeatable: false,
|
||||
component: 'components.main-compo',
|
||||
},
|
||||
existingCompo: {
|
||||
{
|
||||
name: 'existingCompo',
|
||||
type: 'component',
|
||||
repeatable: true,
|
||||
component: 'default.metas',
|
||||
},
|
||||
quote: {
|
||||
{
|
||||
name: 'quote',
|
||||
type: 'component',
|
||||
repeatable: false,
|
||||
component: 'blog.quote',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
contentTypeToEdit: {
|
||||
@ -256,56 +250,51 @@ const data = {
|
||||
collectionName: 'test-content-types',
|
||||
connection: 'default',
|
||||
description: '',
|
||||
attributes: {
|
||||
name: {
|
||||
attributes: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
address: {
|
||||
dominant: null,
|
||||
columnName: null,
|
||||
nature: 'oneWay',
|
||||
targetAttribute: '-',
|
||||
{
|
||||
name: 'address',
|
||||
relation: 'oneToOne',
|
||||
targetAttribute: null,
|
||||
target: 'application::address.address',
|
||||
unique: false,
|
||||
targetColumnName: null,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentTypes: {
|
||||
dominant: null,
|
||||
columnName: null,
|
||||
nature: 'oneToMany',
|
||||
{
|
||||
name: 'testContentTypes',
|
||||
relation: 'oneToMany',
|
||||
targetAttribute: 'testContentType',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
targetColumnName: null,
|
||||
required: false,
|
||||
type: 'relation',
|
||||
},
|
||||
testContentType: {
|
||||
nature: 'manyToOne',
|
||||
{
|
||||
name: 'testContentType',
|
||||
relation: 'manyToOne',
|
||||
target: 'application::test-content-type.test-content-type',
|
||||
unique: false,
|
||||
required: false,
|
||||
dominant: null,
|
||||
targetAttribute: 'testContentTypes',
|
||||
columnName: null,
|
||||
targetColumnName: null,
|
||||
type: 'relation',
|
||||
},
|
||||
mainCompoField: {
|
||||
{
|
||||
name: 'mainCompoField',
|
||||
type: 'component',
|
||||
repeatable: false,
|
||||
component: 'components.main-compo',
|
||||
},
|
||||
existingCompo: {
|
||||
{
|
||||
name: 'existingCompo',
|
||||
type: 'component',
|
||||
repeatable: true,
|
||||
component: 'default.metas',
|
||||
},
|
||||
quote: {
|
||||
{
|
||||
name: 'quote',
|
||||
type: 'component',
|
||||
repeatable: false,
|
||||
component: 'blog.quote',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
"@strapi/helper-plugin": "3.6.5",
|
||||
"@strapi/utils": "3.6.5",
|
||||
"fs-extra": "^9.1.0",
|
||||
"immutable": "^3.8.2",
|
||||
"lodash": "4.17.21",
|
||||
"pluralize": "^8.0.0",
|
||||
"react": "^16.14.0",
|
||||
@ -31,7 +30,6 @@
|
||||
"react-router-dom": "^5.0.0",
|
||||
"reactstrap": "8.4.1",
|
||||
"redux": "^4.0.1",
|
||||
"redux-immutable": "^4.0.0",
|
||||
"reselect": "^4.0.0",
|
||||
"yup": "^0.32.9"
|
||||
},
|
||||
|
||||
@ -19,9 +19,10 @@
|
||||
"@buffetjs/styles": "3.3.5",
|
||||
"@buffetjs/utils": "3.3.5",
|
||||
"@purest/providers": "^1.0.2",
|
||||
"@strapi/helper-plugin": "3.6.5",
|
||||
"@strapi/utils": "3.6.5",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"grant-koa": "5.4.8",
|
||||
"immutable": "^3.8.2",
|
||||
"jsonwebtoken": "^8.1.0",
|
||||
"koa2-ratelimit": "^0.9.0",
|
||||
"lodash": "4.17.21",
|
||||
@ -35,8 +36,6 @@
|
||||
"reactstrap": "8.4.1",
|
||||
"redux-saga": "^0.16.0",
|
||||
"request": "^2.83.0",
|
||||
"@strapi/helper-plugin": "3.6.5",
|
||||
"@strapi/utils": "3.6.5",
|
||||
"uuid": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user