@akemona-org/strapi-plugin-content-type-builder 3.7.0 → 3.7.1
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/components/AllowedTypesSelect/index.js +1 -1
- package/admin/src/components/AttributeOption/index.js +1 -1
- package/admin/src/components/BooleanBox/icons/CTSelected.js +1 -1
- package/admin/src/components/BooleanBox/icons/CTUnselected.js +1 -1
- package/admin/src/components/BooleanBox/icons/STSelected.js +1 -1
- package/admin/src/components/BooleanBox/icons/STUnselected.js +1 -1
- package/admin/src/components/BooleanBox/index.js +3 -3
- package/admin/src/components/ComponentCard/index.js +1 -1
- package/admin/src/components/ComponentIconPicker/CellRenderer.js +1 -6
- package/admin/src/components/ComponentIconPicker/index.js +4 -4
- package/admin/src/components/ComponentList/index.js +1 -3
- package/admin/src/components/ComponentSelect/MenuList.js +5 -6
- package/admin/src/components/ComponentSelect/MultipleMenuList.js +15 -15
- package/admin/src/components/ComponentSelect/Value.js +3 -11
- package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +1 -1
- package/admin/src/components/ComponentSelect/utils/hasSubArray.js +1 -1
- package/admin/src/components/CreatableSelect/index.js +2 -2
- package/admin/src/components/CustomCheckbox/index.js +1 -1
- package/admin/src/components/DynamicZoneList/index.js +1 -1
- package/admin/src/components/HeaderNavLink/index.js +2 -4
- package/admin/src/components/List/index.js +1 -1
- package/admin/src/components/ListHeader/index.js +1 -1
- package/admin/src/components/ListRow/index.js +3 -3
- package/admin/src/components/ModalHeader/DropdownInfos.js +1 -1
- package/admin/src/components/ModalHeader/index.js +2 -8
- package/admin/src/components/RelationForm/index.js +2 -8
- package/admin/src/components/RelationFormBox/index.js +1 -3
- package/admin/src/components/RelationFormNaturePicker/index.js +1 -1
- package/admin/src/components/RelationTargetPicker/index.js +2 -2
- package/admin/src/components/SelectMenuUl/index.js +1 -1
- package/admin/src/components/WrapperSelect/index.js +2 -2
- package/admin/src/containers/DataManagerProvider/constants.js +10 -5
- package/admin/src/containers/DataManagerProvider/index.js +15 -17
- package/admin/src/containers/DataManagerProvider/reducer.js +25 -25
- package/admin/src/containers/DataManagerProvider/selectors.js +2 -2
- package/admin/src/containers/DataManagerProvider/utils/cleanData.js +8 -8
- package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +1 -1
- package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +25 -42
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +6 -21
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +12 -18
- package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +4 -10
- package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +1 -1
- package/admin/src/containers/FormModal/attributes/advancedForm.js +6 -6
- package/admin/src/containers/FormModal/attributes/baseForm.js +5 -5
- package/admin/src/containers/FormModal/attributes/types.js +10 -23
- package/admin/src/containers/FormModal/attributes/validation/common.js +8 -16
- package/admin/src/containers/FormModal/category/createCategorySchema.js +2 -2
- package/admin/src/containers/FormModal/component/createComponentSchema.js +2 -2
- package/admin/src/containers/FormModal/constants.js +10 -5
- package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +2 -2
- package/admin/src/containers/FormModal/contentType/form.js +1 -1
- package/admin/src/containers/FormModal/forms/index.js +5 -5
- package/admin/src/containers/FormModal/index.js +15 -15
- package/admin/src/containers/FormModal/reducer.js +9 -9
- package/admin/src/containers/FormModal/selectors.js +2 -2
- package/admin/src/containers/FormModal/utils/createHeadersArray.js +3 -6
- package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +1 -1
- package/admin/src/containers/FormModal/utils/createUid.js +2 -2
- package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +1 -1
- package/admin/src/containers/FormModal/utils/relations.js +2 -2
- package/admin/src/containers/LeftMenu/index.js +11 -11
- package/admin/src/containers/ListView/index.js +4 -4
- package/admin/src/icons/Curve.js +1 -1
- package/admin/src/icons/ManyToMany.js +3 -12
- package/admin/src/icons/ManyToOne.js +1 -4
- package/admin/src/icons/OneToMany.js +2 -8
- package/admin/src/index.js +1 -1
- package/admin/src/pluginId.js +1 -1
- package/admin/src/utils/convertAttrObjToArray.js +1 -1
- package/admin/src/utils/formAPI.js +2 -2
- package/admin/src/utils/getAttributeDisplayedType.js +1 -1
- package/admin/src/utils/getComponents.js +2 -2
- package/admin/src/utils/getTrad.js +1 -1
- package/admin/src/utils/makeUnique.js +1 -1
- package/controllers/Components.js +7 -15
- package/controllers/validation/common.js +12 -18
- package/controllers/validation/data-transform.js +4 -4
- package/controllers/validation/model-schema.js +5 -14
- package/controllers/validation/relations.js +8 -20
- package/controllers/validation/types.js +12 -35
- package/package.json +6 -6
- package/services/Components.js +4 -4
- package/services/ContentTypes.js +2 -1
- package/services/api-handler.js +5 -5
- package/services/schema-builder/index.js +12 -14
- package/services/schema-builder/schema-handler.js +5 -5
- package/utils/helpers.js +1 -1
|
@@ -47,21 +47,11 @@ const types = {
|
|
|
47
47
|
const shape = {
|
|
48
48
|
name: validators.name(usedAttributeNames, reservedNames),
|
|
49
49
|
type: validators.type(),
|
|
50
|
-
default: yup
|
|
51
|
-
.string()
|
|
52
|
-
.nullable()
|
|
53
|
-
.matches(/^\d*$/),
|
|
50
|
+
default: yup.string().nullable().matches(/^\d*$/),
|
|
54
51
|
unique: validators.unique(),
|
|
55
52
|
required: validators.required(),
|
|
56
|
-
max: yup
|
|
57
|
-
|
|
58
|
-
.nullable()
|
|
59
|
-
.matches(/^\d*$/, errorsTrads.regex),
|
|
60
|
-
min: yup
|
|
61
|
-
.string()
|
|
62
|
-
.nullable()
|
|
63
|
-
.test(isMinSuperiorThanMax)
|
|
64
|
-
.matches(/^\d*$/, errorsTrads.regex),
|
|
53
|
+
max: yup.string().nullable().matches(/^\d*$/, errorsTrads.regex),
|
|
54
|
+
min: yup.string().nullable().test(isMinSuperiorThanMax).matches(/^\d*$/, errorsTrads.regex),
|
|
65
55
|
};
|
|
66
56
|
|
|
67
57
|
return yup.object(shape);
|
|
@@ -115,10 +105,7 @@ const types = {
|
|
|
115
105
|
const shape = {
|
|
116
106
|
name: validators.name(usedAttributeNames, reservedNames),
|
|
117
107
|
type: validators.type(),
|
|
118
|
-
default: yup
|
|
119
|
-
.string()
|
|
120
|
-
.email()
|
|
121
|
-
.nullable(),
|
|
108
|
+
default: yup.string().email().nullable(),
|
|
122
109
|
unique: validators.unique(),
|
|
123
110
|
required: validators.required(),
|
|
124
111
|
maxLength: validators.maxLength(),
|
|
@@ -148,7 +135,7 @@ const types = {
|
|
|
148
135
|
.test({
|
|
149
136
|
name: 'areEnumValuesUnique',
|
|
150
137
|
message: getTrad('error.validation.enum-duplicate'),
|
|
151
|
-
test: values => {
|
|
138
|
+
test: (values) => {
|
|
152
139
|
const filtered = [...new Set(values)];
|
|
153
140
|
|
|
154
141
|
return filtered.length === values.length;
|
|
@@ -157,14 +144,14 @@ const types = {
|
|
|
157
144
|
.test({
|
|
158
145
|
name: 'valuesMatchesRegex',
|
|
159
146
|
message: errorsTrads.regex,
|
|
160
|
-
test: values => {
|
|
161
|
-
return values.every(val => val === '' || ENUM_REGEX.test(val));
|
|
147
|
+
test: (values) => {
|
|
148
|
+
return values.every((val) => val === '' || ENUM_REGEX.test(val));
|
|
162
149
|
},
|
|
163
150
|
})
|
|
164
151
|
.test({
|
|
165
152
|
name: 'doesNotHaveEmptyValues',
|
|
166
153
|
message: getTrad('error.validation.enum-empty-string'),
|
|
167
|
-
test: values => !values.some(val => val === ''),
|
|
154
|
+
test: (values) => !values.some((val) => val === ''),
|
|
168
155
|
}),
|
|
169
156
|
enumName: yup.string().nullable(),
|
|
170
157
|
};
|
|
@@ -251,7 +238,7 @@ const types = {
|
|
|
251
238
|
const initialForbiddenName = [...alreadyTakenTargetAttributes, modifiedData.name];
|
|
252
239
|
|
|
253
240
|
let forbiddenTargetAttributeName = initialForbiddenName.filter(
|
|
254
|
-
val => val !== initialData.targetAttribute
|
|
241
|
+
(val) => val !== initialData.targetAttribute
|
|
255
242
|
);
|
|
256
243
|
|
|
257
244
|
if (!['oneWay', 'manyWay'].includes(modifiedData.nature)) {
|
|
@@ -262,7 +249,7 @@ const types = {
|
|
|
262
249
|
.test({
|
|
263
250
|
name: 'forbiddenTargetAttributeName',
|
|
264
251
|
message: getTrad('error.validation.relation.targetAttribute-taken'),
|
|
265
|
-
test: value => {
|
|
252
|
+
test: (value) => {
|
|
266
253
|
if (!value) {
|
|
267
254
|
return false;
|
|
268
255
|
}
|
|
@@ -5,11 +5,11 @@ import getTrad from '../../../../utils/getTrad';
|
|
|
5
5
|
|
|
6
6
|
const NAME_REGEX = new RegExp('^[A-Za-z][_0-9A-Za-z]*$');
|
|
7
7
|
|
|
8
|
-
const alreadyUsedAttributeNames = usedNames => {
|
|
8
|
+
const alreadyUsedAttributeNames = (usedNames) => {
|
|
9
9
|
return {
|
|
10
10
|
name: 'attributeNameAlreadyUsed',
|
|
11
11
|
message: errorsTrads.unique,
|
|
12
|
-
test: value => {
|
|
12
|
+
test: (value) => {
|
|
13
13
|
if (!value) {
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ const alreadyUsedAttributeNames = usedNames => {
|
|
|
22
22
|
const getUsedContentTypeAttributeNames = (ctShema, isEdition, attributeNameToEdit) => {
|
|
23
23
|
const attributes = get(ctShema, ['schema', 'attributes'], {});
|
|
24
24
|
|
|
25
|
-
return Object.keys(attributes).filter(attr => {
|
|
25
|
+
return Object.keys(attributes).filter((attr) => {
|
|
26
26
|
if (isEdition) {
|
|
27
27
|
return attr !== attributeNameToEdit;
|
|
28
28
|
}
|
|
@@ -31,11 +31,11 @@ const getUsedContentTypeAttributeNames = (ctShema, isEdition, attributeNameToEdi
|
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const isNameAllowed = reservedNames => {
|
|
34
|
+
const isNameAllowed = (reservedNames) => {
|
|
35
35
|
return {
|
|
36
36
|
name: 'forbiddenAttributeName',
|
|
37
37
|
message: getTrad('error.attributeName.reserved-name'),
|
|
38
|
-
test: value => {
|
|
38
|
+
test: (value) => {
|
|
39
39
|
if (!value) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -47,11 +47,7 @@ const isNameAllowed = reservedNames => {
|
|
|
47
47
|
|
|
48
48
|
const validators = {
|
|
49
49
|
default: () => yup.string().nullable(),
|
|
50
|
-
max: () =>
|
|
51
|
-
yup
|
|
52
|
-
.number()
|
|
53
|
-
.integer()
|
|
54
|
-
.nullable(),
|
|
50
|
+
max: () => yup.number().integer().nullable(),
|
|
55
51
|
min: () =>
|
|
56
52
|
yup
|
|
57
53
|
.number()
|
|
@@ -64,11 +60,7 @@ const validators = {
|
|
|
64
60
|
return schema;
|
|
65
61
|
})
|
|
66
62
|
.nullable(),
|
|
67
|
-
maxLength: () =>
|
|
68
|
-
yup
|
|
69
|
-
.number()
|
|
70
|
-
.integer()
|
|
71
|
-
.nullable(),
|
|
63
|
+
maxLength: () => yup.number().integer().nullable(),
|
|
72
64
|
minLength: () =>
|
|
73
65
|
yup
|
|
74
66
|
.number()
|
|
@@ -108,7 +100,7 @@ const createTextShape = (usedAttributeNames, reservedNames) => {
|
|
|
108
100
|
.test({
|
|
109
101
|
name: 'isValidRegExpPattern',
|
|
110
102
|
message: getTrad('error.validation.regex'),
|
|
111
|
-
test: value => {
|
|
103
|
+
test: (value) => {
|
|
112
104
|
return new RegExp(value) !== null;
|
|
113
105
|
},
|
|
114
106
|
})
|
|
@@ -3,7 +3,7 @@ import { toLower } from 'lodash';
|
|
|
3
3
|
import { translatedErrors as errorsTrads } from 'strapi-helper-plugin';
|
|
4
4
|
import CATEGORY_NAME_REGEX from './regex';
|
|
5
5
|
|
|
6
|
-
const createCategorySchema = usedCategoryNames => {
|
|
6
|
+
const createCategorySchema = (usedCategoryNames) => {
|
|
7
7
|
const shape = {
|
|
8
8
|
name: yup
|
|
9
9
|
.string()
|
|
@@ -11,7 +11,7 @@ const createCategorySchema = usedCategoryNames => {
|
|
|
11
11
|
.test({
|
|
12
12
|
name: 'nameNotAllowed',
|
|
13
13
|
message: errorsTrads.unique,
|
|
14
|
-
test: value => {
|
|
14
|
+
test: (value) => {
|
|
15
15
|
if (!value) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
@@ -12,7 +12,7 @@ const createComponentSchema = (usedComponentNames, reservedNames, category) => {
|
|
|
12
12
|
.test({
|
|
13
13
|
name: 'nameAlreadyUsed',
|
|
14
14
|
message: errorsTrads.unique,
|
|
15
|
-
test: value => {
|
|
15
|
+
test: (value) => {
|
|
16
16
|
if (!value) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
@@ -25,7 +25,7 @@ const createComponentSchema = (usedComponentNames, reservedNames, category) => {
|
|
|
25
25
|
.test({
|
|
26
26
|
name: 'nameNotAllowed',
|
|
27
27
|
message: getTrad('error.contentTypeName.reserved-name'),
|
|
28
|
-
test: value => {
|
|
28
|
+
test: (value) => {
|
|
29
29
|
if (!value) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
export const ADD_COMPONENTS_TO_DYNAMIC_ZONE =
|
|
1
|
+
export const ADD_COMPONENTS_TO_DYNAMIC_ZONE =
|
|
2
|
+
'ContentTypeBuilder/FormModal/ADD_COMPONENTS_TO_DYNAMIC_ZONE';
|
|
2
3
|
export const ON_CHANGE = 'ContentTypeBuilder/FormModal/ON_CHANGE';
|
|
3
4
|
export const ON_CHANGE_ALLOWED_TYPE = 'ContentTypeBuilder/FormModal/ON_CHANGE_ALLOWED_TYPE';
|
|
4
5
|
export const RESET_PROPS = 'ContentTypeBuilder/FormModal/RESET_PROPS';
|
|
5
|
-
export const RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO =
|
|
6
|
-
|
|
7
|
-
export const
|
|
6
|
+
export const RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO =
|
|
7
|
+
'ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO';
|
|
8
|
+
export const RESET_PROPS_AND_SAVE_CURRENT_DATA =
|
|
9
|
+
'ContentTypeBuilder/FormModal/RESET_PROPS_AND_SAVE_CURRENT_DATA';
|
|
10
|
+
export const RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ =
|
|
11
|
+
'ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ';
|
|
8
12
|
export const SET_DATA_TO_EDIT = 'ContentTypeBuilder/FormModal/SET_DATA_TO_EDIT';
|
|
9
13
|
export const SET_ATTRIBUTE_DATA_SCHEMA = 'ContentTypeBuilder/FormModal/SET_ATTRIBUTE_DATA_SCHEMA';
|
|
10
|
-
export const SET_DYNAMIC_ZONE_DATA_SCHEMA =
|
|
14
|
+
export const SET_DYNAMIC_ZONE_DATA_SCHEMA =
|
|
15
|
+
'ContentTypeBuilder/FormModal/SET_DYNAMIC_ZONE_DATA_SCHEMA';
|
|
11
16
|
export const SET_ERRORS = 'ContentTypeBuilder/FormModal/SET_ERRORS';
|
|
@@ -11,7 +11,7 @@ const createContentTypeSchema = (usedContentTypeNames, reservedNames) => {
|
|
|
11
11
|
.test({
|
|
12
12
|
name: 'nameAlreadyUsed',
|
|
13
13
|
message: errorsTrads.unique,
|
|
14
|
-
test: value => {
|
|
14
|
+
test: (value) => {
|
|
15
15
|
if (!value) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ const createContentTypeSchema = (usedContentTypeNames, reservedNames) => {
|
|
|
24
24
|
.test({
|
|
25
25
|
name: 'nameNotAllowed',
|
|
26
26
|
message: getTrad('error.contentTypeName.reserved-name'),
|
|
27
|
-
test: value => {
|
|
27
|
+
test: (value) => {
|
|
28
28
|
if (!value) {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
@@ -18,7 +18,7 @@ const forms = {
|
|
|
18
18
|
) {
|
|
19
19
|
const attributes = get(currentSchema, ['schema', 'attributes'], {});
|
|
20
20
|
|
|
21
|
-
const usedAttributeNames = Object.keys(attributes).filter(attr => {
|
|
21
|
+
const usedAttributeNames = Object.keys(attributes).filter((attr) => {
|
|
22
22
|
return attr !== options.initialData.name;
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -73,7 +73,7 @@ const forms = {
|
|
|
73
73
|
contentType: {
|
|
74
74
|
schema(alreadyTakenNames, isEditing, ctUid, reservedNames, extensions) {
|
|
75
75
|
const takenNames = isEditing
|
|
76
|
-
? alreadyTakenNames.filter(uid => uid !== ctUid)
|
|
76
|
+
? alreadyTakenNames.filter((uid) => uid !== ctUid)
|
|
77
77
|
: alreadyTakenNames;
|
|
78
78
|
|
|
79
79
|
const contentTypeShape = createContentTypeSchema(takenNames, reservedNames.models);
|
|
@@ -111,7 +111,7 @@ const forms = {
|
|
|
111
111
|
compoUid = null
|
|
112
112
|
) {
|
|
113
113
|
const takenNames = isEditing
|
|
114
|
-
? alreadyTakenAttributes.filter(uid => uid !== compoUid)
|
|
114
|
+
? alreadyTakenAttributes.filter((uid) => uid !== compoUid)
|
|
115
115
|
: alreadyTakenAttributes;
|
|
116
116
|
|
|
117
117
|
return createComponentSchema(takenNames, reservedNames.models, componentCategory);
|
|
@@ -148,8 +148,8 @@ const forms = {
|
|
|
148
148
|
editCategory: {
|
|
149
149
|
schema(allCategories, initialData) {
|
|
150
150
|
const allowedCategories = allCategories
|
|
151
|
-
.filter(cat => cat !== initialData.name)
|
|
152
|
-
.map(cat => toLower(cat));
|
|
151
|
+
.filter((cat) => cat !== initialData.name)
|
|
152
|
+
.map((cat) => toLower(cat));
|
|
153
153
|
|
|
154
154
|
return createCategorySchema(allowedCategories);
|
|
155
155
|
},
|
|
@@ -68,7 +68,7 @@ const FormModal = () => {
|
|
|
68
68
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
|
69
69
|
const formModalSelector = useMemo(makeSelectFormModal, []);
|
|
70
70
|
const dispatch = useDispatch();
|
|
71
|
-
const reducerState = useSelector(state => formModalSelector(state), shallowEqual);
|
|
71
|
+
const reducerState = useSelector((state) => formModalSelector(state), shallowEqual);
|
|
72
72
|
const { push } = useHistory();
|
|
73
73
|
const { search } = useLocation();
|
|
74
74
|
const { emitEvent, formatMessage } = useGlobalContext();
|
|
@@ -457,7 +457,7 @@ const FormModal = () => {
|
|
|
457
457
|
// in order to prevent the user from creating a relation with a targetAttribute
|
|
458
458
|
// that may exist in the other content type
|
|
459
459
|
alreadyTakenTargetContentTypeAttributes = Object.keys(targetContentTypeAttributes).filter(
|
|
460
|
-
attrName => {
|
|
460
|
+
(attrName) => {
|
|
461
461
|
// Keep all the target content type attributes when creating a relation
|
|
462
462
|
if (state.actionType !== 'edit') {
|
|
463
463
|
return true;
|
|
@@ -577,7 +577,7 @@ const FormModal = () => {
|
|
|
577
577
|
});
|
|
578
578
|
};
|
|
579
579
|
|
|
580
|
-
const toggleConfirmModal = useCallback(() => setShowConfirmModal(prev => !prev), []);
|
|
580
|
+
const toggleConfirmModal = useCallback(() => setShowConfirmModal((prev) => !prev), []);
|
|
581
581
|
|
|
582
582
|
const handleChange = useCallback(
|
|
583
583
|
({ target: { name, value, type, ...rest } }) => {
|
|
@@ -1068,7 +1068,7 @@ const FormModal = () => {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
};
|
|
1070
1070
|
|
|
1071
|
-
const sendAdvancedTabEvent = tab => {
|
|
1071
|
+
const sendAdvancedTabEvent = (tab) => {
|
|
1072
1072
|
if (tab !== 'advanced') {
|
|
1073
1073
|
return;
|
|
1074
1074
|
}
|
|
@@ -1084,7 +1084,7 @@ const FormModal = () => {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
};
|
|
1086
1086
|
|
|
1087
|
-
const sendButtonAddMoreFieldEvent = shouldContinue => {
|
|
1087
|
+
const sendButtonAddMoreFieldEvent = (shouldContinue) => {
|
|
1088
1088
|
if (
|
|
1089
1089
|
state.modalType === 'attribute' &&
|
|
1090
1090
|
state.forTarget === 'contentType' &&
|
|
@@ -1142,7 +1142,7 @@ const FormModal = () => {
|
|
|
1142
1142
|
step: state.step,
|
|
1143
1143
|
}}
|
|
1144
1144
|
>
|
|
1145
|
-
{msg => <span>{upperFirst(msg)}</span>}
|
|
1145
|
+
{(msg) => <span>{upperFirst(msg)}</span>}
|
|
1146
1146
|
</FormattedMessage>
|
|
1147
1147
|
|
|
1148
1148
|
{!isPickingAttribute && (
|
|
@@ -1159,7 +1159,7 @@ const FormModal = () => {
|
|
|
1159
1159
|
key={link.id}
|
|
1160
1160
|
{...link}
|
|
1161
1161
|
onClick={() => {
|
|
1162
|
-
setState(prev => ({
|
|
1162
|
+
setState((prev) => ({
|
|
1163
1163
|
...prev,
|
|
1164
1164
|
settingType: link.id,
|
|
1165
1165
|
}));
|
|
@@ -1246,7 +1246,7 @@ const FormModal = () => {
|
|
|
1246
1246
|
textTransform="uppercase"
|
|
1247
1247
|
>
|
|
1248
1248
|
<FormattedMessage id={getTrad(tradId)}>
|
|
1249
|
-
{txt => txt}
|
|
1249
|
+
{(txt) => txt}
|
|
1250
1250
|
</FormattedMessage>
|
|
1251
1251
|
</Text>
|
|
1252
1252
|
</Padded>
|
|
@@ -1295,7 +1295,7 @@ const FormModal = () => {
|
|
|
1295
1295
|
// - and we just want to access { "pluginOptions.i18n.localized": {...} }
|
|
1296
1296
|
// NOTE: this is a hack
|
|
1297
1297
|
const pluginOptionError = Object.keys(formErrors).find(
|
|
1298
|
-
key => key === input.name
|
|
1298
|
+
(key) => key === input.name
|
|
1299
1299
|
);
|
|
1300
1300
|
|
|
1301
1301
|
// Retrieve the error for a specific input
|
|
@@ -1311,7 +1311,7 @@ const FormModal = () => {
|
|
|
1311
1311
|
// Since the component info is stored in the
|
|
1312
1312
|
// componentToCreate object we can access the error
|
|
1313
1313
|
// By removing the key
|
|
1314
|
-
.filter(key => key !== 'componentToCreate'),
|
|
1314
|
+
.filter((key) => key !== 'componentToCreate'),
|
|
1315
1315
|
'id',
|
|
1316
1316
|
],
|
|
1317
1317
|
null
|
|
@@ -1438,7 +1438,7 @@ const FormModal = () => {
|
|
|
1438
1438
|
<Button
|
|
1439
1439
|
type={isCreating ? 'button' : 'submit'}
|
|
1440
1440
|
color="success"
|
|
1441
|
-
onClick={e => {
|
|
1441
|
+
onClick={(e) => {
|
|
1442
1442
|
handleSubmit(e, false);
|
|
1443
1443
|
}}
|
|
1444
1444
|
style={{ marginRight: '10px' }}
|
|
@@ -1450,7 +1450,7 @@ const FormModal = () => {
|
|
|
1450
1450
|
<Button
|
|
1451
1451
|
type="button"
|
|
1452
1452
|
color="delete"
|
|
1453
|
-
onClick={e => {
|
|
1453
|
+
onClick={(e) => {
|
|
1454
1454
|
e.preventDefault();
|
|
1455
1455
|
deleteData();
|
|
1456
1456
|
}}
|
|
@@ -1463,7 +1463,7 @@ const FormModal = () => {
|
|
|
1463
1463
|
<Button
|
|
1464
1464
|
type="button"
|
|
1465
1465
|
color="delete"
|
|
1466
|
-
onClick={e => {
|
|
1466
|
+
onClick={(e) => {
|
|
1467
1467
|
e.preventDefault();
|
|
1468
1468
|
|
|
1469
1469
|
deleteCategory(initialData.name);
|
|
@@ -1487,7 +1487,7 @@ const FormModal = () => {
|
|
|
1487
1487
|
? 'success'
|
|
1488
1488
|
: 'primary'
|
|
1489
1489
|
}
|
|
1490
|
-
onClick={e => handleSubmit(e, true)}
|
|
1490
|
+
onClick={(e) => handleSubmit(e, true)}
|
|
1491
1491
|
icon={
|
|
1492
1492
|
(isCreatingAttribute &&
|
|
1493
1493
|
!isCreatingComponentFromAView &&
|
|
@@ -1514,7 +1514,7 @@ const FormModal = () => {
|
|
|
1514
1514
|
? 'success'
|
|
1515
1515
|
: 'primary'
|
|
1516
1516
|
}
|
|
1517
|
-
onClick={e => handleSubmit(e, true)}
|
|
1517
|
+
onClick={(e) => handleSubmit(e, true)}
|
|
1518
1518
|
icon={
|
|
1519
1519
|
(isCreatingAttribute &&
|
|
1520
1520
|
!isCreatingComponentFromAView &&
|
|
@@ -19,13 +19,13 @@ const reducer = (state = initialState, action) => {
|
|
|
19
19
|
case actions.ADD_COMPONENTS_TO_DYNAMIC_ZONE: {
|
|
20
20
|
const { name, components, shouldAddComponents } = action;
|
|
21
21
|
|
|
22
|
-
return state.updateIn(['modifiedData', name], list => {
|
|
22
|
+
return state.updateIn(['modifiedData', name], (list) => {
|
|
23
23
|
let updatedList = list;
|
|
24
24
|
|
|
25
25
|
if (shouldAddComponents) {
|
|
26
26
|
updatedList = list.concat(components);
|
|
27
27
|
} else {
|
|
28
|
-
updatedList = list.filter(comp => {
|
|
28
|
+
updatedList = list.filter((comp) => {
|
|
29
29
|
return components.indexOf(comp) === -1;
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ const reducer = (state = initialState, action) => {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
case actions.ON_CHANGE:
|
|
37
|
-
return state.update('modifiedData', obj => {
|
|
37
|
+
return state.update('modifiedData', (obj) => {
|
|
38
38
|
const {
|
|
39
39
|
selectedContentTypeFriendlyName,
|
|
40
40
|
keys,
|
|
@@ -62,10 +62,10 @@ const reducer = (state = initialState, action) => {
|
|
|
62
62
|
|
|
63
63
|
return null;
|
|
64
64
|
})
|
|
65
|
-
.update('name', oldValue => {
|
|
65
|
+
.update('name', (oldValue) => {
|
|
66
66
|
return pluralize(snakeCase(oldValue), shouldPluralizeName(value));
|
|
67
67
|
})
|
|
68
|
-
.update('targetAttribute', oldValue => {
|
|
68
|
+
.update('targetAttribute', (oldValue) => {
|
|
69
69
|
if (['oneWay', 'manyWay'].includes(value)) {
|
|
70
70
|
return '-';
|
|
71
71
|
}
|
|
@@ -75,7 +75,7 @@ const reducer = (state = initialState, action) => {
|
|
|
75
75
|
shouldPluralizeTargetAttribute(value)
|
|
76
76
|
);
|
|
77
77
|
})
|
|
78
|
-
.update('targetColumnName', oldValue => {
|
|
78
|
+
.update('targetColumnName', (oldValue) => {
|
|
79
79
|
if (['oneWay', 'manyWay'].includes(value)) {
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
@@ -90,7 +90,7 @@ const reducer = (state = initialState, action) => {
|
|
|
90
90
|
|
|
91
91
|
return obj
|
|
92
92
|
.update('target', () => value)
|
|
93
|
-
.update('nature', currentNature => {
|
|
93
|
+
.update('nature', (currentNature) => {
|
|
94
94
|
if (targetContentTypeAllowedRelations === null) {
|
|
95
95
|
return currentNature;
|
|
96
96
|
}
|
|
@@ -149,11 +149,11 @@ const reducer = (state = initialState, action) => {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
return state.updateIn(['modifiedData', 'allowedTypes'], currentList => {
|
|
152
|
+
return state.updateIn(['modifiedData', 'allowedTypes'], (currentList) => {
|
|
153
153
|
let list = currentList || fromJS([]);
|
|
154
154
|
|
|
155
155
|
if (list.includes(action.name)) {
|
|
156
|
-
list = list.filter(v => v !== action.name);
|
|
156
|
+
list = list.filter((v) => v !== action.name);
|
|
157
157
|
|
|
158
158
|
if (list.size === 0) {
|
|
159
159
|
return null;
|
|
@@ -5,7 +5,7 @@ import { initialState } from './reducer';
|
|
|
5
5
|
/**
|
|
6
6
|
* Direct selector to the formModal state domain
|
|
7
7
|
*/
|
|
8
|
-
const formModalDomain = () => state => state.get(`${pluginId}_formModal`) || initialState;
|
|
8
|
+
const formModalDomain = () => (state) => state.get(`${pluginId}_formModal`) || initialState;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Other specific selectors
|
|
@@ -16,7 +16,7 @@ const formModalDomain = () => state => state.get(`${pluginId}_formModal`) || ini
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
const makeSelectFormModal = () =>
|
|
19
|
-
createSelector(formModalDomain(), substate => {
|
|
19
|
+
createSelector(formModalDomain(), (substate) => {
|
|
20
20
|
return substate;
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -7,17 +7,14 @@ const ALLOWED_KEYS = [
|
|
|
7
7
|
'header_info_category',
|
|
8
8
|
'header_info_name',
|
|
9
9
|
];
|
|
10
|
-
const createHeadersArray = obj => {
|
|
10
|
+
const createHeadersArray = (obj) => {
|
|
11
11
|
const array = Object.keys(obj).reduce((acc, current) => {
|
|
12
12
|
const splitted = current.split('_');
|
|
13
13
|
const currentKeys = splitted.filter((_, i) => i !== splitted.length - 1);
|
|
14
14
|
|
|
15
15
|
if (ALLOWED_KEYS.includes(currentKeys.join('_'))) {
|
|
16
16
|
const currentKeysIndex = parseInt(splitted[splitted.length - 1] - 1, 10);
|
|
17
|
-
const path = [
|
|
18
|
-
currentKeysIndex,
|
|
19
|
-
...currentKeys.filter(key => key !== 'header'),
|
|
20
|
-
];
|
|
17
|
+
const path = [currentKeysIndex, ...currentKeys.filter((key) => key !== 'header')];
|
|
21
18
|
|
|
22
19
|
let value = obj[current];
|
|
23
20
|
|
|
@@ -31,7 +28,7 @@ const createHeadersArray = obj => {
|
|
|
31
28
|
return acc;
|
|
32
29
|
}, []);
|
|
33
30
|
|
|
34
|
-
return array.filter(obj => obj.label !== null);
|
|
31
|
+
return array.filter((obj) => obj.label !== null);
|
|
35
32
|
};
|
|
36
33
|
|
|
37
34
|
export default createHeadersArray;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject } from 'lodash';
|
|
2
2
|
|
|
3
|
-
const createHeadersObjectFromArray = array => {
|
|
3
|
+
const createHeadersObjectFromArray = (array) => {
|
|
4
4
|
return array.reduce((acc, current, index) => {
|
|
5
5
|
const createHeaderObject = (obj, i, middle = '') =>
|
|
6
6
|
Object.keys(obj).reduce((acc1, current1) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import slugify from '@sindresorhus/slugify';
|
|
2
2
|
|
|
3
|
-
const nameToSlug = name => slugify(name, { separator: '-' });
|
|
3
|
+
const nameToSlug = (name) => slugify(name, { separator: '-' });
|
|
4
4
|
|
|
5
|
-
const createUid = name => {
|
|
5
|
+
const createUid = (name) => {
|
|
6
6
|
const modelName = nameToSlug(name);
|
|
7
7
|
const uid = `application::${modelName}.${modelName}`;
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-confusing-arrow */
|
|
2
2
|
|
|
3
|
-
const shouldPluralizeName = nature =>
|
|
3
|
+
const shouldPluralizeName = (nature) =>
|
|
4
4
|
['manyToMany', 'oneToMany', 'manyWay'].includes(nature) ? 2 : 1;
|
|
5
5
|
|
|
6
|
-
const shouldPluralizeTargetAttribute = nature =>
|
|
6
|
+
const shouldPluralizeTargetAttribute = (nature) =>
|
|
7
7
|
['manyToMany', 'manyToOne'].includes(nature) ? 2 : 1;
|
|
8
8
|
|
|
9
9
|
export { shouldPluralizeName, shouldPluralizeTargetAttribute };
|
|
@@ -37,7 +37,7 @@ function LeftMenu({ wait }) {
|
|
|
37
37
|
const { emitEvent, formatMessage } = useGlobalContext();
|
|
38
38
|
const { push } = useHistory();
|
|
39
39
|
const componentsData = sortBy(
|
|
40
|
-
Object.keys(componentsGroupedByCategory).map(category => ({
|
|
40
|
+
Object.keys(componentsGroupedByCategory).map((category) => ({
|
|
41
41
|
name: category,
|
|
42
42
|
title: category,
|
|
43
43
|
isEditable: isInDevelopmentMode,
|
|
@@ -67,21 +67,21 @@ function LeftMenu({ wait }) {
|
|
|
67
67
|
push({ search });
|
|
68
68
|
},
|
|
69
69
|
links: sortBy(
|
|
70
|
-
componentsGroupedByCategory[category].map(compo => ({
|
|
70
|
+
componentsGroupedByCategory[category].map((compo) => ({
|
|
71
71
|
name: compo.uid,
|
|
72
72
|
to: `/plugins/${pluginId}/component-categories/${category}/${compo.uid}`,
|
|
73
73
|
title: compo.schema.name,
|
|
74
74
|
})),
|
|
75
|
-
obj => obj.title
|
|
75
|
+
(obj) => obj.title
|
|
76
76
|
),
|
|
77
77
|
})),
|
|
78
|
-
obj => obj.title
|
|
78
|
+
(obj) => obj.title
|
|
79
79
|
);
|
|
80
80
|
|
|
81
81
|
const canOpenModalCreateCTorComponent = () => {
|
|
82
82
|
return (
|
|
83
|
-
!Object.keys(contentTypes).some(ct => contentTypes[ct].isTemporary === true) &&
|
|
84
|
-
!Object.keys(components).some(component => components[component].isTemporary === true)
|
|
83
|
+
!Object.keys(contentTypes).some((ct) => contentTypes[ct].isTemporary === true) &&
|
|
84
|
+
!Object.keys(components).some((component) => components[component].isTemporary === true)
|
|
85
85
|
);
|
|
86
86
|
};
|
|
87
87
|
|
|
@@ -113,8 +113,8 @@ function LeftMenu({ wait }) {
|
|
|
113
113
|
|
|
114
114
|
const displayedContentTypes = useMemo(() => {
|
|
115
115
|
return sortedContentTypesList
|
|
116
|
-
.filter(obj => obj.visible)
|
|
117
|
-
.map(obj => {
|
|
116
|
+
.filter((obj) => obj.visible)
|
|
117
|
+
.map((obj) => {
|
|
118
118
|
if (obj.plugin) {
|
|
119
119
|
return {
|
|
120
120
|
...obj,
|
|
@@ -158,7 +158,7 @@ function LeftMenu({ wait }) {
|
|
|
158
158
|
},
|
|
159
159
|
}
|
|
160
160
|
: null,
|
|
161
|
-
links: displayedContentTypes.filter(contentType => contentType.kind === 'collectionType'),
|
|
161
|
+
links: displayedContentTypes.filter((contentType) => contentType.kind === 'collectionType'),
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
name: 'singleTypes',
|
|
@@ -177,7 +177,7 @@ function LeftMenu({ wait }) {
|
|
|
177
177
|
},
|
|
178
178
|
}
|
|
179
179
|
: null,
|
|
180
|
-
links: displayedContentTypes.filter(singleType => singleType.kind === 'singleType'),
|
|
180
|
+
links: displayedContentTypes.filter((singleType) => singleType.kind === 'singleType'),
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
name: 'components',
|
|
@@ -202,7 +202,7 @@ function LeftMenu({ wait }) {
|
|
|
202
202
|
|
|
203
203
|
return (
|
|
204
204
|
<Wrapper className="col-md-3">
|
|
205
|
-
{data.map(list => {
|
|
205
|
+
{data.map((list) => {
|
|
206
206
|
return <LeftMenuList {...list} key={list.name} />;
|
|
207
207
|
})}
|
|
208
208
|
</Wrapper>
|