mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Respect alphabetical order
This commit is contained in:
parent
b6bbd3e534
commit
5e8cb0f63b
@ -40,34 +40,6 @@ const reducer = (state = initialState, action) =>
|
||||
// eslint-disable-next-line consistent-return
|
||||
produce(state, (draftState) => {
|
||||
switch (action.type) {
|
||||
case actions.ADD_CUSTOM_FIELD_ATTRIBUTE: {
|
||||
const {
|
||||
attributeToSet: { name, ...rest },
|
||||
forTarget,
|
||||
targetUid,
|
||||
} = action;
|
||||
|
||||
const pathToDataToEdit = ['component', 'contentType'].includes(forTarget)
|
||||
? [forTarget]
|
||||
: [forTarget, targetUid];
|
||||
|
||||
const currentAttributes = get(
|
||||
state,
|
||||
['modifiedData', ...pathToDataToEdit, 'schema', 'attributes'],
|
||||
[]
|
||||
).slice();
|
||||
|
||||
// Add the createdAttribute
|
||||
const updatedAttributes = [...currentAttributes, { ...rest, name }];
|
||||
|
||||
set(
|
||||
draftState,
|
||||
['modifiedData', ...pathToDataToEdit, 'schema', 'attributes'],
|
||||
updatedAttributes
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.ADD_ATTRIBUTE: {
|
||||
const {
|
||||
attributeToSet: { name, ...rest },
|
||||
@ -189,6 +161,34 @@ const reducer = (state = initialState, action) =>
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.ADD_CUSTOM_FIELD_ATTRIBUTE: {
|
||||
const {
|
||||
attributeToSet: { name, ...rest },
|
||||
forTarget,
|
||||
targetUid,
|
||||
} = action;
|
||||
|
||||
const pathToDataToEdit = ['component', 'contentType'].includes(forTarget)
|
||||
? [forTarget]
|
||||
: [forTarget, targetUid];
|
||||
|
||||
const currentAttributes = get(
|
||||
state,
|
||||
['modifiedData', ...pathToDataToEdit, 'schema', 'attributes'],
|
||||
[]
|
||||
).slice();
|
||||
|
||||
// Add the createdAttribute
|
||||
const updatedAttributes = [...currentAttributes, { ...rest, name }];
|
||||
|
||||
set(
|
||||
draftState,
|
||||
['modifiedData', ...pathToDataToEdit, 'schema', 'attributes'],
|
||||
updatedAttributes
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.CHANGE_DYNAMIC_ZONE_COMPONENTS: {
|
||||
const { dynamicZoneTarget, newComponents } = action;
|
||||
|
||||
@ -261,27 +261,6 @@ const reducer = (state = initialState, action) =>
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.EDIT_CUSTOM_FIELD_ATTRIBUTE: {
|
||||
const { forTarget, targetUid, initialAttribute, attributeToSet } = action;
|
||||
|
||||
const initialAttributeName = initialAttribute.name;
|
||||
const pathToDataToEdit = ['component', 'contentType'].includes(forTarget)
|
||||
? [forTarget]
|
||||
: [forTarget, targetUid];
|
||||
|
||||
const initialAttributeIndex = findAttributeIndex(
|
||||
get(state, ['modifiedData', ...pathToDataToEdit]),
|
||||
initialAttributeName
|
||||
);
|
||||
|
||||
set(
|
||||
draftState,
|
||||
['modifiedData', ...pathToDataToEdit, 'schema', 'attributes', initialAttributeIndex],
|
||||
attributeToSet
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.EDIT_ATTRIBUTE: {
|
||||
const {
|
||||
attributeToSet: { name, ...rest },
|
||||
@ -462,6 +441,27 @@ const reducer = (state = initialState, action) =>
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.EDIT_CUSTOM_FIELD_ATTRIBUTE: {
|
||||
const { forTarget, targetUid, initialAttribute, attributeToSet } = action;
|
||||
|
||||
const initialAttributeName = initialAttribute.name;
|
||||
const pathToDataToEdit = ['component', 'contentType'].includes(forTarget)
|
||||
? [forTarget]
|
||||
: [forTarget, targetUid];
|
||||
|
||||
const initialAttributeIndex = findAttributeIndex(
|
||||
get(state, ['modifiedData', ...pathToDataToEdit]),
|
||||
initialAttributeName
|
||||
);
|
||||
|
||||
set(
|
||||
draftState,
|
||||
['modifiedData', ...pathToDataToEdit, 'schema', 'attributes', initialAttributeIndex],
|
||||
attributeToSet
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case actions.GET_DATA_SUCCEEDED: {
|
||||
draftState.components = action.components;
|
||||
draftState.initialComponents = action.components;
|
||||
|
Loading…
x
Reference in New Issue
Block a user