strapi-plugin-navigation 2.1.0-beta.2 → 2.2.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/README.md +20 -10
- package/admin/src/components/AdditionalFieldInput/index.d.ts +5 -0
- package/admin/src/components/AdditionalFieldInput/index.js +71 -0
- package/admin/src/components/AdditionalFieldInput/types.d.ts +14 -0
- package/admin/src/components/AdditionalFieldInput/types.js +3 -0
- package/admin/src/components/DragButton/index.d.ts +4 -0
- package/admin/src/components/DragButton/index.js +61 -0
- package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +1 -1
- package/admin/src/components/Item/ItemCardHeader/icons.d.ts +5 -0
- package/admin/src/components/Item/ItemCardHeader/icons.js +12 -0
- package/admin/src/components/Item/ItemCardHeader/index.d.ts +13 -10
- package/admin/src/components/Item/ItemCardHeader/index.js +17 -38
- package/admin/src/components/Item/index.js +6 -6
- package/admin/src/components/RestartAlert/index.d.ts +1 -1
- package/admin/src/components/TextArrayInput/index.d.ts +14 -0
- package/admin/src/components/TextArrayInput/index.js +45 -0
- package/admin/src/hooks/useAllContentTypes.d.ts +1 -4
- package/admin/src/hooks/useAllContentTypes.js +3 -7
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +9 -0
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +51 -0
- package/admin/src/hooks/useNavigationConfig.d.ts +1 -1
- package/admin/src/hooks/useNavigationConfig.js +6 -6
- package/admin/src/hooks/useNavigationManager.d.ts +7 -0
- package/admin/src/hooks/useNavigationManager.js +41 -0
- package/admin/src/pages/DataManagerProvider/index.d.ts +1 -1
- package/admin/src/pages/DataManagerProvider/index.js +46 -10
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +12 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +112 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +12 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +20 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +11 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +105 -0
- package/admin/src/pages/SettingsPage/index.d.ts +2 -1
- package/admin/src/pages/SettingsPage/index.js +111 -75
- package/admin/src/pages/SettingsPage/types.d.ts +32 -0
- package/admin/src/pages/SettingsPage/types.js +3 -0
- package/admin/src/pages/SettingsPage/utils/form.d.ts +18 -0
- package/admin/src/pages/SettingsPage/utils/form.js +34 -0
- package/admin/src/pages/SettingsPage/utils/functions.d.ts +2 -2
- package/admin/src/pages/SettingsPage/utils/functions.js +1 -1
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +3 -9
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +2 -47
- package/admin/src/pages/View/components/NavigationHeader/index.js +11 -6
- package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +3 -49
- package/admin/src/pages/View/components/NavigationItemForm/index.js +219 -152
- package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +90 -0
- package/admin/src/pages/View/components/NavigationItemForm/types.js +3 -0
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +24 -43
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +84 -48
- package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +4 -1
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +32 -7
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +4 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +11 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.js +139 -0
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.js +34 -0
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.js +53 -0
- package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +24 -0
- package/admin/src/pages/View/components/NavigationManager/Footer/index.js +13 -0
- package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +20 -0
- package/admin/src/pages/View/components/NavigationManager/Form/index.js +103 -0
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.js +59 -0
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +10 -0
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.js +62 -0
- package/admin/src/pages/View/components/NavigationManager/index.d.ts +11 -0
- package/admin/src/pages/View/components/NavigationManager/index.js +190 -0
- package/admin/src/pages/View/components/NavigationManager/types.d.ts +40 -0
- package/admin/src/pages/View/components/NavigationManager/types.js +3 -0
- package/admin/src/pages/View/index.d.ts +1 -1
- package/admin/src/pages/View/index.js +11 -9
- package/admin/src/pages/View/utils/parsers.d.ts +7 -1
- package/admin/src/pages/View/utils/parsers.js +21 -10
- package/admin/src/translations/en.json +68 -0
- package/admin/src/translations/index.d.ts +2 -1
- package/admin/src/translations/index.js +1 -1
- package/admin/src/utils/api.d.ts +8 -7
- package/admin/src/utils/api.js +6 -41
- package/admin/src/utils/enums.d.ts +25 -0
- package/admin/src/utils/enums.js +30 -0
- package/admin/src/utils/functions.d.ts +16 -0
- package/admin/src/utils/functions.js +46 -0
- package/admin/src/utils/index.d.ts +3 -4
- package/admin/src/utils/index.js +16 -24
- package/package.json +6 -7
- package/server/config/index.js +6 -4
- package/server/config/setupStrategy.js +13 -1
- package/server/content-types/index.d.ts +5 -25
- package/server/content-types/navigation/index.d.ts +0 -7
- package/server/content-types/navigation/index.js +0 -2
- package/server/content-types/navigation/schema.js +1 -1
- package/server/content-types/navigation-item/index.d.ts +5 -13
- package/server/content-types/navigation-item/index.js +0 -2
- package/server/content-types/navigation-item/schema.d.ts +5 -0
- package/server/content-types/navigation-item/schema.js +5 -0
- package/server/content-types/navigations-items-related/index.d.ts +0 -5
- package/server/content-types/navigations-items-related/index.js +0 -2
- package/server/controllers/admin.js +67 -14
- package/server/controllers/client.js +43 -19
- package/server/graphql/types/navigation-item.d.ts +2 -1
- package/server/graphql/types/navigation-item.js +26 -2
- package/server/i18n/serviceEnhancers.d.ts +2 -1
- package/server/i18n/serviceEnhancers.js +45 -6
- package/server/i18n/types.d.ts +6 -0
- package/server/index.d.ts +5 -25
- package/server/navigation/setupStrategy.js +3 -1
- package/server/routes/admin.js +10 -0
- package/server/services/admin.js +104 -37
- package/server/services/client.js +64 -21
- package/server/services/common.js +26 -7
- package/server/utils/constant.d.ts +0 -3
- package/server/utils/constant.js +1 -2
- package/server/utils/functions.d.ts +13 -12
- package/server/utils/functions.js +62 -22
- package/strapi-server.d.ts +5 -25
- package/tsconfig.tsbuildinfo +1 -1
- package/types/config.d.ts +6 -2
- package/types/contentTypes.d.ts +22 -1
- package/types/controllers.d.ts +21 -8
- package/types/services.d.ts +20 -5
- package/types/utils.d.ts +10 -1
- package/types/utils.js +18 -3
- package/utils/InvalidParamNavigationError.js +0 -3
- package/admin/src/pages/View/utils/enums.d.ts +0 -9
- package/admin/src/pages/View/utils/enums.js +0 -12
- package/admin/src/utils/getTrad.d.ts +0 -3
- package/admin/src/utils/getTrad.js +0 -9
- package/server/content-types/navigation/lifecycle.d.ts +0 -9
- package/server/content-types/navigation/lifecycle.js +0 -10
- package/server/content-types/navigation-item/lifecycle.d.ts +0 -16
- package/server/content-types/navigation-item/lifecycle.js +0 -31
- package/server/content-types/navigations-items-related/lifecycle.d.ts +0 -8
- package/server/content-types/navigations-items-related/lifecycle.js +0 -22
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateNavigationStructure = exports.isRelationPublished = exports.isRelationCorrect = exports.usedContentTypes = exports.extractRelatedItemLabel = exports.prepareItemToViewPayload = exports.transformItemToViewPayload = exports.transformToRESTPayload = exports.transformItemToRESTPayload = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
|
-
const
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
7
|
const transformItemToRESTPayload = (item, parent = undefined, master = undefined, config = {}, parentAttachedToMenu = true) => {
|
|
8
|
-
const { id, title, type =
|
|
9
|
-
const isExternal = type ===
|
|
10
|
-
const isWrapper = type ===
|
|
8
|
+
const { id, title, type = utils_1.navigationItemType.INTERNAL, updated = false, removed = false, uiRouterKey, menuAttached, path, externalPath, related, relatedType, order, audience = [], items = [], collapsed, isSingle, additionalFields = {}, } = item;
|
|
9
|
+
const isExternal = type === utils_1.navigationItemType.EXTERNAL;
|
|
10
|
+
const isWrapper = type === utils_1.navigationItemType.WRAPPER;
|
|
11
11
|
const { contentTypes = [] } = config;
|
|
12
12
|
const parsedRelated = Number(related);
|
|
13
13
|
const relatedId = isExternal || isWrapper || isNaN(parsedRelated) ? related?.value || related : parsedRelated;
|
|
@@ -26,8 +26,11 @@ const transformItemToRESTPayload = (item, parent = undefined, master = undefined
|
|
|
26
26
|
order,
|
|
27
27
|
uiRouterKey,
|
|
28
28
|
collapsed,
|
|
29
|
+
additionalFields,
|
|
29
30
|
menuAttached: itemAttachedToMenu,
|
|
30
|
-
audience: audience.map((audienceItem) => (0, lodash_1.isObject)(audienceItem)
|
|
31
|
+
audience: audience.map((audienceItem) => (0, lodash_1.isObject)(audienceItem)
|
|
32
|
+
? audienceItem.id || audienceItem.value
|
|
33
|
+
: audienceItem),
|
|
31
34
|
path: isExternal ? undefined : path,
|
|
32
35
|
externalPath: isExternal ? externalPath : undefined,
|
|
33
36
|
related: isExternal || isWrapper
|
|
@@ -75,7 +78,7 @@ const linkRelations = (item, config) => {
|
|
|
75
78
|
},
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
|
-
if ((type !==
|
|
81
|
+
if ((type !== utils_1.navigationItemType.INTERNAL) || !related || ((0, lodash_1.isObject)(related) && (0, lodash_1.isEmpty)(related))) {
|
|
79
82
|
return {
|
|
80
83
|
...item,
|
|
81
84
|
...relation,
|
|
@@ -149,6 +152,7 @@ const transformItemToViewPayload = (payload, items = [], config) => {
|
|
|
149
152
|
}
|
|
150
153
|
return {
|
|
151
154
|
...item,
|
|
155
|
+
items: (0, exports.transformItemToViewPayload)(payload, item.items, config),
|
|
152
156
|
};
|
|
153
157
|
});
|
|
154
158
|
return reOrderItems(updatedRootLevel);
|
|
@@ -201,17 +205,24 @@ const transformItemToViewPayload = (payload, items = [], config) => {
|
|
|
201
205
|
return reOrderItems(updatedLevel);
|
|
202
206
|
};
|
|
203
207
|
exports.transformItemToViewPayload = transformItemToViewPayload;
|
|
204
|
-
const prepareItemToViewPayload = (items = [], viewParentId = null, config = {}) => reOrderItems(items.map((item, n) => {
|
|
208
|
+
const prepareItemToViewPayload = ({ items = [], viewParentId = null, config = {}, structureIdPrefix = '' }) => reOrderItems(items.map((item, n) => {
|
|
205
209
|
const viewId = (0, uuid_1.v4)();
|
|
210
|
+
const structureId = structureIdPrefix ? `${structureIdPrefix}.${n}` : n.toString();
|
|
206
211
|
return {
|
|
207
212
|
...linkRelations({
|
|
208
213
|
viewId,
|
|
209
214
|
viewParentId,
|
|
210
215
|
...item,
|
|
211
216
|
order: item.order || (n + 1),
|
|
217
|
+
structureId,
|
|
212
218
|
updated: item.updated || (0, lodash_1.isNil)(item.order),
|
|
213
219
|
}, config),
|
|
214
|
-
items: (0, exports.prepareItemToViewPayload)(
|
|
220
|
+
items: (0, exports.prepareItemToViewPayload)({
|
|
221
|
+
config,
|
|
222
|
+
items: item.items,
|
|
223
|
+
structureIdPrefix: structureId,
|
|
224
|
+
viewId,
|
|
225
|
+
}),
|
|
215
226
|
};
|
|
216
227
|
}));
|
|
217
228
|
exports.prepareItemToViewPayload = prepareItemToViewPayload;
|
|
@@ -236,14 +247,14 @@ const usedContentTypes = (items = []) => items.flatMap((item) => {
|
|
|
236
247
|
exports.usedContentTypes = usedContentTypes;
|
|
237
248
|
const isRelationCorrect = ({ related, type }) => {
|
|
238
249
|
const isRelationDefined = !(0, lodash_1.isNil)(related);
|
|
239
|
-
return type !==
|
|
250
|
+
return type !== utils_1.navigationItemType.INTERNAL || (type === utils_1.navigationItemType.INTERNAL && isRelationDefined);
|
|
240
251
|
};
|
|
241
252
|
exports.isRelationCorrect = isRelationCorrect;
|
|
242
253
|
const isRelationPublished = ({ relatedRef, relatedType = {}, type, isCollection }) => {
|
|
243
254
|
if (isCollection) {
|
|
244
255
|
return relatedType.available || relatedRef.available;
|
|
245
256
|
}
|
|
246
|
-
if ((type ===
|
|
257
|
+
if ((type === utils_1.navigationItemType.INTERNAL)) {
|
|
247
258
|
const isHandledByPublshFlow = relatedRef ? 'published_at' in relatedRef : false;
|
|
248
259
|
if (isHandledByPublshFlow) {
|
|
249
260
|
return (0, lodash_1.get)(relatedRef, 'published_at', true);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"header.title": "Navigation",
|
|
4
4
|
"header.description": "Define your portal navigation",
|
|
5
5
|
"header.action.newItem": "New Item",
|
|
6
|
+
"header.action.manage": "Manage",
|
|
6
7
|
"header.action.collapseAll": "Collapse All",
|
|
7
8
|
"header.action.expandAll": "Expand All",
|
|
8
9
|
"submit.cta.cancel": "Cancel",
|
|
@@ -34,6 +35,11 @@
|
|
|
34
35
|
"popup.item.form.relatedType.label": "Content Type",
|
|
35
36
|
"popup.item.form.relatedType.placeholder": "Select content type...",
|
|
36
37
|
"popup.item.form.relatedType.empty": "There are no content types to select",
|
|
38
|
+
"popup.item.form.i18n.locale.label": "Copy details from",
|
|
39
|
+
"popup.item.form.i18n.locale.placeholder": "locale",
|
|
40
|
+
"popup.item.form.i18n.locale.button": "Copy",
|
|
41
|
+
"popup.item.form.i18n.locale.error.generic": "Unable to copy item",
|
|
42
|
+
"popup.item.form.i18n.locale.error.unavailable": "Locale version unavailable",
|
|
37
43
|
"popup.item.form.related.label": "Entity",
|
|
38
44
|
"popup.item.form.related.empty": "There are no more entities of \"{ contentTypeName }\" to select",
|
|
39
45
|
"popup.item.form.button.create": "Create item",
|
|
@@ -42,16 +48,45 @@
|
|
|
42
48
|
"popup.item.form.button.remove": "Remove",
|
|
43
49
|
"popup.item.form.button.save": "Save",
|
|
44
50
|
"popup.item.form.button.cancel": "Cancel",
|
|
51
|
+
"popup.navigation.form.name.label": "Name",
|
|
52
|
+
"popup.navigation.form.name.placeholder": "Navigations's name",
|
|
53
|
+
"popup.navigation.form.visible.label": "Visibility",
|
|
54
|
+
"popup.navigation.form.validation.name.alreadyUsed": "Name is already used",
|
|
55
|
+
"popup.navigation.form.validation.name.required": "Name is required",
|
|
56
|
+
"popup.navigation.form.validation.name.tooShort": "Name is too short",
|
|
57
|
+
"popup.navigation.form.validation.visible.required": "Visibility is required",
|
|
58
|
+
"popup.navigation.manage.table.hasSelected": "{count} entries selected",
|
|
59
|
+
"popup.navigation.manage.table.id": "Id",
|
|
60
|
+
"popup.navigation.manage.table.name": "Name",
|
|
61
|
+
"popup.navigation.manage.table.locale": "Locale versions",
|
|
62
|
+
"popup.navigation.manage.table.visibility": "Visibility",
|
|
63
|
+
"popup.navigation.manage.button.goBack": "Go back",
|
|
64
|
+
"popup.navigation.manage.button.cancel": "Cancel",
|
|
65
|
+
"popup.navigation.manage.button.delete": "Delete",
|
|
66
|
+
"popup.navigation.manage.button.save": "Save",
|
|
67
|
+
"popup.navigation.manage.button.edit": "Edit",
|
|
68
|
+
"popup.navigation.manage.button.create": "Create",
|
|
69
|
+
"popup.navigation.manage.delete.header": "Following navigations will be removed:",
|
|
70
|
+
"popup.navigation.manage.header.LIST": "All navigations",
|
|
71
|
+
"popup.navigation.manage.header.CREATE": "New navigation",
|
|
72
|
+
"popup.navigation.manage.header.DELETE": "Deleting",
|
|
73
|
+
"popup.navigation.manage.header.ERROR": "Error",
|
|
74
|
+
"popup.navigation.manage.header.EDIT": "Editing \"{name}\"",
|
|
75
|
+
"popup.navigation.manage.error.message": "An error happened :(",
|
|
76
|
+
"popup.navigation.manage.navigation.visible": "visible",
|
|
77
|
+
"popup.navigation.manage.navigation.hidden": "hidden",
|
|
45
78
|
"notification.navigation.submit": "Navigation changes has been saved",
|
|
46
79
|
"notification.navigation.error": "Duplicate path: { path } in parent: { parentTitle } for { errorTitles } items",
|
|
47
80
|
"notification.navigation.item.relation": "Entity relation does not exist!",
|
|
48
81
|
"notification.navigation.item.relation.status.draft": "draft",
|
|
49
82
|
"notification.navigation.item.relation.status.published": "published",
|
|
50
83
|
"notification.error": "Error while processing request.",
|
|
84
|
+
"notification.error.customField.type": "Unsupported type of custom field",
|
|
51
85
|
"pages.main.search.placeholder": "Type to start searching...",
|
|
52
86
|
"pages.main.header.localization.select.placeholder": "Select locale",
|
|
53
87
|
"pages.settings.general.title": "General settings",
|
|
54
88
|
"pages.settings.additional.title": "Additional settings",
|
|
89
|
+
"pages.settings.customFields.title": "Custom fields settings",
|
|
55
90
|
"pages.settings.nameField.title": "Content types settings",
|
|
56
91
|
"pages.settings.restoring.title": "Restoring",
|
|
57
92
|
"pages.settings.section.title": "Navigation Plugin",
|
|
@@ -106,6 +141,10 @@
|
|
|
106
141
|
"pages.settings.form.populate.placeholder": "Select at least one or leave empty to disable populating relation fields",
|
|
107
142
|
"pages.settings.form.populate.hint": "Selected relation fields will be populated inside API responses",
|
|
108
143
|
"pages.settings.form.populate.empty": "This content type doesn't have any relation fields",
|
|
144
|
+
"pages.settings.form.pathDefaultFields.label": "Path default fields",
|
|
145
|
+
"pages.settings.form.pathDefaultFields.placeholder": "Select at least one or leave it empty to disable populating path field with attributes value",
|
|
146
|
+
"pages.settings.form.pathDefaultFields.hint": "Value of selected attribute will be a default value for internal path",
|
|
147
|
+
"pages.settings.form.pathDefaultFields.empty": "This content type doesn't have any suitable attributes",
|
|
109
148
|
"pages.settings.form.contentTypesSettings.label": "Content types",
|
|
110
149
|
"pages.settings.form.contentTypesSettings.tooltip": "Custom configuration per content type",
|
|
111
150
|
"pages.settings.form.contentTypesSettings.initializationWarning.title": "Warning",
|
|
@@ -113,6 +152,35 @@
|
|
|
113
152
|
"pages.view.actions.i18nCopyItems.confirmation.header": "Confirmation",
|
|
114
153
|
"pages.view.actions.i18nCopyItems.confirmation.confirm": "Copy",
|
|
115
154
|
"pages.view.actions.i18nCopyItems.confirmation.content": "Do you want to copy navigations items?",
|
|
155
|
+
"pages.settings.form.customFields.table.confirmation.header": "Removing custom field",
|
|
156
|
+
"pages.settings.form.customFields.table.confirmation.message": "This action will cause removing all custom fields values from navigation items.",
|
|
157
|
+
"pages.settings.form.customFields.table.confirmation.confirm": "Continue",
|
|
158
|
+
"pages.settings.form.customFields.table.confirmation.error": "An error ocurred while removing custom field",
|
|
159
|
+
"pages.settings.form.customFields.table.header.name": "Name",
|
|
160
|
+
"pages.settings.form.customFields.table.header.label": "Label",
|
|
161
|
+
"pages.settings.form.customFields.table.header.type": "Type",
|
|
162
|
+
"pages.settings.form.customFields.table.header.required": "Required",
|
|
163
|
+
"pages.settings.form.customFields.table.footer": "Create new custom field",
|
|
164
|
+
"pages.settings.form.customFields.table.edit": "Edit custom field",
|
|
165
|
+
"pages.settings.form.customFields.table.enable": "Enable custom field",
|
|
166
|
+
"pages.settings.form.customFields.table.disable": "Disable custom field",
|
|
167
|
+
"pages.settings.form.customFields.table.remove": "Remove custom field",
|
|
168
|
+
"pages.settings.form.customFields.table.required": "required",
|
|
169
|
+
"pages.settings.form.customFields.table.notRequired": "not required",
|
|
170
|
+
"pages.settings.form.customFields.popup.header.edit": "Edit custom field",
|
|
171
|
+
"pages.settings.form.customFields.popup.header.new": "Add new custom field",
|
|
172
|
+
"pages.settings.form.customFields.popup.name.label": "Custom field name",
|
|
173
|
+
"pages.settings.form.customFields.popup.name.placeholder": "example_name",
|
|
174
|
+
"pages.settings.form.customFields.popup.name.description": "Name of the custom field must be unique",
|
|
175
|
+
"pages.settings.form.customFields.popup.label.label": "Custom field label",
|
|
176
|
+
"pages.settings.form.customFields.popup.label.placeholder": "Example label",
|
|
177
|
+
"pages.settings.form.customFields.popup.label.description": "This label will be displayed on navigation item form",
|
|
178
|
+
"pages.settings.form.customFields.popup.type.label": "Custom field type",
|
|
179
|
+
"pages.settings.form.customFields.popup.required.label": "Require field",
|
|
180
|
+
"pages.settings.form.customFields.popup.required.description": "Enabling this field will not change already exiting navigation items",
|
|
181
|
+
"pages.settings.form.customFields.popup.options.label": "Options for select input",
|
|
182
|
+
"pages.settings.form.customFields.popup.options.description": "Enabling this field will not change already exiting navigation items",
|
|
183
|
+
"pages.settings.form.customFields.popup.multi.label": "Enable multiple options input",
|
|
116
184
|
"components.navigationItem.action.newItem": "Add nested item",
|
|
117
185
|
"components.navigationItem.badge.removed": "Removed",
|
|
118
186
|
"components.navigationItem.badge.draft": "Draft",
|
|
@@ -13,7 +13,7 @@ const trads = {
|
|
|
13
13
|
};
|
|
14
14
|
const getTradId = (msg) => `${pluginId_1.default}.${msg}`;
|
|
15
15
|
exports.getTradId = getTradId;
|
|
16
|
-
const getTrad = (msg) => ({ id: (0, exports.getTradId)(msg) });
|
|
16
|
+
const getTrad = (msg, defaultMessage) => ({ id: (0, exports.getTradId)(msg), defaultMessage: defaultMessage || (0, exports.getTradId)(msg) });
|
|
17
17
|
exports.getTrad = getTrad;
|
|
18
18
|
exports.default = trads;
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/admin/src/utils/api.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
import { NavigationPluginConfig } from '../../../types';
|
|
2
|
+
export declare const fetchNavigationConfig: () => any;
|
|
3
|
+
export declare const updateNavigationConfig: ({ body }: {
|
|
4
|
+
body: NavigationPluginConfig;
|
|
5
|
+
}) => any;
|
|
6
|
+
export declare const restoreNavigationConfig: () => any;
|
|
7
|
+
export declare const fetchAllContentTypes: () => Promise<any>;
|
|
8
|
+
export declare const restartStrapi: () => any;
|
|
8
9
|
//# sourceMappingURL=api.d.ts.map
|
package/admin/src/utils/api.js
CHANGED
|
@@ -5,51 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.restartStrapi = exports.fetchAllContentTypes = exports.restoreNavigationConfig = exports.updateNavigationConfig = exports.fetchNavigationConfig = void 0;
|
|
7
7
|
const helper_plugin_1 = require("@strapi/helper-plugin");
|
|
8
|
+
const fp_1 = require("lodash/fp");
|
|
8
9
|
const pluginId_1 = __importDefault(require("../pluginId"));
|
|
9
|
-
const fetchNavigationConfig =
|
|
10
|
-
try {
|
|
11
|
-
const data = await (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/config`, { method: 'GET' });
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
toggleNotification({
|
|
16
|
-
type: 'warning',
|
|
17
|
-
message: { id: 'notification.error' },
|
|
18
|
-
});
|
|
19
|
-
return { err };
|
|
20
|
-
}
|
|
21
|
-
};
|
|
10
|
+
const fetchNavigationConfig = () => (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/config`, { method: 'GET' });
|
|
22
11
|
exports.fetchNavigationConfig = fetchNavigationConfig;
|
|
23
|
-
const updateNavigationConfig =
|
|
12
|
+
const updateNavigationConfig = ({ body }) => (0, helper_plugin_1.request)(`/${pluginId_1.default}/config`, { method: 'PUT', body }, true);
|
|
24
13
|
exports.updateNavigationConfig = updateNavigationConfig;
|
|
25
|
-
const restoreNavigationConfig =
|
|
14
|
+
const restoreNavigationConfig = () => (0, helper_plugin_1.request)(`/${pluginId_1.default}/config`, { method: 'DELETE' }, true);
|
|
26
15
|
exports.restoreNavigationConfig = restoreNavigationConfig;
|
|
27
|
-
const fetchAllContentTypes = async () => {
|
|
28
|
-
try {
|
|
29
|
-
const { data } = await (0, helper_plugin_1.request)('/content-manager/content-types');
|
|
30
|
-
return { ...data };
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
toggleNotification({
|
|
34
|
-
type: 'warning',
|
|
35
|
-
message: { id: 'notification.error' },
|
|
36
|
-
});
|
|
37
|
-
return { err };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
16
|
+
const fetchAllContentTypes = async () => (0, helper_plugin_1.request)('/content-manager/content-types', { method: 'GET' }).then((0, fp_1.prop)("data"));
|
|
40
17
|
exports.fetchAllContentTypes = fetchAllContentTypes;
|
|
41
|
-
const restartStrapi =
|
|
42
|
-
try {
|
|
43
|
-
const { data } = await (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/restart`);
|
|
44
|
-
return data;
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
toggleNotification({
|
|
48
|
-
type: 'warning',
|
|
49
|
-
message: { id: 'notification.error' },
|
|
50
|
-
});
|
|
51
|
-
return { err };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
18
|
+
const restartStrapi = () => (0, helper_plugin_1.request)(`/${pluginId_1.default}/settings/restart`);
|
|
54
19
|
exports.restartStrapi = restartStrapi;
|
|
55
20
|
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const navigationItemType: {
|
|
2
|
+
INTERNAL: string;
|
|
3
|
+
EXTERNAL: string;
|
|
4
|
+
WRAPPER: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const navigationItemAdditionalFields: {
|
|
7
|
+
AUDIENCE: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const ItemTypes: {
|
|
10
|
+
NAVIGATION_ITEM: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const ResourceState: {
|
|
13
|
+
RESOLVED: string;
|
|
14
|
+
LOADING: string;
|
|
15
|
+
ERROR: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const resolvedResourceFor: <T = unknown>(value: T) => {
|
|
18
|
+
type: string;
|
|
19
|
+
value: T;
|
|
20
|
+
};
|
|
21
|
+
export declare const errorStatusResourceFor: (errors: Array<Error>) => {
|
|
22
|
+
type: string;
|
|
23
|
+
errors: Error[];
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorStatusResourceFor = exports.resolvedResourceFor = exports.ResourceState = exports.ItemTypes = exports.navigationItemAdditionalFields = exports.navigationItemType = void 0;
|
|
4
|
+
exports.navigationItemType = {
|
|
5
|
+
INTERNAL: "INTERNAL",
|
|
6
|
+
EXTERNAL: "EXTERNAL",
|
|
7
|
+
WRAPPER: "WRAPPER",
|
|
8
|
+
};
|
|
9
|
+
exports.navigationItemAdditionalFields = {
|
|
10
|
+
AUDIENCE: 'audience',
|
|
11
|
+
};
|
|
12
|
+
exports.ItemTypes = {
|
|
13
|
+
NAVIGATION_ITEM: 'navigationItem'
|
|
14
|
+
};
|
|
15
|
+
exports.ResourceState = {
|
|
16
|
+
RESOLVED: 'RESOLVED',
|
|
17
|
+
LOADING: 'LOADING',
|
|
18
|
+
ERROR: 'ERROR',
|
|
19
|
+
};
|
|
20
|
+
const resolvedResourceFor = (value) => ({
|
|
21
|
+
type: exports.ResourceState.RESOLVED,
|
|
22
|
+
value,
|
|
23
|
+
});
|
|
24
|
+
exports.resolvedResourceFor = resolvedResourceFor;
|
|
25
|
+
const errorStatusResourceFor = (errors) => ({
|
|
26
|
+
type: exports.ResourceState.ERROR,
|
|
27
|
+
errors,
|
|
28
|
+
});
|
|
29
|
+
exports.errorStatusResourceFor = errorStatusResourceFor;
|
|
30
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NavigationItemAdditionalField, NavigationItemAdditionalFieldValues, ToBeFixed } from '../../../types';
|
|
2
|
+
declare type MessageInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage?: string;
|
|
5
|
+
props?: Record<string, ToBeFixed>;
|
|
6
|
+
} | string;
|
|
7
|
+
declare type PrepareNewValueForRecord = (uid: string, current: Record<string, string[] | undefined>, value: string[]) => Record<string, string[] | undefined>;
|
|
8
|
+
export declare const getMessage: (input: MessageInput, defaultMessage?: string, inPluginScope?: boolean) => string;
|
|
9
|
+
export declare const getDefaultCustomFields: (args: {
|
|
10
|
+
additionalFields: NavigationItemAdditionalField[];
|
|
11
|
+
customFieldsValues: NavigationItemAdditionalFieldValues;
|
|
12
|
+
defaultCustomFieldsValues: NavigationItemAdditionalFieldValues;
|
|
13
|
+
}) => NavigationItemAdditionalFieldValues;
|
|
14
|
+
export declare const prepareNewValueForRecord: PrepareNewValueForRecord;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prepareNewValueForRecord = exports.getDefaultCustomFields = exports.getMessage = void 0;
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const form_1 = require("../pages/View/components/NavigationItemForm/utils/form");
|
|
10
|
+
const pluginId_1 = __importDefault(require("../pluginId"));
|
|
11
|
+
const getMessage = (input, defaultMessage = '', inPluginScope = true) => {
|
|
12
|
+
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
13
|
+
let formattedId = '';
|
|
14
|
+
if (typeof input === 'string') {
|
|
15
|
+
formattedId = input;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
formattedId = input.id.toString() || formattedId;
|
|
19
|
+
}
|
|
20
|
+
return formatMessage({
|
|
21
|
+
id: `${inPluginScope ? pluginId_1.default : 'app.components'}.${formattedId}`,
|
|
22
|
+
defaultMessage,
|
|
23
|
+
}, typeof input === 'string' ? undefined : input?.props);
|
|
24
|
+
};
|
|
25
|
+
exports.getMessage = getMessage;
|
|
26
|
+
const getDefaultCustomFields = (args) => {
|
|
27
|
+
return args.additionalFields.reduce((acc, additionalField) => {
|
|
28
|
+
if (typeof additionalField === 'string') {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const value = form_1.defaultValues.additionalFields[additionalField.type];
|
|
33
|
+
return {
|
|
34
|
+
...acc,
|
|
35
|
+
[additionalField.name]: (0, lodash_1.get)(args.customFieldsValues, additionalField.name, value),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}, {});
|
|
39
|
+
};
|
|
40
|
+
exports.getDefaultCustomFields = getDefaultCustomFields;
|
|
41
|
+
const prepareNewValueForRecord = (uid, current, value) => ({
|
|
42
|
+
...current,
|
|
43
|
+
[uid]: value && !(0, lodash_1.isEmpty)(value) ? [...value] : undefined,
|
|
44
|
+
});
|
|
45
|
+
exports.prepareNewValueForRecord = prepareNewValueForRecord;
|
|
46
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
export * from './functions';
|
|
2
|
+
export * from './api';
|
|
3
|
+
export * from './enums';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
package/admin/src/utils/index.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const react_intl_1 = require("react-intl");
|
|
8
|
-
const lodash_1 = require("lodash");
|
|
9
|
-
const pluginId_1 = __importDefault(require("../pluginId"));
|
|
10
|
-
const getMessage = (input, defaultMessage = '', inPluginScope = true) => {
|
|
11
|
-
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
12
|
-
let formattedId = '';
|
|
13
|
-
if ((0, lodash_1.isString)(input)) {
|
|
14
|
-
formattedId = input;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
formattedId = input?.id;
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
7
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports
|
|
26
|
-
NAVIGATION_ITEM: 'navigationItem'
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
15
|
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./functions"), exports);
|
|
18
|
+
__exportStar(require("./api"), exports);
|
|
19
|
+
__exportStar(require("./enums"), exports);
|
|
28
20
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-navigation",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Strapi - Navigation plugin",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"name": "navigation",
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"
|
|
19
|
-
"uuid": "^8.3.0",
|
|
17
|
+
"@sindresorhus/slugify": "1.1.0",
|
|
18
|
+
"@strapi/utils": "^4.3.2",
|
|
20
19
|
"lodash": "^4.17.11",
|
|
21
20
|
"pluralize": "^8.0.0",
|
|
22
21
|
"react": "^16.9.0",
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
"reactstrap": "8.4.1",
|
|
29
28
|
"redux-saga": "^0.16.0",
|
|
30
29
|
"request": "^2.83.0",
|
|
31
|
-
"
|
|
30
|
+
"uuid": "^8.3.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {},
|
|
34
33
|
"peerDependencies": {
|
|
@@ -57,8 +56,8 @@
|
|
|
57
56
|
}
|
|
58
57
|
],
|
|
59
58
|
"engines": {
|
|
60
|
-
"node": ">=
|
|
61
|
-
"npm": ">=
|
|
59
|
+
"node": ">=14.19.3 <=17.x.x",
|
|
60
|
+
"npm": ">=7.x.x"
|
|
62
61
|
},
|
|
63
62
|
"nodemonConfig": {
|
|
64
63
|
"ignore": [
|
package/server/config/index.js
CHANGED
|
@@ -18,15 +18,17 @@ __exportStar(require("./setupStrategy"), exports);
|
|
|
18
18
|
const config = {
|
|
19
19
|
default: {
|
|
20
20
|
additionalFields: [],
|
|
21
|
+
allowedLevels: 2,
|
|
21
22
|
contentTypes: [],
|
|
22
23
|
contentTypesNameFields: {},
|
|
23
24
|
contentTypesPopulate: {},
|
|
24
|
-
allowedLevels: 2,
|
|
25
|
-
i18nEnabled: false,
|
|
26
|
-
pruneObsoleteI18nNavigations: false,
|
|
27
25
|
gql: {
|
|
28
|
-
navigationItemRelated: []
|
|
26
|
+
navigationItemRelated: [],
|
|
29
27
|
},
|
|
28
|
+
i18nEnabled: false,
|
|
29
|
+
pathDefaultFields: {},
|
|
30
|
+
pruneObsoleteI18nNavigations: false,
|
|
31
|
+
slugify: {},
|
|
30
32
|
},
|
|
31
33
|
};
|
|
32
34
|
exports.default = config;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configSetupStrategy = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
4
5
|
const types_1 = require("../../types");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
5
7
|
const configSetupStrategy = async ({ strapi }) => {
|
|
6
8
|
const pluginStore = strapi.store({
|
|
7
9
|
type: "plugin",
|
|
@@ -21,9 +23,12 @@ const configSetupStrategy = async ({ strapi }) => {
|
|
|
21
23
|
allowedLevels: getWithFallback("allowedLevels"),
|
|
22
24
|
gql: getWithFallback("gql"),
|
|
23
25
|
i18nEnabled: hasI18nPlugin && getWithFallback("i18nEnabled"),
|
|
26
|
+
slugify: (0, lodash_1.pick)(getWithFallback("slugify"), validSlugifyFields),
|
|
24
27
|
pruneObsoleteI18nNavigations: false,
|
|
28
|
+
pathDefaultFields: getWithFallback("pathDefaultFields"),
|
|
25
29
|
};
|
|
26
|
-
|
|
30
|
+
(0, utils_1.validateAdditionalFields)(config.additionalFields);
|
|
31
|
+
await pluginStore.set({
|
|
27
32
|
key: "config",
|
|
28
33
|
value: config,
|
|
29
34
|
});
|
|
@@ -35,4 +40,11 @@ const getWithFallbackFactory = (config, fallback) => (key) => {
|
|
|
35
40
|
(0, types_1.assertNotEmpty)(value, new Error(`[Navigation] Config "${key}" is undefined`));
|
|
36
41
|
return value;
|
|
37
42
|
};
|
|
43
|
+
const validSlugifyFields = [
|
|
44
|
+
"separator",
|
|
45
|
+
"lowercase",
|
|
46
|
+
"decamelize",
|
|
47
|
+
"customReplacements",
|
|
48
|
+
"preserveLeadingUnderscore",
|
|
49
|
+
];
|
|
38
50
|
//# sourceMappingURL=setupStrategy.js.map
|
|
@@ -25,13 +25,6 @@ declare const _default: {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
navigation: {
|
|
28
|
-
lifecycle: {
|
|
29
|
-
renderType: {
|
|
30
|
-
FLAT: string;
|
|
31
|
-
TREE: string;
|
|
32
|
-
RFR: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
28
|
schema: {
|
|
36
29
|
collectionName: string;
|
|
37
30
|
info: {
|
|
@@ -87,19 +80,6 @@ declare const _default: {
|
|
|
87
80
|
};
|
|
88
81
|
};
|
|
89
82
|
"navigation-item": {
|
|
90
|
-
lifecycle: {
|
|
91
|
-
type: {
|
|
92
|
-
INTERNAL: string;
|
|
93
|
-
EXTERNAL: string;
|
|
94
|
-
WRAPPER: string;
|
|
95
|
-
};
|
|
96
|
-
additionalFields: {
|
|
97
|
-
AUDIENCE: string;
|
|
98
|
-
};
|
|
99
|
-
lifecycles: {
|
|
100
|
-
afterFind(results: any): void;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
83
|
schema: {
|
|
104
84
|
collectionName: string;
|
|
105
85
|
info: {
|
|
@@ -193,15 +173,15 @@ declare const _default: {
|
|
|
193
173
|
relation: string;
|
|
194
174
|
target: string;
|
|
195
175
|
};
|
|
176
|
+
additionalFields: {
|
|
177
|
+
type: string;
|
|
178
|
+
require: boolean;
|
|
179
|
+
default: {};
|
|
180
|
+
};
|
|
196
181
|
};
|
|
197
182
|
};
|
|
198
183
|
};
|
|
199
184
|
"navigations-items-related": {
|
|
200
|
-
lifecycle: {
|
|
201
|
-
lifecycles: {
|
|
202
|
-
afterFind(results: any): void;
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
185
|
schema: {
|
|
206
186
|
collectionName: string;
|
|
207
187
|
info: {
|