@akemona-org/strapi-plugin-content-type-builder 3.7.0
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/LICENSE +22 -0
- package/README.md +19 -0
- package/admin/src/InjectedComponents/ContentManager/EditSettingViewButton.js +76 -0
- package/admin/src/InjectedComponents/ContentManager/EditViewLink.js +44 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AllowedTypesSelect/MenuList.js +115 -0
- package/admin/src/components/AllowedTypesSelect/Text.js +26 -0
- package/admin/src/components/AllowedTypesSelect/index.js +55 -0
- package/admin/src/components/AttributeOption/Button.js +50 -0
- package/admin/src/components/AttributeOption/Card.js +26 -0
- package/admin/src/components/AttributeOption/index.js +127 -0
- package/admin/src/components/BooleanBox/CT.js +21 -0
- package/admin/src/components/BooleanBox/Enumeration.js +10 -0
- package/admin/src/components/BooleanBox/EnumerationWrapper.js +14 -0
- package/admin/src/components/BooleanBox/Label.js +9 -0
- package/admin/src/components/BooleanBox/ST.js +21 -0
- package/admin/src/components/BooleanBox/Wrapper.js +75 -0
- package/admin/src/components/BooleanBox/icons/CTSelected.js +136 -0
- package/admin/src/components/BooleanBox/icons/CTUnselected.js +136 -0
- package/admin/src/components/BooleanBox/icons/STSelected.js +80 -0
- package/admin/src/components/BooleanBox/icons/STUnselected.js +76 -0
- package/admin/src/components/BooleanBox/index.js +103 -0
- package/admin/src/components/CheckboxWithDescription/Wrapper.js +12 -0
- package/admin/src/components/CheckboxWithDescription/index.js +40 -0
- package/admin/src/components/ComponentCard/Close.js +12 -0
- package/admin/src/components/ComponentCard/Wrapper.js +84 -0
- package/admin/src/components/ComponentCard/index.js +62 -0
- package/admin/src/components/ComponentIconPicker/Cell.js +40 -0
- package/admin/src/components/ComponentIconPicker/CellRenderer.js +36 -0
- package/admin/src/components/ComponentIconPicker/Search.js +12 -0
- package/admin/src/components/ComponentIconPicker/SearchWrapper.js +34 -0
- package/admin/src/components/ComponentIconPicker/Wrapper.js +60 -0
- package/admin/src/components/ComponentIconPicker/index.js +143 -0
- package/admin/src/components/ComponentList/index.js +78 -0
- package/admin/src/components/ComponentSelect/Category.js +20 -0
- package/admin/src/components/ComponentSelect/CategoryName.js +11 -0
- package/admin/src/components/ComponentSelect/MenuList.js +110 -0
- package/admin/src/components/ComponentSelect/MultipleMenuList.js +271 -0
- package/admin/src/components/ComponentSelect/Value.js +83 -0
- package/admin/src/components/ComponentSelect/index.js +83 -0
- package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +5 -0
- package/admin/src/components/ComponentSelect/utils/hasSubArray.js +5 -0
- package/admin/src/components/CreatableSelect/index.js +58 -0
- package/admin/src/components/CustomCheckbox/StyledCustomCheckbox.js +25 -0
- package/admin/src/components/CustomCheckbox/index.js +71 -0
- package/admin/src/components/CustomLink/P.js +17 -0
- package/admin/src/components/CustomLink/StyledCustomLink.js +20 -0
- package/admin/src/components/CustomLink/index.js +31 -0
- package/admin/src/components/DynamicZoneList/ComponentButton.js +39 -0
- package/admin/src/components/DynamicZoneList/index.js +124 -0
- package/admin/src/components/HeaderModalNavContainer/index.js +25 -0
- package/admin/src/components/HeaderNavLink/Wrapper.js +21 -0
- package/admin/src/components/HeaderNavLink/index.js +50 -0
- package/admin/src/components/List/List.js +131 -0
- package/admin/src/components/List/index.js +295 -0
- package/admin/src/components/ListButton/index.js +9 -0
- package/admin/src/components/ListHeader/Title.js +19 -0
- package/admin/src/components/ListHeader/Wrapper.js +24 -0
- package/admin/src/components/ListHeader/index.js +37 -0
- package/admin/src/components/ListRow/Wrapper.js +76 -0
- package/admin/src/components/ListRow/index.js +334 -0
- package/admin/src/components/ModalHeader/ComponentIcon.js +21 -0
- package/admin/src/components/ModalHeader/ComponentInfos.js +22 -0
- package/admin/src/components/ModalHeader/ComponentInfosWrapper.js +9 -0
- package/admin/src/components/ModalHeader/DropdownInfos.js +50 -0
- package/admin/src/components/ModalHeader/Icon.js +26 -0
- package/admin/src/components/ModalHeader/IconWrapper.js +11 -0
- package/admin/src/components/ModalHeader/Item.js +19 -0
- package/admin/src/components/ModalHeader/Menu.js +8 -0
- package/admin/src/components/ModalHeader/Toggle.js +14 -0
- package/admin/src/components/ModalHeader/Wrapper.js +12 -0
- package/admin/src/components/ModalHeader/index.js +105 -0
- package/admin/src/components/RelationForm/Wrapper.js +9 -0
- package/admin/src/components/RelationForm/index.js +66 -0
- package/admin/src/components/RelationFormBox/Wrapper.js +34 -0
- package/admin/src/components/RelationFormBox/index.js +85 -0
- package/admin/src/components/RelationFormNaturePicker/Wrapper.js +53 -0
- package/admin/src/components/RelationFormNaturePicker/index.js +112 -0
- package/admin/src/components/RelationTargetPicker/Item.js +62 -0
- package/admin/src/components/RelationTargetPicker/Wrapper.js +89 -0
- package/admin/src/components/RelationTargetPicker/index.js +88 -0
- package/admin/src/components/SelectCheckbox/index.js +8 -0
- package/admin/src/components/SelectMenuSubUl/ToggleUl.js +23 -0
- package/admin/src/components/SelectMenuSubUl/index.js +23 -0
- package/admin/src/components/SelectMenuUl/index.js +66 -0
- package/admin/src/components/Td/index.js +37 -0
- package/admin/src/components/UpperFirst/index.js +14 -0
- package/admin/src/components/WrapperSelect/index.js +89 -0
- package/admin/src/containers/App/Wrapper.js +14 -0
- package/admin/src/containers/App/index.js +39 -0
- package/admin/src/containers/App/utils/icons.json +962 -0
- package/admin/src/containers/DataManagerProvider/constants.js +15 -0
- package/admin/src/containers/DataManagerProvider/index.js +610 -0
- package/admin/src/containers/DataManagerProvider/reducer.js +461 -0
- package/admin/src/containers/DataManagerProvider/selectors.js +25 -0
- package/admin/src/containers/DataManagerProvider/utils/cleanData.js +167 -0
- package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +8 -0
- package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +91 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +55 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +35 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +34 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +12 -0
- package/admin/src/containers/FormModal/CustomButton.js +12 -0
- package/admin/src/containers/FormModal/attributes/advancedForm.js +269 -0
- package/admin/src/containers/FormModal/attributes/attributeOptions.js +99 -0
- package/admin/src/containers/FormModal/attributes/baseForm.js +322 -0
- package/admin/src/containers/FormModal/attributes/commonBaseForm.js +7 -0
- package/admin/src/containers/FormModal/attributes/form.js +9 -0
- package/admin/src/containers/FormModal/attributes/index.js +4 -0
- package/admin/src/containers/FormModal/attributes/nameField.js +19 -0
- package/admin/src/containers/FormModal/attributes/types.js +309 -0
- package/admin/src/containers/FormModal/attributes/uiHelpers.js +11 -0
- package/admin/src/containers/FormModal/attributes/validation/common.js +151 -0
- package/admin/src/containers/FormModal/category/createCategorySchema.js +28 -0
- package/admin/src/containers/FormModal/category/form.js +27 -0
- package/admin/src/containers/FormModal/category/index.js +3 -0
- package/admin/src/containers/FormModal/category/regex.js +3 -0
- package/admin/src/containers/FormModal/component/componentField.js +25 -0
- package/admin/src/containers/FormModal/component/createComponentSchema.js +49 -0
- package/admin/src/containers/FormModal/component/form.js +67 -0
- package/admin/src/containers/FormModal/component/index.js +4 -0
- package/admin/src/containers/FormModal/constants.js +11 -0
- package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +44 -0
- package/admin/src/containers/FormModal/contentType/form.js +116 -0
- package/admin/src/containers/FormModal/contentType/index.js +2 -0
- package/admin/src/containers/FormModal/dynamicZone/form.js +45 -0
- package/admin/src/containers/FormModal/dynamicZone/index.js +2 -0
- package/admin/src/containers/FormModal/forms/index.js +164 -0
- package/admin/src/containers/FormModal/index.js +1552 -0
- package/admin/src/containers/FormModal/reducer.js +293 -0
- package/admin/src/containers/FormModal/selectors.js +24 -0
- package/admin/src/containers/FormModal/utils/canEditContentType.js +19 -0
- package/admin/src/containers/FormModal/utils/createHeadersArray.js +37 -0
- package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +27 -0
- package/admin/src/containers/FormModal/utils/createUid.js +17 -0
- package/admin/src/containers/FormModal/utils/getAttributesToDisplay.js +35 -0
- package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +25 -0
- package/admin/src/containers/FormModal/utils/getNextSearch.js +17 -0
- package/admin/src/containers/FormModal/utils/index.js +6 -0
- package/admin/src/containers/FormModal/utils/relations.js +9 -0
- package/admin/src/containers/FormModal/utils/staticData.js +43 -0
- package/admin/src/containers/Initializer/index.js +26 -0
- package/admin/src/containers/LeftMenu/Wrapper.js +14 -0
- package/admin/src/containers/LeftMenu/index.js +220 -0
- package/admin/src/containers/ListView/Wrapper.js +16 -0
- package/admin/src/containers/ListView/index.js +322 -0
- package/admin/src/containers/NotFoundPage/index.js +20 -0
- package/admin/src/containers/RecursivePath/index.js +22 -0
- package/admin/src/contexts/DataManagerContext.js +5 -0
- package/admin/src/contexts/ListViewContext.js +5 -0
- package/admin/src/hooks/useDataManager.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/icons/Curve.js +26 -0
- package/admin/src/icons/ManyToMany.js +98 -0
- package/admin/src/icons/ManyToOne.js +64 -0
- package/admin/src/icons/ManyWay.js +36 -0
- package/admin/src/icons/OneToMany.js +65 -0
- package/admin/src/icons/OneToOne.js +47 -0
- package/admin/src/icons/OneWay.js +38 -0
- package/admin/src/index.js +83 -0
- package/admin/src/lifecycles.js +13 -0
- package/admin/src/permissions.js +9 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +10 -0
- package/admin/src/translations/ar.json +48 -0
- package/admin/src/translations/cs.json +151 -0
- package/admin/src/translations/de.json +187 -0
- package/admin/src/translations/dk.json +181 -0
- package/admin/src/translations/en.json +188 -0
- package/admin/src/translations/es.json +188 -0
- package/admin/src/translations/fr.json +87 -0
- package/admin/src/translations/id.json +187 -0
- package/admin/src/translations/index.js +51 -0
- package/admin/src/translations/it.json +187 -0
- package/admin/src/translations/ja.json +50 -0
- package/admin/src/translations/ko.json +57 -0
- package/admin/src/translations/ms.json +179 -0
- package/admin/src/translations/nl.json +171 -0
- package/admin/src/translations/pl.json +152 -0
- package/admin/src/translations/pt-BR.json +51 -0
- package/admin/src/translations/pt.json +51 -0
- package/admin/src/translations/ru.json +188 -0
- package/admin/src/translations/sk.json +186 -0
- package/admin/src/translations/th.json +181 -0
- package/admin/src/translations/tr.json +51 -0
- package/admin/src/translations/uk.json +180 -0
- package/admin/src/translations/zh-Hans.json +188 -0
- package/admin/src/translations/zh.json +178 -0
- package/admin/src/utils/convertAttrObjToArray.js +7 -0
- package/admin/src/utils/formAPI.js +112 -0
- package/admin/src/utils/getAttributeDisplayedType.js +31 -0
- package/admin/src/utils/getComponents.js +31 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/makeSearch.js +15 -0
- package/admin/src/utils/makeUnique.js +3 -0
- package/config/functions/bootstrap.js +14 -0
- package/config/routes.json +144 -0
- package/controllers/Builder.js +7 -0
- package/controllers/ComponentCategories.js +43 -0
- package/controllers/Components.js +152 -0
- package/controllers/Connections.js +9 -0
- package/controllers/ContentTypes.js +143 -0
- package/controllers/validation/common.js +118 -0
- package/controllers/validation/component-category.js +21 -0
- package/controllers/validation/component.js +89 -0
- package/controllers/validation/content-type.js +161 -0
- package/controllers/validation/data-transform.js +32 -0
- package/controllers/validation/model-schema.js +91 -0
- package/controllers/validation/relations.js +56 -0
- package/controllers/validation/types.js +277 -0
- package/package.json +63 -0
- package/services/Builder.js +7 -0
- package/services/ComponentCategories.js +88 -0
- package/services/Components.js +103 -0
- package/services/ContentTypes.js +263 -0
- package/services/api-handler.js +158 -0
- package/services/constants.js +59 -0
- package/services/schema-builder/component-builder.js +137 -0
- package/services/schema-builder/content-type-builder.js +256 -0
- package/services/schema-builder/index.js +196 -0
- package/services/schema-builder/schema-handler.js +297 -0
- package/utils/attributes.js +154 -0
- package/utils/helpers.js +31 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { get } from 'lodash';
|
|
4
|
+
import { FormattedMessage } from 'react-intl';
|
|
5
|
+
import { AttributeIcon, IconLinks } from '@buffetjs/core';
|
|
6
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
|
+
import pluginId from '../../pluginId';
|
|
8
|
+
import useDataManager from '../../hooks/useDataManager';
|
|
9
|
+
import getAttributeDisplayedType from '../../utils/getAttributeDisplayedType';
|
|
10
|
+
import getTrad from '../../utils/getTrad';
|
|
11
|
+
import Curve from '../../icons/Curve';
|
|
12
|
+
import UpperFist from '../UpperFirst';
|
|
13
|
+
import Wrapper from './Wrapper';
|
|
14
|
+
|
|
15
|
+
function ListRow({
|
|
16
|
+
configurable,
|
|
17
|
+
name,
|
|
18
|
+
dzName,
|
|
19
|
+
nature,
|
|
20
|
+
onClick,
|
|
21
|
+
plugin,
|
|
22
|
+
target,
|
|
23
|
+
targetUid,
|
|
24
|
+
type,
|
|
25
|
+
mainTypeName,
|
|
26
|
+
editTarget,
|
|
27
|
+
firstLoopComponentName,
|
|
28
|
+
firstLoopComponentUid,
|
|
29
|
+
isFromDynamicZone,
|
|
30
|
+
repeatable,
|
|
31
|
+
secondLoopComponentName,
|
|
32
|
+
secondLoopComponentUid,
|
|
33
|
+
isNestedInDZComponent,
|
|
34
|
+
}) {
|
|
35
|
+
const { contentTypes, isInDevelopmentMode, modifiedData, removeAttribute } = useDataManager();
|
|
36
|
+
const isMorph = target === '*';
|
|
37
|
+
const ico = ['integer', 'biginteger', 'float', 'decimal'].includes(type) ? 'number' : type;
|
|
38
|
+
|
|
39
|
+
let readableType = type;
|
|
40
|
+
|
|
41
|
+
if (['integer', 'biginteger', 'float', 'decimal'].includes(type)) {
|
|
42
|
+
readableType = 'number';
|
|
43
|
+
} else if (['string'].includes(type)) {
|
|
44
|
+
readableType = 'text';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const contentTypeFriendlyName = get(contentTypes, [target, 'schema', 'name'], '');
|
|
48
|
+
const src = target ? 'relation' : ico;
|
|
49
|
+
|
|
50
|
+
const handleClick = () => {
|
|
51
|
+
if (isMorph) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (configurable !== false) {
|
|
56
|
+
const firstComponentCategory = get(
|
|
57
|
+
modifiedData,
|
|
58
|
+
['components', firstLoopComponentUid, 'category'],
|
|
59
|
+
null
|
|
60
|
+
);
|
|
61
|
+
const secondComponentCategory = get(
|
|
62
|
+
modifiedData,
|
|
63
|
+
['components', secondLoopComponentUid, 'category'],
|
|
64
|
+
null
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const attrType = nature ? 'relation' : type;
|
|
68
|
+
const icoType = getAttributeDisplayedType(attrType);
|
|
69
|
+
|
|
70
|
+
let firstHeaderObject = {
|
|
71
|
+
header_label_1: mainTypeName,
|
|
72
|
+
header_icon_name_1: icoType,
|
|
73
|
+
header_icon_isCustom_1: false,
|
|
74
|
+
header_info_category_1: null,
|
|
75
|
+
header_info_name_1: null,
|
|
76
|
+
};
|
|
77
|
+
let secondHeaderObject = {
|
|
78
|
+
header_label_2: name,
|
|
79
|
+
header_icon_name_2: null,
|
|
80
|
+
header_icon_isCustom_2: false,
|
|
81
|
+
header_info_category_2: null,
|
|
82
|
+
header_info_name_2: null,
|
|
83
|
+
};
|
|
84
|
+
let thirdHeaderObject = {
|
|
85
|
+
header_icon_name_3: 'component',
|
|
86
|
+
header_icon_isCustom_3: false,
|
|
87
|
+
header_info_category_3: null,
|
|
88
|
+
header_info_name_3: null,
|
|
89
|
+
};
|
|
90
|
+
let fourthHeaderObject = {
|
|
91
|
+
header_icon_name_4: null,
|
|
92
|
+
header_icon_isCustom_4: false,
|
|
93
|
+
header_info_category_4: null,
|
|
94
|
+
header_info_name_4: null,
|
|
95
|
+
};
|
|
96
|
+
let fifthHeaderObject = {
|
|
97
|
+
header_icon_name_5: null,
|
|
98
|
+
header_icon_isCustom_5: false,
|
|
99
|
+
header_info_category_5: null,
|
|
100
|
+
header_info_name_5: null,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (firstLoopComponentName) {
|
|
104
|
+
secondHeaderObject = {
|
|
105
|
+
header_label_2: firstLoopComponentName,
|
|
106
|
+
header_icon_name_2: 'component',
|
|
107
|
+
header_icon_isCustom_2: false,
|
|
108
|
+
header_info_category_2: firstComponentCategory,
|
|
109
|
+
header_info_name_2: firstLoopComponentName,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
thirdHeaderObject = {
|
|
113
|
+
...thirdHeaderObject,
|
|
114
|
+
header_label_3: name,
|
|
115
|
+
header_icon_name_3: null,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (secondLoopComponentUid) {
|
|
120
|
+
thirdHeaderObject = {
|
|
121
|
+
...thirdHeaderObject,
|
|
122
|
+
header_label_3: secondLoopComponentName,
|
|
123
|
+
header_icon_name_3: 'component',
|
|
124
|
+
header_info_category_3: secondComponentCategory,
|
|
125
|
+
header_info_name_3: secondLoopComponentName,
|
|
126
|
+
};
|
|
127
|
+
fourthHeaderObject = {
|
|
128
|
+
...fourthHeaderObject,
|
|
129
|
+
header_label_4: name,
|
|
130
|
+
header_icon_name_4: null,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (isFromDynamicZone || isNestedInDZComponent) {
|
|
135
|
+
secondHeaderObject = {
|
|
136
|
+
header_label_2: dzName,
|
|
137
|
+
header_icon_name_2: 'dynamiczone',
|
|
138
|
+
header_icon_isCustom_2: false,
|
|
139
|
+
header_info_name_2: null,
|
|
140
|
+
header_info_category_2: null,
|
|
141
|
+
};
|
|
142
|
+
thirdHeaderObject = {
|
|
143
|
+
header_icon_name_3: 'component',
|
|
144
|
+
header_label_3: firstLoopComponentName,
|
|
145
|
+
header_info_name_3: firstComponentCategory,
|
|
146
|
+
header_info_category_3: firstComponentCategory,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (!isNestedInDZComponent) {
|
|
150
|
+
fourthHeaderObject = {
|
|
151
|
+
header_icon_name_4: null,
|
|
152
|
+
header_icon_isCustom_4: false,
|
|
153
|
+
header_info_category_4: null,
|
|
154
|
+
header_label_4: name,
|
|
155
|
+
};
|
|
156
|
+
} else {
|
|
157
|
+
fourthHeaderObject = {
|
|
158
|
+
header_icon_name_4: 'components',
|
|
159
|
+
header_icon_isCustom_4: false,
|
|
160
|
+
header_info_category_4: secondComponentCategory,
|
|
161
|
+
header_info_name_4: secondLoopComponentName,
|
|
162
|
+
header_label_4: secondLoopComponentName,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
fifthHeaderObject = {
|
|
166
|
+
...fifthHeaderObject,
|
|
167
|
+
header_label_5: name,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
onClick(
|
|
173
|
+
// Tells where the attribute is located in the main modifiedData object : contentType, component or components
|
|
174
|
+
editTarget,
|
|
175
|
+
// main data type uid
|
|
176
|
+
secondLoopComponentUid || firstLoopComponentUid || targetUid,
|
|
177
|
+
// Name of the attribute
|
|
178
|
+
name,
|
|
179
|
+
// Type of the attribute
|
|
180
|
+
attrType,
|
|
181
|
+
firstHeaderObject,
|
|
182
|
+
secondHeaderObject,
|
|
183
|
+
thirdHeaderObject,
|
|
184
|
+
fourthHeaderObject,
|
|
185
|
+
fifthHeaderObject
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
let loopNumber;
|
|
190
|
+
|
|
191
|
+
if (secondLoopComponentUid && firstLoopComponentUid) {
|
|
192
|
+
loopNumber = 2;
|
|
193
|
+
} else if (firstLoopComponentUid) {
|
|
194
|
+
loopNumber = 1;
|
|
195
|
+
} else {
|
|
196
|
+
loopNumber = 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<Wrapper
|
|
201
|
+
onClick={handleClick}
|
|
202
|
+
className={[target ? 'relation-row' : '', configurable ? 'clickable' : '']}
|
|
203
|
+
loopNumber={loopNumber}
|
|
204
|
+
>
|
|
205
|
+
<td>
|
|
206
|
+
<AttributeIcon key={src} type={src} />
|
|
207
|
+
<Curve fill={isFromDynamicZone ? '#AED4FB' : '#f3f4f4'} />
|
|
208
|
+
</td>
|
|
209
|
+
<td style={{ fontWeight: 600 }}>
|
|
210
|
+
<p>{name}</p>
|
|
211
|
+
</td>
|
|
212
|
+
<td>
|
|
213
|
+
{target ? (
|
|
214
|
+
<div>
|
|
215
|
+
<FormattedMessage
|
|
216
|
+
id={`${pluginId}.modelPage.attribute.${
|
|
217
|
+
isMorph ? 'relation-polymorphic' : 'relationWith'
|
|
218
|
+
}`}
|
|
219
|
+
/>
|
|
220
|
+
|
|
221
|
+
<FormattedMessage id={`${pluginId}.from`}>
|
|
222
|
+
{msg => (
|
|
223
|
+
<span style={{ fontStyle: 'italic' }}>
|
|
224
|
+
<UpperFist content={contentTypeFriendlyName} />
|
|
225
|
+
|
|
226
|
+
{plugin && `(${msg}: ${plugin})`}
|
|
227
|
+
</span>
|
|
228
|
+
)}
|
|
229
|
+
</FormattedMessage>
|
|
230
|
+
</div>
|
|
231
|
+
) : (
|
|
232
|
+
<>
|
|
233
|
+
<FormattedMessage id={`${pluginId}.attribute.${readableType}`} defaultMessage={type} />
|
|
234
|
+
|
|
235
|
+
{repeatable && <FormattedMessage id={getTrad('component.repeatable')} />}
|
|
236
|
+
</>
|
|
237
|
+
)}
|
|
238
|
+
</td>
|
|
239
|
+
<td className="button-container">
|
|
240
|
+
{isInDevelopmentMode && (
|
|
241
|
+
<>
|
|
242
|
+
{configurable ? (
|
|
243
|
+
<>
|
|
244
|
+
{!isMorph ? (
|
|
245
|
+
<IconLinks
|
|
246
|
+
links={[
|
|
247
|
+
{
|
|
248
|
+
icon: <FontAwesomeIcon icon="pencil-alt" />,
|
|
249
|
+
onClick: () => handleClick(),
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
icon: <FontAwesomeIcon icon="trash-alt" />,
|
|
253
|
+
onClick: e => {
|
|
254
|
+
e.stopPropagation();
|
|
255
|
+
removeAttribute(
|
|
256
|
+
editTarget,
|
|
257
|
+
name,
|
|
258
|
+
secondLoopComponentUid || firstLoopComponentUid || ''
|
|
259
|
+
);
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
]}
|
|
263
|
+
/>
|
|
264
|
+
) : (
|
|
265
|
+
<IconLinks
|
|
266
|
+
links={[
|
|
267
|
+
{
|
|
268
|
+
icon: <FontAwesomeIcon icon="trash-alt" />,
|
|
269
|
+
onClick: e => {
|
|
270
|
+
e.stopPropagation();
|
|
271
|
+
removeAttribute(
|
|
272
|
+
editTarget,
|
|
273
|
+
name,
|
|
274
|
+
secondLoopComponentUid || firstLoopComponentUid || ''
|
|
275
|
+
);
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
]}
|
|
279
|
+
/>
|
|
280
|
+
)}
|
|
281
|
+
</>
|
|
282
|
+
) : (
|
|
283
|
+
<button type="button">
|
|
284
|
+
<FontAwesomeIcon icon="lock" />
|
|
285
|
+
</button>
|
|
286
|
+
)}
|
|
287
|
+
</>
|
|
288
|
+
)}
|
|
289
|
+
</td>
|
|
290
|
+
</Wrapper>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
ListRow.defaultProps = {
|
|
295
|
+
configurable: true,
|
|
296
|
+
dzName: null,
|
|
297
|
+
firstLoopComponentName: null,
|
|
298
|
+
firstLoopComponentUid: null,
|
|
299
|
+
isFromDynamicZone: false,
|
|
300
|
+
isNestedInDZComponent: false,
|
|
301
|
+
nature: null,
|
|
302
|
+
onClick: () => {},
|
|
303
|
+
plugin: null,
|
|
304
|
+
repeatable: false,
|
|
305
|
+
secondLoopComponentName: null,
|
|
306
|
+
secondLoopComponentUid: null,
|
|
307
|
+
target: null,
|
|
308
|
+
targetUid: null,
|
|
309
|
+
type: null,
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
ListRow.propTypes = {
|
|
313
|
+
configurable: PropTypes.bool,
|
|
314
|
+
dzName: PropTypes.string,
|
|
315
|
+
editTarget: PropTypes.string.isRequired,
|
|
316
|
+
firstLoopComponentName: PropTypes.string,
|
|
317
|
+
firstLoopComponentUid: PropTypes.string,
|
|
318
|
+
isFromDynamicZone: PropTypes.bool,
|
|
319
|
+
isNestedInDZComponent: PropTypes.bool,
|
|
320
|
+
mainTypeName: PropTypes.string.isRequired,
|
|
321
|
+
name: PropTypes.string.isRequired,
|
|
322
|
+
nature: PropTypes.string,
|
|
323
|
+
onClick: PropTypes.func,
|
|
324
|
+
plugin: PropTypes.string,
|
|
325
|
+
repeatable: PropTypes.bool,
|
|
326
|
+
secondLoopComponentName: PropTypes.string,
|
|
327
|
+
secondLoopComponentUid: PropTypes.string,
|
|
328
|
+
target: PropTypes.string,
|
|
329
|
+
targetUid: PropTypes.string,
|
|
330
|
+
type: PropTypes.string,
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export default memo(ListRow);
|
|
334
|
+
export { ListRow };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const ComponentIcon = styled.div`
|
|
4
|
+
margin: 12px 0;
|
|
5
|
+
margin-right: 20px;
|
|
6
|
+
display: flex;
|
|
7
|
+
width: 35px;
|
|
8
|
+
height: 35px;
|
|
9
|
+
align-items: center;
|
|
10
|
+
text-align: center;
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
background-color: #aed4fb;
|
|
13
|
+
|
|
14
|
+
svg {
|
|
15
|
+
margin: auto;
|
|
16
|
+
font-size: 16px;
|
|
17
|
+
color: #007eff;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export default ComponentIcon;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import UpperFirst from '../UpperFirst';
|
|
4
|
+
import ComponentInfosWrapper from './ComponentInfosWrapper';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable react/jsx-one-expression-per-line */
|
|
7
|
+
|
|
8
|
+
const ComponentInfos = ({ category, name }) => {
|
|
9
|
+
return (
|
|
10
|
+
<ComponentInfosWrapper>
|
|
11
|
+
(<UpperFirst content={category} /> —
|
|
12
|
+
<UpperFirst content={name} />)
|
|
13
|
+
</ComponentInfosWrapper>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
ComponentInfos.propTypes = {
|
|
18
|
+
category: PropTypes.string.isRequired,
|
|
19
|
+
name: PropTypes.string.isRequired,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default ComponentInfos;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import UpperFirst from '../UpperFirst';
|
|
4
|
+
import Icon from './Icon';
|
|
5
|
+
import Item from './Item';
|
|
6
|
+
import Menu from './Menu';
|
|
7
|
+
import Toggle from './Toggle';
|
|
8
|
+
import Wrapper from './Wrapper';
|
|
9
|
+
|
|
10
|
+
/* eslint-disable react/no-array-index-key */
|
|
11
|
+
|
|
12
|
+
const DropdownInfos = ({ headers, shouldDisplaySecondHeader }) => {
|
|
13
|
+
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
14
|
+
|
|
15
|
+
const toggle = () => setDropdownOpen(prevState => !prevState);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Wrapper isOpen={dropdownOpen} toggle={toggle} style={{ margin: 'auto 0' }}>
|
|
19
|
+
<Toggle>...</Toggle>
|
|
20
|
+
<Menu style={{ top: '8px' }}>
|
|
21
|
+
{headers.map((header, index) => {
|
|
22
|
+
if (!shouldDisplaySecondHeader && index === 1) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Item key={index}>
|
|
28
|
+
<Icon type={header.icon.name} />
|
|
29
|
+
<span>
|
|
30
|
+
<UpperFirst content={header.label} />
|
|
31
|
+
</span>
|
|
32
|
+
</Item>
|
|
33
|
+
);
|
|
34
|
+
})}
|
|
35
|
+
</Menu>
|
|
36
|
+
</Wrapper>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
DropdownInfos.defaultProps = {
|
|
41
|
+
headers: [],
|
|
42
|
+
shouldDisplaySecondHeader: false,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
DropdownInfos.propTypes = {
|
|
46
|
+
headers: PropTypes.array,
|
|
47
|
+
shouldDisplaySecondHeader: PropTypes.bool,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default DropdownInfos;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AttributeIcon } from '@buffetjs/core';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
const Icon = ({ type, style }) => {
|
|
6
|
+
const icoName = type === 'collectionType' ? 'contentType' : type;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<AttributeIcon
|
|
10
|
+
type={icoName || 'dynamiczone'}
|
|
11
|
+
style={{ ...style, margin: 'auto 20px auto 0' }}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
Icon.defaultProps = {
|
|
17
|
+
style: null,
|
|
18
|
+
type: 'dynamiczone',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Icon.propTypes = {
|
|
22
|
+
style: PropTypes.object,
|
|
23
|
+
type: PropTypes.string,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default Icon;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { DropdownItem } from 'reactstrap';
|
|
3
|
+
|
|
4
|
+
const Item = styled(DropdownItem)`
|
|
5
|
+
display: flex;
|
|
6
|
+
padding-left: 10px;
|
|
7
|
+
padding-right: 10px;
|
|
8
|
+
color: #3b3b3b;
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
font-size: 14px;
|
|
11
|
+
&:active,
|
|
12
|
+
&:focus,
|
|
13
|
+
&:hover {
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
outline: 0;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export default Item;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { DropdownToggle } from 'reactstrap';
|
|
3
|
+
|
|
4
|
+
const Toggle = styled(DropdownToggle)`
|
|
5
|
+
height: 12px;
|
|
6
|
+
background: transparent;
|
|
7
|
+
border: 0;
|
|
8
|
+
margin-top: -14px;
|
|
9
|
+
color: #3b3b3b;
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
font-size: 14px;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export default Toggle;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { HeaderModalTitle } from 'strapi-helper-plugin';
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
7
|
+
import UpperFirst from '../UpperFirst';
|
|
8
|
+
import ComponentIcon from './ComponentIcon';
|
|
9
|
+
import ComponentInfos from './ComponentInfos';
|
|
10
|
+
import Icon from './Icon';
|
|
11
|
+
import IconWrapper from './IconWrapper';
|
|
12
|
+
import DropdownInfos from './DropdownInfos';
|
|
13
|
+
|
|
14
|
+
/* eslint-disable react/no-array-index-key */
|
|
15
|
+
|
|
16
|
+
const ModalHeader = ({ headerId, headers }) => {
|
|
17
|
+
const shouldDisplayDropDown = headers.length > 3;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<section>
|
|
21
|
+
<HeaderModalTitle style={{ textTransform: 'none' }}>
|
|
22
|
+
{headerId && (
|
|
23
|
+
<>
|
|
24
|
+
<Icon type={get(headers, [0, 'icon', 'name'], '')} />
|
|
25
|
+
<FormattedMessage
|
|
26
|
+
id={headerId}
|
|
27
|
+
values={{ name: get(headers, [0, 'label'], '') }}
|
|
28
|
+
/>
|
|
29
|
+
</>
|
|
30
|
+
)}
|
|
31
|
+
{!headerId &&
|
|
32
|
+
headers.map((header, index) => {
|
|
33
|
+
const iconName = get(header, ['icon', 'name'], '');
|
|
34
|
+
const iconType = iconName === null ? '' : iconName;
|
|
35
|
+
const icon = get(header, ['icon', 'isCustom'], false) ? (
|
|
36
|
+
<ComponentIcon isSelected>
|
|
37
|
+
<FontAwesomeIcon icon={iconType} />
|
|
38
|
+
</ComponentIcon>
|
|
39
|
+
) : (
|
|
40
|
+
<Icon type={iconType} />
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (shouldDisplayDropDown && index === 1) {
|
|
44
|
+
return (
|
|
45
|
+
<Fragment key={index}>
|
|
46
|
+
<IconWrapper>
|
|
47
|
+
<FontAwesomeIcon icon="chevron-right" />
|
|
48
|
+
</IconWrapper>
|
|
49
|
+
<DropdownInfos
|
|
50
|
+
headers={[headers[1], headers[2]]}
|
|
51
|
+
shouldDisplaySecondHeader={headers.length > 4}
|
|
52
|
+
/>
|
|
53
|
+
</Fragment>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (shouldDisplayDropDown && index === 2 && headers.length > 4) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (index === 0) {
|
|
62
|
+
return (
|
|
63
|
+
<Fragment key={index}>
|
|
64
|
+
{icon}
|
|
65
|
+
<span>
|
|
66
|
+
<UpperFirst content={get(header, ['label'], '')} />
|
|
67
|
+
</span>
|
|
68
|
+
</Fragment>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Fragment key={index}>
|
|
74
|
+
<IconWrapper>
|
|
75
|
+
<FontAwesomeIcon icon="chevron-right" />
|
|
76
|
+
</IconWrapper>
|
|
77
|
+
|
|
78
|
+
<span>
|
|
79
|
+
<UpperFirst content={get(header, ['label'], '')} />
|
|
80
|
+
</span>
|
|
81
|
+
{header.info.category && (
|
|
82
|
+
<ComponentInfos
|
|
83
|
+
category={header.info.category}
|
|
84
|
+
name={header.info.name}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
</Fragment>
|
|
88
|
+
);
|
|
89
|
+
})}
|
|
90
|
+
</HeaderModalTitle>
|
|
91
|
+
</section>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
ModalHeader.defaultProps = {
|
|
96
|
+
headerId: '',
|
|
97
|
+
headers: [],
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
ModalHeader.propTypes = {
|
|
101
|
+
headerId: PropTypes.string,
|
|
102
|
+
headers: PropTypes.array,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default ModalHeader;
|