@akemona-org/strapi-plugin-content-manager 3.7.0 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +2 -5
- package/admin/src/components/AddDropdown/index.js +5 -12
- package/admin/src/components/Block/index.js +2 -4
- package/admin/src/components/ComponentInitializer/index.js +1 -1
- package/admin/src/components/CustomTable/ActionCollapse/index.js +2 -2
- package/admin/src/components/CustomTable/Row/Cell.js +1 -1
- package/admin/src/components/CustomTable/Row/index.js +6 -6
- package/admin/src/components/CustomTable/index.js +5 -5
- package/admin/src/components/CustomTable/styledComponents.js +2 -2
- package/admin/src/components/DragLayer/index.js +1 -1
- package/admin/src/components/DraggedField/Wrapper.js +2 -7
- package/admin/src/components/DraggedField/index.js +3 -3
- package/admin/src/components/DraggedField/utils/getHeight.js +1 -1
- package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +2 -2
- package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +1 -2
- package/admin/src/components/DraggedFieldWithPreview/index.js +4 -4
- package/admin/src/components/DynamicComponentCard/index.js +2 -8
- package/admin/src/components/DynamicZone/Picker/index.js +3 -3
- package/admin/src/components/DynamicZone/index.js +4 -4
- package/admin/src/components/DynamicZone/utils/select.js +1 -1
- package/admin/src/components/FieldComponent/index.js +1 -1
- package/admin/src/components/FieldComponent/utils/select.js +6 -6
- package/admin/src/components/FieldsReorder/Item.js +6 -9
- package/admin/src/components/FieldsReorder/index.js +6 -17
- package/admin/src/components/FilterOptionsCTA/index.js +1 -1
- package/admin/src/components/FilterPicker/components.js +2 -2
- package/admin/src/components/FilterPicker/index.js +7 -7
- package/admin/src/components/FilterPicker/reducer.js +2 -2
- package/admin/src/components/FilterPickerOption/Input.js +1 -1
- package/admin/src/components/FilterPickerOption/Option.js +1 -3
- package/admin/src/components/FilterPickerOption/components.js +2 -2
- package/admin/src/components/FilterPickerOption/index.js +4 -4
- package/admin/src/components/FormTitle/index.js +1 -5
- package/admin/src/components/InputJSON/index.js +3 -3
- package/admin/src/components/InputJSON/jsonlint.js +639 -383
- package/admin/src/components/InputJSONWithErrors/index.js +2 -2
- package/admin/src/components/InputUID/Options/index.js +2 -2
- package/admin/src/components/InputUID/Options/wrapper.js +1 -1
- package/admin/src/components/InputUID/index.js +2 -2
- package/admin/src/components/Inputs/index.js +4 -4
- package/admin/src/components/Inputs/utils/generateOptions.js +2 -2
- package/admin/src/components/Inputs/utils/getStep.js +1 -1
- package/admin/src/components/MediaPreviewList/index.js +5 -5
- package/admin/src/components/NonRepeatableComponent/index.js +4 -4
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +1 -1
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +1 -1
- package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +3 -3
- package/admin/src/components/RelationPreviewList/index.js +1 -1
- package/admin/src/components/RepeatableComponent/Banner.js +2 -2
- package/admin/src/components/RepeatableComponent/BannerWrapper.js +1 -2
- package/admin/src/components/RepeatableComponent/DraggedItem/index.js +3 -9
- package/admin/src/components/RepeatableComponent/index.js +8 -8
- package/admin/src/components/RepeatableComponent/reducer.js +9 -9
- package/admin/src/components/Search/index.js +2 -2
- package/admin/src/components/SectionTitle/index.js +1 -3
- package/admin/src/components/SelectMany/ListItem.js +2 -2
- package/admin/src/components/SelectMany/index.js +3 -3
- package/admin/src/components/SelectOne/SingleValue.js +1 -1
- package/admin/src/components/SelectWrapper/ClearIndicator.js +1 -1
- package/admin/src/components/SelectWrapper/Option.js +1 -1
- package/admin/src/components/SelectWrapper/index.js +17 -27
- package/admin/src/components/SelectWrapper/utils/styles.js +6 -6
- package/admin/src/components/SettingsViewWrapper/index.js +9 -9
- package/admin/src/components/SortableList/Item.js +5 -11
- package/admin/src/components/Wysiwyg/MediaLib.js +1 -1
- package/admin/src/components/Wysiwyg/index.js +17 -25
- package/admin/src/components/Wysiwyg/toggleMode.js +3 -7
- package/admin/src/components/Wysiwyg/utils.js +2 -10
- package/admin/src/components/WysiwygDropUpload/index.js +1 -1
- package/admin/src/components/WysiwygInlineControls/Button.js +1 -1
- package/admin/src/components/WysiwygInlineControls/index.js +1 -1
- package/admin/src/components/WysiwygWithErrors/index.js +1 -1
- package/admin/src/containers/CollectionTypeFormWrapper/index.js +7 -12
- package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +1 -1
- package/admin/src/containers/CollectionTypeRecursivePath/index.js +1 -1
- package/admin/src/containers/ComponentSetttingsView/index.js +2 -2
- package/admin/src/containers/EditSettingsView/index.js +17 -17
- package/admin/src/containers/EditSettingsView/reducer.js +10 -10
- package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +2 -2
- package/admin/src/containers/EditSettingsView/utils/getInputProps.js +1 -1
- package/admin/src/containers/EditSettingsView/utils/layout.js +9 -9
- package/admin/src/containers/EditView/DeleteLink/index.js +1 -1
- package/admin/src/containers/EditView/Header/index.js +10 -9
- package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +3 -3
- package/admin/src/containers/EditView/index.js +7 -10
- package/admin/src/containers/EditView/utils/createAttributesLayout.js +4 -9
- package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +1 -1
- package/admin/src/containers/EditViewDataManagerProvider/index.js +7 -12
- package/admin/src/containers/EditViewDataManagerProvider/reducer.js +14 -14
- package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +4 -4
- package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +2 -8
- package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +12 -12
- package/admin/src/containers/EditViewLayoutManager/Permissions.js +1 -1
- package/admin/src/containers/EditViewLayoutManager/reducer.js +1 -1
- package/admin/src/containers/EditViewLayoutManager/selectors.js +1 -1
- package/admin/src/containers/ListSettingsView/Label.js +2 -11
- package/admin/src/containers/ListSettingsView/index.js +9 -9
- package/admin/src/containers/ListSettingsView/reducer.js +2 -2
- package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +1 -1
- package/admin/src/containers/ListView/FieldPicker/Fields/index.js +2 -2
- package/admin/src/containers/ListView/FieldPicker/index.js +2 -2
- package/admin/src/containers/ListView/Filter.js +1 -4
- package/admin/src/containers/ListView/actions.js +2 -2
- package/admin/src/containers/ListView/index.js +8 -7
- package/admin/src/containers/ListView/reducer.js +5 -5
- package/admin/src/containers/ListView/selectors.js +2 -2
- package/admin/src/containers/ListView/utils/createPluginsFilter.js +1 -1
- package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +1 -1
- package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +2 -2
- package/admin/src/containers/ListViewLayoutManager/Permissions.js +1 -1
- package/admin/src/containers/ListViewProvider/index.js +1 -3
- package/admin/src/containers/Main/index.js +2 -2
- package/admin/src/containers/Main/reducer.js +1 -1
- package/admin/src/containers/Main/selectors.js +2 -2
- package/admin/src/containers/RBACManager/reducer.js +1 -1
- package/admin/src/containers/SingleTypeFormWrapper/index.js +6 -11
- package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +1 -1
- package/admin/src/containers/WysiwygProvider/index.js +1 -3
- package/admin/src/hooks/useContentTypeLayout/index.js +1 -1
- package/admin/src/hooks/useFetchContentTypeLayout/index.js +3 -3
- package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +1 -1
- package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +8 -8
- package/admin/src/hooks/useFindRedirectionLink/index.js +1 -1
- package/admin/src/hooks/useFindRedirectionLink/selectors.js +1 -1
- package/admin/src/icons/Cross/index.js +1 -6
- package/admin/src/icons/Na/index.js +3 -22
- package/admin/src/index.js +1 -1
- package/admin/src/pluginId.js +1 -1
- package/admin/src/selectors.js +2 -2
- package/admin/src/sharedReducers/crudReducer/actions.js +3 -3
- package/admin/src/sharedReducers/crudReducer/reducer.js +1 -1
- package/admin/src/sharedReducers/crudReducer/selectors.js +1 -1
- package/admin/src/utils/checkIfAttributeIsDisplayable.js +1 -1
- package/admin/src/utils/formatFiltersFromQuery.js +2 -2
- package/admin/src/utils/formatLayoutToApi.js +2 -2
- package/admin/src/utils/generatePermissionsObject.js +3 -2
- package/admin/src/utils/getComponents.js +3 -5
- package/admin/src/utils/getFieldName.js +2 -2
- package/admin/src/utils/getMaxTempKey.js +2 -2
- package/admin/src/utils/getRequestUrl.js +1 -1
- package/admin/src/utils/getTrad.js +1 -1
- package/admin/src/utils/mergeMetasWithSchema.js +2 -2
- package/admin/src/utils/removeKeyInObject.js +1 -1
- package/admin/src/utils/removePasswordFieldsFromData.js +2 -2
- package/controllers/content-types.js +4 -4
- package/package.json +4 -4
- package/services/components.js +1 -1
- package/services/configuration.js +9 -9
- package/services/permission-checker.js +6 -6
- package/services/uid.js +1 -1
- package/services/utils/configuration/layouts.js +14 -35
- package/services/utils/configuration/metadatas.js +1 -1
- package/services/utils/store.js +9 -9
- package/utils/index.js +1 -1
- package/utils/wrap-bad-request.js +14 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable indent */
|
|
2
|
-
const getRowSize = arr => arr.reduce((sum, value) => sum + value.size, 0);
|
|
2
|
+
const getRowSize = (arr) => arr.reduce((sum, value) => sum + value.size, 0);
|
|
3
3
|
|
|
4
|
-
const createLayout = arr => {
|
|
4
|
+
const createLayout = (arr) => {
|
|
5
5
|
return arr.reduce((acc, current, index) => {
|
|
6
6
|
const row = { rowId: index, rowContent: current };
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ const createLayout = arr => {
|
|
|
9
9
|
}, []);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const formatLayout = arr => {
|
|
12
|
+
const formatLayout = (arr) => {
|
|
13
13
|
return arr
|
|
14
14
|
.reduce((acc, current) => {
|
|
15
15
|
let toPush = [];
|
|
@@ -33,7 +33,7 @@ const formatLayout = arr => {
|
|
|
33
33
|
? 0
|
|
34
34
|
: Math.max.apply(
|
|
35
35
|
Math,
|
|
36
|
-
acc.map(o => o.rowId)
|
|
36
|
+
acc.map((o) => o.rowId)
|
|
37
37
|
) + 1;
|
|
38
38
|
|
|
39
39
|
const currentRowSize = getRowSize(currentRow);
|
|
@@ -57,8 +57,8 @@ const formatLayout = arr => {
|
|
|
57
57
|
|
|
58
58
|
return acc;
|
|
59
59
|
}, [])
|
|
60
|
-
.filter(row => row.rowContent.length > 0)
|
|
61
|
-
.filter(row => {
|
|
60
|
+
.filter((row) => row.rowContent.length > 0)
|
|
61
|
+
.filter((row) => {
|
|
62
62
|
if (row.rowContent.length === 1) {
|
|
63
63
|
return row.rowContent[0].name !== '_TEMP_';
|
|
64
64
|
}
|
|
@@ -67,15 +67,15 @@ const formatLayout = arr => {
|
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const unformatLayout = arr => {
|
|
70
|
+
const unformatLayout = (arr) => {
|
|
71
71
|
return arr.reduce((acc, current) => {
|
|
72
|
-
const currentRow = current.rowContent.filter(content => content.name !== '_TEMP_');
|
|
72
|
+
const currentRow = current.rowContent.filter((content) => content.name !== '_TEMP_');
|
|
73
73
|
|
|
74
74
|
return acc.concat([currentRow]);
|
|
75
75
|
}, []);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const getInputSize = type => {
|
|
78
|
+
const getInputSize = (type) => {
|
|
79
79
|
switch (type) {
|
|
80
80
|
case 'boolean':
|
|
81
81
|
case 'date':
|
|
@@ -17,7 +17,7 @@ const DeleteLink = ({ isCreatingEntry, onDelete, onDeleteSucceeded, trackerPrope
|
|
|
17
17
|
const [isModalConfirmButtonLoading, setIsModalConfirmButtonLoading] = useState(false);
|
|
18
18
|
const { formatMessage } = useIntl();
|
|
19
19
|
|
|
20
|
-
const toggleWarningDelete = () => setWarningDelete(prevState => !prevState);
|
|
20
|
+
const toggleWarningDelete = () => setWarningDelete((prevState) => !prevState);
|
|
21
21
|
|
|
22
22
|
const handleConfirmDelete = async () => {
|
|
23
23
|
try {
|
|
@@ -39,9 +39,10 @@ const Header = ({
|
|
|
39
39
|
const [shouldUnpublish, setShouldUnpublish] = useState(false);
|
|
40
40
|
const [shouldPublish, setShouldPublish] = useState(false);
|
|
41
41
|
|
|
42
|
-
const currentContentTypeMainField = useMemo(
|
|
43
|
-
layout,
|
|
44
|
-
|
|
42
|
+
const currentContentTypeMainField = useMemo(
|
|
43
|
+
() => get(layout, ['settings', 'mainField'], 'id'),
|
|
44
|
+
[layout]
|
|
45
|
+
);
|
|
45
46
|
|
|
46
47
|
const currentContentTypeName = useMemo(() => get(layout, ['info', 'name']), [layout]);
|
|
47
48
|
|
|
@@ -100,7 +101,7 @@ const Header = ({
|
|
|
100
101
|
/* eslint-disable indent */
|
|
101
102
|
const onClick = isPublished
|
|
102
103
|
? () => setWarningUnpublish(true)
|
|
103
|
-
: e => {
|
|
104
|
+
: (e) => {
|
|
104
105
|
if (!checkIfHasDraftRelations()) {
|
|
105
106
|
onPublish(e);
|
|
106
107
|
} else {
|
|
@@ -145,10 +146,10 @@ const Header = ({
|
|
|
145
146
|
};
|
|
146
147
|
}, [headerActions, headerTitle, apiID]);
|
|
147
148
|
|
|
148
|
-
const toggleWarningPublish = () => setWarningUnpublish(prevState => !prevState);
|
|
149
|
+
const toggleWarningPublish = () => setWarningUnpublish((prevState) => !prevState);
|
|
149
150
|
|
|
150
151
|
const toggleWarningDraftRelation = useCallback(() => {
|
|
151
|
-
setShowWarningDraftRelation(prev => !prev);
|
|
152
|
+
setShowWarningDraftRelation((prev) => !prev);
|
|
152
153
|
}, []);
|
|
153
154
|
|
|
154
155
|
const handleConfirmPublish = useCallback(() => {
|
|
@@ -162,7 +163,7 @@ const Header = ({
|
|
|
162
163
|
}, []);
|
|
163
164
|
|
|
164
165
|
const handleCloseModalPublish = useCallback(
|
|
165
|
-
e => {
|
|
166
|
+
(e) => {
|
|
166
167
|
if (shouldPublish) {
|
|
167
168
|
onPublish(e);
|
|
168
169
|
}
|
|
@@ -173,7 +174,7 @@ const Header = ({
|
|
|
173
174
|
);
|
|
174
175
|
|
|
175
176
|
const handleCloseModalUnpublish = useCallback(
|
|
176
|
-
e => {
|
|
177
|
+
(e) => {
|
|
177
178
|
if (shouldUnpublish) {
|
|
178
179
|
onUnpublish(e);
|
|
179
180
|
}
|
|
@@ -218,7 +219,7 @@ const Header = ({
|
|
|
218
219
|
id: getTrad(`popUpwarning.warning.has-draft-relations.message.${contentIdSuffix}`),
|
|
219
220
|
values: {
|
|
220
221
|
count: draftRelationsCount,
|
|
221
|
-
b: chunks => (
|
|
222
|
+
b: (chunks) => (
|
|
222
223
|
<Text as="span" fontWeight="bold">
|
|
223
224
|
{chunks}
|
|
224
225
|
</Text>
|
|
@@ -14,7 +14,7 @@ const getDraftRelations = (data, ctSchema, components) => {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
if (type === 'dynamiczone') {
|
|
17
|
-
currentData.forEach(curr => {
|
|
17
|
+
currentData.forEach((curr) => {
|
|
18
18
|
const compoSchema = get(components, curr.__component, {});
|
|
19
19
|
|
|
20
20
|
acc += getDraftRelationsCount(curr, compoSchema);
|
|
@@ -27,7 +27,7 @@ const getDraftRelations = (data, ctSchema, components) => {
|
|
|
27
27
|
const compoSchema = get(components, compoUID, {});
|
|
28
28
|
|
|
29
29
|
if (isRepeatable) {
|
|
30
|
-
currentData.forEach(curr => {
|
|
30
|
+
currentData.forEach((curr) => {
|
|
31
31
|
acc += getDraftRelationsCount(curr, compoSchema);
|
|
32
32
|
});
|
|
33
33
|
} else {
|
|
@@ -43,7 +43,7 @@ const getDraftRelations = (data, ctSchema, components) => {
|
|
|
43
43
|
acc += 1;
|
|
44
44
|
}
|
|
45
45
|
} else {
|
|
46
|
-
currentData.forEach(value => {
|
|
46
|
+
currentData.forEach((value) => {
|
|
47
47
|
if (has(value, 'published_at') && isEmpty(value.published_at)) {
|
|
48
48
|
acc += 1;
|
|
49
49
|
}
|
|
@@ -40,13 +40,10 @@ const EditView = ({
|
|
|
40
40
|
}) => {
|
|
41
41
|
const { currentEnvironment, plugins } = useGlobalContext();
|
|
42
42
|
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} = useMemo(() => {
|
|
48
|
-
return getFieldsActionMatchingPermissions(userPermissions, slug);
|
|
49
|
-
}, [userPermissions, slug]);
|
|
43
|
+
const { createActionAllowedFields, readActionAllowedFields, updateActionAllowedFields } =
|
|
44
|
+
useMemo(() => {
|
|
45
|
+
return getFieldsActionMatchingPermissions(userPermissions, slug);
|
|
46
|
+
}, [userPermissions, slug]);
|
|
50
47
|
const configurationPermissions = useMemo(() => {
|
|
51
48
|
return isSingleType
|
|
52
49
|
? pluginPermissions.singleTypesConfigurations
|
|
@@ -64,9 +61,9 @@ const EditView = ({
|
|
|
64
61
|
);
|
|
65
62
|
|
|
66
63
|
// Check if a block is a dynamic zone
|
|
67
|
-
const isDynamicZone = useCallback(block => {
|
|
68
|
-
return block.every(subBlock => {
|
|
69
|
-
return subBlock.every(obj => obj.fieldSchema.type === 'dynamiczone');
|
|
64
|
+
const isDynamicZone = useCallback((block) => {
|
|
65
|
+
return block.every((subBlock) => {
|
|
66
|
+
return subBlock.every((obj) => obj.fieldSchema.type === 'dynamiczone');
|
|
70
67
|
});
|
|
71
68
|
}, []);
|
|
72
69
|
|
|
@@ -3,24 +3,19 @@ import { get, isEmpty } from 'lodash';
|
|
|
3
3
|
/* eslint-disable no-restricted-syntax */
|
|
4
4
|
|
|
5
5
|
const createAttributesLayout = (currentLayout, attributes) => {
|
|
6
|
-
const getType = name => get(attributes, [name, 'type'], '');
|
|
6
|
+
const getType = (name) => get(attributes, [name, 'type'], '');
|
|
7
7
|
let currentRowIndex = 0;
|
|
8
8
|
const newLayout = [];
|
|
9
9
|
|
|
10
10
|
for (let row of currentLayout) {
|
|
11
|
-
const hasDynamicZone = row.some(
|
|
12
|
-
({ name }) => getType(name) === 'dynamiczone'
|
|
13
|
-
);
|
|
11
|
+
const hasDynamicZone = row.some(({ name }) => getType(name) === 'dynamiczone');
|
|
14
12
|
|
|
15
13
|
if (!newLayout[currentRowIndex]) {
|
|
16
14
|
newLayout[currentRowIndex] = [];
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
if (hasDynamicZone) {
|
|
20
|
-
currentRowIndex =
|
|
21
|
-
currentRowIndex === 0 && isEmpty(newLayout[0])
|
|
22
|
-
? 0
|
|
23
|
-
: currentRowIndex + 1;
|
|
18
|
+
currentRowIndex = currentRowIndex === 0 && isEmpty(newLayout[0]) ? 0 : currentRowIndex + 1;
|
|
24
19
|
|
|
25
20
|
if (!newLayout[currentRowIndex]) {
|
|
26
21
|
newLayout[currentRowIndex] = [];
|
|
@@ -33,7 +28,7 @@ const createAttributesLayout = (currentLayout, attributes) => {
|
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
30
|
|
|
36
|
-
return newLayout.filter(arr => arr.length > 0);
|
|
31
|
+
return newLayout.filter((arr) => arr.length > 0);
|
|
37
32
|
};
|
|
38
33
|
|
|
39
34
|
export default createAttributesLayout;
|
|
@@ -2,7 +2,7 @@ import { uniq, flatMap } from 'lodash';
|
|
|
2
2
|
import { findMatchingPermissions } from 'strapi-helper-plugin';
|
|
3
3
|
|
|
4
4
|
const getFieldsActionMatchingPermissions = (userPermissions, slug) => {
|
|
5
|
-
const getMatchingPermissions = action => {
|
|
5
|
+
const getMatchingPermissions = (action) => {
|
|
6
6
|
const matched = findMatchingPermissions(userPermissions, [
|
|
7
7
|
{
|
|
8
8
|
action: `plugins::content-manager.explorer.${action}`,
|
|
@@ -36,13 +36,8 @@ const EditViewDataManagerProvider = ({
|
|
|
36
36
|
updateActionAllowedFields,
|
|
37
37
|
}) => {
|
|
38
38
|
const [reducerState, dispatch] = useReducer(reducer, initialState);
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
initialData,
|
|
42
|
-
modifiedData,
|
|
43
|
-
modifiedDZName,
|
|
44
|
-
shouldCheckErrors,
|
|
45
|
-
} = reducerState.toJS();
|
|
39
|
+
const { formErrors, initialData, modifiedData, modifiedDZName, shouldCheckErrors } =
|
|
40
|
+
reducerState.toJS();
|
|
46
41
|
|
|
47
42
|
const currentContentTypeLayout = get(allLayoutData, ['contentType'], {});
|
|
48
43
|
|
|
@@ -234,7 +229,7 @@ const EditViewDataManagerProvider = ({
|
|
|
234
229
|
);
|
|
235
230
|
|
|
236
231
|
const createFormData = useCallback(
|
|
237
|
-
data => {
|
|
232
|
+
(data) => {
|
|
238
233
|
// First we need to remove the added keys needed for the dnd
|
|
239
234
|
const preparedData = removeKeyInObject(cloneDeep(data), '__temp_key__');
|
|
240
235
|
// Then we need to apply our helper
|
|
@@ -258,7 +253,7 @@ const EditViewDataManagerProvider = ({
|
|
|
258
253
|
}, [hasDraftAndPublish, shouldNotRunValidations]);
|
|
259
254
|
|
|
260
255
|
const handleSubmit = useCallback(
|
|
261
|
-
async e => {
|
|
256
|
+
async (e) => {
|
|
262
257
|
e.preventDefault();
|
|
263
258
|
let errors = {};
|
|
264
259
|
|
|
@@ -318,8 +313,8 @@ const EditViewDataManagerProvider = ({
|
|
|
318
313
|
}, [allLayoutData, currentContentTypeLayout, isCreatingEntry, modifiedData, onPublish]);
|
|
319
314
|
|
|
320
315
|
const shouldCheckDZErrors = useCallback(
|
|
321
|
-
dzName => {
|
|
322
|
-
const doesDZHaveError = Object.keys(formErrors).some(key => key.split('.')[0] === dzName);
|
|
316
|
+
(dzName) => {
|
|
317
|
+
const doesDZHaveError = Object.keys(formErrors).some((key) => key.split('.')[0] === dzName);
|
|
323
318
|
const shouldCheckErrors = !isEmpty(formErrors) && doesDZHaveError;
|
|
324
319
|
|
|
325
320
|
return shouldCheckErrors;
|
|
@@ -373,7 +368,7 @@ const EditViewDataManagerProvider = ({
|
|
|
373
368
|
});
|
|
374
369
|
}, []);
|
|
375
370
|
|
|
376
|
-
const onRemoveRelation = useCallback(keys => {
|
|
371
|
+
const onRemoveRelation = useCallback((keys) => {
|
|
377
372
|
dispatch({
|
|
378
373
|
type: 'REMOVE_RELATION',
|
|
379
374
|
keys,
|
|
@@ -21,7 +21,7 @@ const reducer = (state, action) => {
|
|
|
21
21
|
});
|
|
22
22
|
case 'ADD_REPEATABLE_COMPONENT_TO_FIELD': {
|
|
23
23
|
return state
|
|
24
|
-
.updateIn(['modifiedData', ...action.keys], list => {
|
|
24
|
+
.updateIn(['modifiedData', ...action.keys], (list) => {
|
|
25
25
|
const defaultDataStructure = state
|
|
26
26
|
.getIn(['componentsDataStructure', action.componentUid])
|
|
27
27
|
.set('__temp_key__', getMaxTempKey(list ? list.toJS() : []) + 1);
|
|
@@ -32,7 +32,7 @@ const reducer = (state, action) => {
|
|
|
32
32
|
|
|
33
33
|
return fromJS([defaultDataStructure]);
|
|
34
34
|
})
|
|
35
|
-
.update('shouldCheckErrors', v => {
|
|
35
|
+
.update('shouldCheckErrors', (v) => {
|
|
36
36
|
if (action.shouldCheckErrors === true) {
|
|
37
37
|
return !v;
|
|
38
38
|
}
|
|
@@ -42,7 +42,7 @@ const reducer = (state, action) => {
|
|
|
42
42
|
}
|
|
43
43
|
case 'ADD_COMPONENT_TO_DYNAMIC_ZONE':
|
|
44
44
|
return state
|
|
45
|
-
.updateIn(['modifiedData', ...action.keys], list => {
|
|
45
|
+
.updateIn(['modifiedData', ...action.keys], (list) => {
|
|
46
46
|
const defaultDataStructure = state
|
|
47
47
|
.getIn(['componentsDataStructure', action.componentUid])
|
|
48
48
|
.set('__component', action.componentUid);
|
|
@@ -54,7 +54,7 @@ const reducer = (state, action) => {
|
|
|
54
54
|
return fromJS([defaultDataStructure]);
|
|
55
55
|
})
|
|
56
56
|
.update('modifiedDZName', () => action.keys[0])
|
|
57
|
-
.update('shouldCheckErrors', v => {
|
|
57
|
+
.update('shouldCheckErrors', (v) => {
|
|
58
58
|
if (action.shouldCheckErrors === true) {
|
|
59
59
|
return !v;
|
|
60
60
|
}
|
|
@@ -62,7 +62,7 @@ const reducer = (state, action) => {
|
|
|
62
62
|
return v;
|
|
63
63
|
});
|
|
64
64
|
case 'ADD_RELATION':
|
|
65
|
-
return state.updateIn(['modifiedData', ...action.keys], list => {
|
|
65
|
+
return state.updateIn(['modifiedData', ...action.keys], (list) => {
|
|
66
66
|
if (!Array.isArray(action.value) || !action.value.length) {
|
|
67
67
|
return list;
|
|
68
68
|
}
|
|
@@ -84,7 +84,7 @@ const reducer = (state, action) => {
|
|
|
84
84
|
.update('shouldCheckErrors', () => false);
|
|
85
85
|
}
|
|
86
86
|
case 'MOVE_COMPONENT_FIELD':
|
|
87
|
-
return state.updateIn(['modifiedData', ...action.pathToComponent], list => {
|
|
87
|
+
return state.updateIn(['modifiedData', ...action.pathToComponent], (list) => {
|
|
88
88
|
return list
|
|
89
89
|
.delete(action.dragIndex)
|
|
90
90
|
.insert(
|
|
@@ -94,14 +94,14 @@ const reducer = (state, action) => {
|
|
|
94
94
|
});
|
|
95
95
|
case 'MOVE_COMPONENT_UP':
|
|
96
96
|
return state
|
|
97
|
-
.update('shouldCheckErrors', v => {
|
|
97
|
+
.update('shouldCheckErrors', (v) => {
|
|
98
98
|
if (action.shouldCheckErrors) {
|
|
99
99
|
return !v;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
return v;
|
|
103
103
|
})
|
|
104
|
-
.updateIn(['modifiedData', action.dynamicZoneName], list => {
|
|
104
|
+
.updateIn(['modifiedData', action.dynamicZoneName], (list) => {
|
|
105
105
|
return list
|
|
106
106
|
.delete(action.currentIndex)
|
|
107
107
|
.insert(
|
|
@@ -111,14 +111,14 @@ const reducer = (state, action) => {
|
|
|
111
111
|
});
|
|
112
112
|
case 'MOVE_COMPONENT_DOWN':
|
|
113
113
|
return state
|
|
114
|
-
.update('shouldCheckErrors', v => {
|
|
114
|
+
.update('shouldCheckErrors', (v) => {
|
|
115
115
|
if (action.shouldCheckErrors) {
|
|
116
116
|
return !v;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
return v;
|
|
120
120
|
})
|
|
121
|
-
.updateIn(['modifiedData', action.dynamicZoneName], list => {
|
|
121
|
+
.updateIn(['modifiedData', action.dynamicZoneName], (list) => {
|
|
122
122
|
return list
|
|
123
123
|
.delete(action.currentIndex)
|
|
124
124
|
.insert(
|
|
@@ -127,7 +127,7 @@ const reducer = (state, action) => {
|
|
|
127
127
|
);
|
|
128
128
|
});
|
|
129
129
|
case 'MOVE_FIELD':
|
|
130
|
-
return state.updateIn(['modifiedData', ...action.keys], list => {
|
|
130
|
+
return state.updateIn(['modifiedData', ...action.keys], (list) => {
|
|
131
131
|
return list.delete(action.dragIndex).insert(action.overIndex, list.get(action.dragIndex));
|
|
132
132
|
});
|
|
133
133
|
case 'ON_CHANGE': {
|
|
@@ -157,7 +157,7 @@ const reducer = (state, action) => {
|
|
|
157
157
|
}
|
|
158
158
|
case 'REMOVE_COMPONENT_FROM_DYNAMIC_ZONE':
|
|
159
159
|
return state
|
|
160
|
-
.update('shouldCheckErrors', v => {
|
|
160
|
+
.update('shouldCheckErrors', (v) => {
|
|
161
161
|
if (action.shouldCheckErrors) {
|
|
162
162
|
return !v;
|
|
163
163
|
}
|
|
@@ -177,7 +177,7 @@ const reducer = (state, action) => {
|
|
|
177
177
|
const componentPathToRemove = ['modifiedData', ...action.keys];
|
|
178
178
|
|
|
179
179
|
return state
|
|
180
|
-
.update('shouldCheckErrors', v => {
|
|
180
|
+
.update('shouldCheckErrors', (v) => {
|
|
181
181
|
const hasErrors = state.get('formErrors').keySeq().size > 0;
|
|
182
182
|
|
|
183
183
|
if (hasErrors) {
|
|
@@ -200,7 +200,7 @@ const reducer = (state, action) => {
|
|
|
200
200
|
.update('formErrors', () => fromJS(action.errors));
|
|
201
201
|
}
|
|
202
202
|
case 'TRIGGER_FORM_VALIDATION':
|
|
203
|
-
return state.update('shouldCheckErrors', v => {
|
|
203
|
+
return state.update('shouldCheckErrors', (v) => {
|
|
204
204
|
const hasErrors = state.get('formErrors').keySeq().size > 0;
|
|
205
205
|
|
|
206
206
|
if (hasErrors) {
|
|
@@ -32,7 +32,7 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
|
|
|
32
32
|
break;
|
|
33
33
|
case 'media':
|
|
34
34
|
if (getOtherInfos(schema, [current, 'multiple']) === true) {
|
|
35
|
-
cleanedData = value ? value.filter(file => !(file instanceof File)) : null;
|
|
35
|
+
cleanedData = value ? value.filter((file) => !(file instanceof File)) : null;
|
|
36
36
|
} else {
|
|
37
37
|
cleanedData = get(value, 0) instanceof File ? null : get(value, 'id', null);
|
|
38
38
|
}
|
|
@@ -40,7 +40,7 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
|
|
|
40
40
|
case 'component':
|
|
41
41
|
if (isRepeatable) {
|
|
42
42
|
cleanedData = value
|
|
43
|
-
? value.map(data => {
|
|
43
|
+
? value.map((data) => {
|
|
44
44
|
const subCleanedData = recursiveCleanData(data, componentsSchema[component]);
|
|
45
45
|
|
|
46
46
|
return subCleanedData;
|
|
@@ -51,7 +51,7 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
|
|
|
51
51
|
}
|
|
52
52
|
break;
|
|
53
53
|
case 'dynamiczone':
|
|
54
|
-
cleanedData = value.map(componentData => {
|
|
54
|
+
cleanedData = value.map((componentData) => {
|
|
55
55
|
const subCleanedData = recursiveCleanData(
|
|
56
56
|
componentData,
|
|
57
57
|
componentsSchema[componentData.__component]
|
|
@@ -76,7 +76,7 @@ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
|
|
|
76
76
|
|
|
77
77
|
export const helperCleanData = (value, key) => {
|
|
78
78
|
if (isArray(value)) {
|
|
79
|
-
return value.map(obj => (obj[key] ? obj[key] : obj));
|
|
79
|
+
return value.map((obj) => (obj[key] ? obj[key] : obj));
|
|
80
80
|
}
|
|
81
81
|
if (isObject(value)) {
|
|
82
82
|
return value[key];
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { get } from 'lodash';
|
|
2
2
|
|
|
3
|
-
const getYupInnerErrors = error => {
|
|
3
|
+
const getYupInnerErrors = (error) => {
|
|
4
4
|
return get(error, 'inner', []).reduce((acc, curr) => {
|
|
5
|
-
acc[
|
|
6
|
-
curr.path
|
|
7
|
-
.split('[')
|
|
8
|
-
.join('.')
|
|
9
|
-
.split(']')
|
|
10
|
-
.join('')
|
|
11
|
-
] = { id: curr.message };
|
|
5
|
+
acc[curr.path.split('[').join('.').split(']').join('')] = { id: curr.message };
|
|
12
6
|
|
|
13
7
|
return acc;
|
|
14
8
|
}, {});
|
|
@@ -14,11 +14,11 @@ import * as yup from 'yup';
|
|
|
14
14
|
import { translatedErrors as errorsTrads } from 'strapi-helper-plugin';
|
|
15
15
|
|
|
16
16
|
yup.addMethod(yup.mixed, 'defined', function() {
|
|
17
|
-
return this.test('defined', errorsTrads.required, value => value !== undefined);
|
|
17
|
+
return this.test('defined', errorsTrads.required, (value) => value !== undefined);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
yup.addMethod(yup.array, 'notEmptyMin', function(min) {
|
|
21
|
-
return this.test('notEmptyMin', errorsTrads.min, value => {
|
|
21
|
+
return this.test('notEmptyMin', errorsTrads.min, (value) => {
|
|
22
22
|
if (isEmpty(value)) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
@@ -55,7 +55,7 @@ yup.addMethod(yup.string, 'isSuperior', function(message, min) {
|
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
const getAttributes = data => get(data, ['attributes'], {});
|
|
58
|
+
const getAttributes = (data) => get(data, ['attributes'], {});
|
|
59
59
|
|
|
60
60
|
const createYupSchema = (
|
|
61
61
|
model,
|
|
@@ -100,7 +100,7 @@ const createYupSchema = (
|
|
|
100
100
|
|
|
101
101
|
if (attribute.repeatable === true) {
|
|
102
102
|
const { min, max, required } = attribute;
|
|
103
|
-
let componentSchema = yup.lazy(value => {
|
|
103
|
+
let componentSchema = yup.lazy((value) => {
|
|
104
104
|
let baseSchema = yup.array().of(componentFieldSchema);
|
|
105
105
|
|
|
106
106
|
if (min && !options.isDraft) {
|
|
@@ -124,7 +124,7 @@ const createYupSchema = (
|
|
|
124
124
|
|
|
125
125
|
return acc;
|
|
126
126
|
}
|
|
127
|
-
const componentSchema = yup.lazy(obj => {
|
|
127
|
+
const componentSchema = yup.lazy((obj) => {
|
|
128
128
|
if (obj !== undefined) {
|
|
129
129
|
return attribute.required === true && !options.isDraft
|
|
130
130
|
? componentFieldSchema.defined()
|
|
@@ -153,7 +153,7 @@ const createYupSchema = (
|
|
|
153
153
|
const { max, min } = attribute;
|
|
154
154
|
|
|
155
155
|
if (attribute.required && !options.isDraft) {
|
|
156
|
-
dynamicZoneSchema = dynamicZoneSchema.test('required', errorsTrads.required, value => {
|
|
156
|
+
dynamicZoneSchema = dynamicZoneSchema.test('required', errorsTrads.required, (value) => {
|
|
157
157
|
if (options.isCreatingEntry) {
|
|
158
158
|
return value !== null || value !== undefined;
|
|
159
159
|
}
|
|
@@ -167,7 +167,7 @@ const createYupSchema = (
|
|
|
167
167
|
|
|
168
168
|
if (min) {
|
|
169
169
|
dynamicZoneSchema = dynamicZoneSchema
|
|
170
|
-
.test('min', errorsTrads.min, value => {
|
|
170
|
+
.test('min', errorsTrads.min, (value) => {
|
|
171
171
|
if (options.isCreatingEntry) {
|
|
172
172
|
return value && value.length > 0;
|
|
173
173
|
}
|
|
@@ -178,7 +178,7 @@ const createYupSchema = (
|
|
|
178
178
|
|
|
179
179
|
return value !== null && value.length > 0;
|
|
180
180
|
})
|
|
181
|
-
.test('required', errorsTrads.required, value => {
|
|
181
|
+
.test('required', errorsTrads.required, (value) => {
|
|
182
182
|
if (options.isCreatingEntry) {
|
|
183
183
|
return value !== null || value !== undefined;
|
|
184
184
|
}
|
|
@@ -219,7 +219,7 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
|
|
219
219
|
if (type === 'json') {
|
|
220
220
|
schema = yup
|
|
221
221
|
.mixed(errorsTrads.json)
|
|
222
|
-
.test('isJSON', errorsTrads.json, value => {
|
|
222
|
+
.test('isJSON', errorsTrads.json, (value) => {
|
|
223
223
|
if (value === undefined) {
|
|
224
224
|
return true;
|
|
225
225
|
}
|
|
@@ -246,7 +246,7 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
|
|
246
246
|
if (['number', 'integer', 'biginteger', 'float', 'decimal'].includes(type)) {
|
|
247
247
|
schema = yup
|
|
248
248
|
.number()
|
|
249
|
-
.transform(cv => (isNaN(cv) ? undefined : cv))
|
|
249
|
+
.transform((cv) => (isNaN(cv) ? undefined : cv))
|
|
250
250
|
.typeError();
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -258,7 +258,7 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
|
|
258
258
|
schema = yup.string().matches(/^\d*$/);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
Object.keys(validations).forEach(validation => {
|
|
261
|
+
Object.keys(validations).forEach((validation) => {
|
|
262
262
|
const validationValue = validations[validation];
|
|
263
263
|
|
|
264
264
|
if (
|
|
@@ -277,7 +277,7 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
|
|
277
277
|
if (options.isCreatingEntry) {
|
|
278
278
|
schema = schema.required(errorsTrads.required);
|
|
279
279
|
} else {
|
|
280
|
-
schema = schema.test('required', errorsTrads.required, value => {
|
|
280
|
+
schema = schema.test('required', errorsTrads.required, (value) => {
|
|
281
281
|
// Field is not touched and the user is editing the entry
|
|
282
282
|
if (value === undefined && !options.isFromComponent) {
|
|
283
283
|
return true;
|
|
@@ -5,7 +5,7 @@ import isEqual from 'react-fast-compare';
|
|
|
5
5
|
import EditView from '../EditView';
|
|
6
6
|
import { generatePermissionsObject } from '../../utils';
|
|
7
7
|
|
|
8
|
-
const Permissions = props => {
|
|
8
|
+
const Permissions = (props) => {
|
|
9
9
|
const viewPermissions = useMemo(() => generatePermissionsObject(props.slug), [props.slug]);
|
|
10
10
|
const { isLoading, allowedActions } = useUserPermissions(viewPermissions, props.userPermissions);
|
|
11
11
|
|
|
@@ -12,7 +12,7 @@ export const initialState = {
|
|
|
12
12
|
|
|
13
13
|
const editViewManagerReducer = (state = initialState, action) =>
|
|
14
14
|
// eslint-disable-next-line consistent-return
|
|
15
|
-
produce(state, drafState => {
|
|
15
|
+
produce(state, (drafState) => {
|
|
16
16
|
switch (action.type) {
|
|
17
17
|
case RESET_PROPS: {
|
|
18
18
|
drafState.currentLayout = null;
|
|
@@ -6,16 +6,7 @@ import ItemTypes from '../../utils/ItemTypes';
|
|
|
6
6
|
import DraggedField from '../../components/DraggedField';
|
|
7
7
|
import useLayoutDnd from '../../hooks/useLayoutDnd';
|
|
8
8
|
|
|
9
|
-
const Label = ({
|
|
10
|
-
count,
|
|
11
|
-
index,
|
|
12
|
-
label,
|
|
13
|
-
move,
|
|
14
|
-
name,
|
|
15
|
-
onClick,
|
|
16
|
-
onRemove,
|
|
17
|
-
selectedItem,
|
|
18
|
-
}) => {
|
|
9
|
+
const Label = ({ count, index, label, move, name, onClick, onRemove, selectedItem }) => {
|
|
19
10
|
const ref = useRef(null);
|
|
20
11
|
const { setIsDraggingSibling } = useLayoutDnd();
|
|
21
12
|
|
|
@@ -46,7 +37,7 @@ const Label = ({
|
|
|
46
37
|
setIsDraggingSibling(false);
|
|
47
38
|
},
|
|
48
39
|
item: { type: ItemTypes.FIELD, id: name, name, index },
|
|
49
|
-
collect: monitor => ({
|
|
40
|
+
collect: (monitor) => ({
|
|
50
41
|
isDragging: monitor.isDragging(),
|
|
51
42
|
}),
|
|
52
43
|
});
|