strapi-plugin-navigation 2.0.13 → 2.1.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/README.md +105 -27
- package/admin/src/components/Alert/styles.d.ts +2 -0
- package/admin/src/components/Alert/styles.js +10 -4
- package/admin/src/components/CollapseButton/index.d.ts +7 -0
- package/admin/src/components/CollapseButton/index.js +21 -22
- package/admin/src/components/ConfirmationDialog/index.d.ts +28 -0
- package/admin/src/components/ConfirmationDialog/index.js +32 -54
- package/admin/src/components/EmptyView/index.d.ts +3 -0
- package/admin/src/components/EmptyView/index.js +9 -7
- package/admin/src/components/Item/ItemCardBadge/index.d.ts +3 -0
- package/admin/src/components/Item/ItemCardBadge/index.js +11 -7
- package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +3 -0
- package/admin/src/components/Item/ItemCardHeader/Wrapper.js +10 -6
- package/admin/src/components/Item/ItemCardHeader/index.d.ts +12 -0
- package/admin/src/components/Item/ItemCardHeader/index.js +33 -52
- package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts +2 -0
- package/admin/src/components/Item/ItemCardRemovedOverlay/index.js +10 -4
- package/admin/src/components/Item/Wrapper.d.ts +3 -0
- package/admin/src/components/Item/Wrapper.js +10 -6
- package/admin/src/components/Item/index.d.ts +31 -0
- package/admin/src/components/Item/index.js +163 -242
- package/admin/src/components/NavigationItemList/Wrapper.d.ts +3 -0
- package/admin/src/components/NavigationItemList/Wrapper.js +9 -5
- package/admin/src/components/NavigationItemList/index.d.ts +35 -0
- package/admin/src/components/NavigationItemList/index.js +28 -66
- package/admin/src/components/RestartAlert/index.d.ts +3 -0
- package/admin/src/components/RestartAlert/index.js +10 -5
- package/admin/src/components/Search/index.d.ts +6 -0
- package/admin/src/components/Search/index.js +57 -46
- package/admin/src/components/icons/navigation.d.ts +6 -0
- package/admin/src/components/icons/navigation.js +11 -13
- package/admin/src/contexts/DataManagerContext.d.ts +3 -0
- package/admin/src/contexts/DataManagerContext.js +6 -5
- package/admin/src/hooks/useAllContentTypes.d.ts +6 -0
- package/admin/src/hooks/useAllContentTypes.js +10 -11
- package/admin/src/hooks/useDataManager.d.ts +3 -0
- package/admin/src/hooks/useDataManager.js +10 -6
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +9 -0
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +51 -0
- package/admin/src/hooks/useNavigationConfig.d.ts +10 -0
- package/admin/src/hooks/useNavigationConfig.js +52 -56
- package/admin/src/hooks/useNavigationManager.d.ts +7 -0
- package/admin/src/hooks/useNavigationManager.js +41 -0
- package/admin/src/index.d.ts +14 -0
- package/admin/src/index.js +92 -76
- package/admin/src/pages/App/index.d.ts +3 -0
- package/admin/src/pages/App/index.js +43 -31
- package/admin/src/pages/DataManagerProvider/actions.d.ts +19 -0
- package/admin/src/pages/DataManagerProvider/actions.js +22 -26
- package/admin/src/pages/DataManagerProvider/index.d.ts +12 -0
- package/admin/src/pages/DataManagerProvider/index.js +316 -298
- package/admin/src/pages/DataManagerProvider/init.d.ts +3 -0
- package/admin/src/pages/DataManagerProvider/init.js +5 -3
- package/admin/src/pages/DataManagerProvider/reducer.d.ts +19 -0
- package/admin/src/pages/DataManagerProvider/reducer.js +119 -121
- package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +24 -0
- package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +88 -0
- package/admin/src/pages/SettingsPage/index.d.ts +3 -0
- package/admin/src/pages/SettingsPage/index.js +242 -335
- package/admin/src/pages/SettingsPage/utils/functions.d.ts +5 -0
- package/admin/src/pages/SettingsPage/utils/functions.js +3 -8
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +14 -0
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +15 -0
- package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts +6 -0
- package/admin/src/pages/View/components/NavigationContentHeader/index.js +13 -17
- package/admin/src/pages/View/components/NavigationHeader/index.d.ts +12 -0
- package/admin/src/pages/View/components/NavigationHeader/index.js +79 -65
- package/admin/src/pages/View/components/NavigationHeader/styles.d.ts +2 -0
- package/admin/src/pages/View/components/NavigationHeader/styles.js +10 -5
- package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +57 -0
- package/admin/src/pages/View/components/NavigationItemForm/index.js +416 -453
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +45 -0
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +84 -52
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts +23 -0
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +24 -34
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts +4 -0
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +16 -16
- package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +30 -0
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +85 -108
- package/admin/src/pages/View/components/NavigationManager/Create/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/Create/index.js +57 -0
- package/admin/src/pages/View/components/NavigationManager/Delete/index.d.ts +8 -0
- package/admin/src/pages/View/components/NavigationManager/Delete/index.js +28 -0
- package/admin/src/pages/View/components/NavigationManager/Edit/index.d.ts +8 -0
- package/admin/src/pages/View/components/NavigationManager/Edit/index.js +54 -0
- package/admin/src/pages/View/components/NavigationManager/Error/index.d.ts +8 -0
- package/admin/src/pages/View/components/NavigationManager/Error/index.js +53 -0
- package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +19 -0
- package/admin/src/pages/View/components/NavigationManager/Form/index.js +98 -0
- package/admin/src/pages/View/components/NavigationManager/List/index.d.ts +8 -0
- package/admin/src/pages/View/components/NavigationManager/List/index.js +138 -0
- package/admin/src/pages/View/components/NavigationManager/index.d.ts +10 -0
- package/admin/src/pages/View/components/NavigationManager/index.js +189 -0
- package/admin/src/pages/View/components/NavigationManager/types.d.ts +53 -0
- package/admin/src/pages/View/components/NavigationManager/types.js +3 -0
- package/admin/src/pages/View/index.d.ts +4 -0
- package/admin/src/pages/View/index.js +231 -304
- package/admin/src/pages/View/utils/enums.d.ts +9 -0
- package/admin/src/pages/View/utils/enums.js +11 -8
- package/admin/src/pages/View/utils/form.d.ts +2 -0
- package/admin/src/pages/View/utils/form.js +15 -12
- package/admin/src/pages/View/utils/index.d.ts +2 -0
- package/admin/src/pages/View/utils/index.js +11 -3
- package/admin/src/pages/View/utils/parsers.d.ts +49 -0
- package/admin/src/pages/View/utils/parsers.js +239 -278
- package/admin/src/permissions.d.ts +12 -0
- package/admin/src/permissions.js +11 -7
- package/admin/src/pluginId.d.ts +3 -0
- package/admin/src/pluginId.js +2 -2
- package/admin/src/translations/en.json +157 -104
- package/admin/src/translations/fr.json +44 -44
- package/admin/src/translations/index.d.ts +12 -0
- package/admin/src/translations/index.js +17 -11
- package/admin/src/utils/api.d.ts +8 -0
- package/admin/src/utils/api.js +54 -50
- package/admin/src/utils/getTrad.d.ts +3 -0
- package/admin/src/utils/getTrad.js +9 -5
- package/admin/src/utils/index.d.ts +18 -0
- package/admin/src/utils/index.js +36 -15
- package/package.json +20 -19
- package/permissions.d.ts +9 -0
- package/permissions.js +5 -4
- package/server/bootstrap/index.d.ts +4 -0
- package/server/bootstrap/index.js +41 -0
- package/server/config/index.d.ts +5 -0
- package/server/config/index.js +33 -9
- package/server/config/setupStrategy.d.ts +3 -0
- package/server/config/setupStrategy.js +38 -0
- package/server/content-types/audience/index.d.ts +27 -0
- package/server/content-types/audience/index.js +9 -8
- package/server/content-types/audience/schema.d.ts +25 -0
- package/server/content-types/audience/schema.js +26 -0
- package/server/content-types/index.d.ts +255 -0
- package/server/content-types/index.js +15 -12
- package/server/content-types/navigation/index.d.ts +64 -0
- package/server/content-types/navigation/index.js +11 -8
- package/server/content-types/navigation/lifecycle.d.ts +9 -0
- package/server/content-types/navigation/lifecycle.js +8 -12
- package/server/content-types/navigation/schema.d.ts +55 -0
- package/server/content-types/navigation/schema.js +56 -0
- package/server/content-types/navigation-item/index.d.ts +112 -0
- package/server/content-types/navigation-item/index.js +11 -8
- package/server/content-types/navigation-item/lifecycle.d.ts +16 -0
- package/server/content-types/navigation-item/lifecycle.js +28 -32
- package/server/content-types/navigation-item/schema.d.ts +97 -0
- package/server/content-types/navigation-item/schema.js +102 -0
- package/server/content-types/navigations-items-related/index.d.ts +56 -0
- package/server/content-types/navigations-items-related/index.js +11 -8
- package/server/content-types/navigations-items-related/lifecycle.d.ts +8 -0
- package/server/content-types/navigations-items-related/lifecycle.js +20 -17
- package/server/content-types/navigations-items-related/schema.d.ts +49 -0
- package/server/content-types/navigations-items-related/schema.js +50 -0
- package/server/controllers/admin.d.ts +4 -0
- package/server/controllers/admin.js +130 -0
- package/server/controllers/client.d.ts +4 -0
- package/server/controllers/client.js +57 -0
- package/server/controllers/index.d.ts +4 -0
- package/server/controllers/index.js +12 -6
- package/server/destroy.d.ts +3 -0
- package/server/destroy.js +5 -0
- package/server/graphql/config.d.ts +4 -0
- package/server/graphql/config.js +28 -0
- package/server/graphql/index.d.ts +2 -0
- package/server/graphql/index.js +18 -22
- package/server/graphql/queries/index.d.ts +3 -0
- package/server/graphql/queries/index.js +15 -15
- package/server/graphql/queries/render-navigation-child.d.ts +15 -0
- package/server/graphql/queries/render-navigation-child.js +24 -15
- package/server/graphql/queries/render-navigation.d.ts +21 -0
- package/server/graphql/queries/render-navigation.js +31 -15
- package/server/graphql/resolvers-config.d.ts +10 -0
- package/server/graphql/resolvers-config.js +5 -3
- package/server/graphql/setupStrategy.d.ts +3 -0
- package/server/graphql/setupStrategy.js +15 -0
- package/server/graphql/types/content-types-name-fields.d.ts +6 -0
- package/server/graphql/types/content-types-name-fields.js +13 -9
- package/server/graphql/types/content-types.d.ts +5 -0
- package/server/graphql/types/content-types.js +17 -15
- package/server/graphql/types/create-navigation-item.d.ts +5 -0
- package/server/graphql/types/create-navigation-item.js +18 -16
- package/server/graphql/types/create-navigation-related.d.ts +5 -0
- package/server/graphql/types/create-navigation-related.js +9 -7
- package/server/graphql/types/create-navigation.d.ts +5 -0
- package/server/graphql/types/create-navigation.js +8 -6
- package/server/graphql/types/index.d.ts +3 -0
- package/server/graphql/types/index.js +15 -13
- package/server/graphql/types/navigation-config.d.ts +5 -0
- package/server/graphql/types/navigation-config.js +10 -8
- package/server/graphql/types/navigation-details.d.ts +5 -0
- package/server/graphql/types/navigation-details.js +11 -9
- package/server/graphql/types/navigation-item-related-data.d.ts +5 -0
- package/server/graphql/types/navigation-item-related-data.js +9 -0
- package/server/graphql/types/navigation-item-related.d.ts +7 -0
- package/server/graphql/types/navigation-item-related.js +25 -0
- package/server/graphql/types/navigation-item.d.ts +5 -0
- package/server/graphql/types/navigation-item.js +28 -29
- package/server/graphql/types/navigation-render-type.d.ts +5 -0
- package/server/graphql/types/navigation-render-type.js +7 -4
- package/server/graphql/types/navigation.d.ts +5 -0
- package/server/graphql/types/navigation.js +10 -8
- package/server/i18n/constant.d.ts +2 -0
- package/server/i18n/constant.js +5 -0
- package/server/i18n/errors.d.ts +7 -0
- package/server/i18n/errors.js +14 -0
- package/server/i18n/graphQLEnhancers.d.ts +10 -0
- package/server/i18n/graphQLEnhancers.js +10 -0
- package/server/i18n/index.d.ts +8 -0
- package/server/i18n/index.js +23 -0
- package/server/i18n/navigationSetupStrategy.d.ts +3 -0
- package/server/i18n/navigationSetupStrategy.js +119 -0
- package/server/i18n/serviceEnhancers.d.ts +13 -0
- package/server/i18n/serviceEnhancers.js +156 -0
- package/server/i18n/types.d.ts +60 -0
- package/server/i18n/types.js +3 -0
- package/server/i18n/utils.d.ts +12 -0
- package/server/i18n/utils.js +29 -0
- package/server/index.d.ts +273 -0
- package/server/index.js +26 -0
- package/server/navigation/index.d.ts +2 -0
- package/server/navigation/index.js +18 -0
- package/server/navigation/setupStrategy.d.ts +3 -0
- package/server/navigation/setupStrategy.js +39 -0
- package/server/register/index.d.ts +3 -0
- package/server/register/index.js +4 -0
- package/server/routes/admin.d.ts +4 -0
- package/server/routes/admin.js +82 -61
- package/server/routes/client.d.ts +4 -0
- package/server/routes/client.js +25 -21
- package/server/routes/index.d.ts +6 -0
- package/server/routes/index.js +13 -4
- package/server/services/admin.d.ts +5 -0
- package/server/services/admin.js +238 -0
- package/server/services/client.d.ts +5 -0
- package/server/services/client.js +249 -0
- package/server/services/common.d.ts +5 -0
- package/server/services/common.js +313 -0
- package/server/services/index.d.ts +7 -0
- package/server/services/index.js +14 -6
- package/server/utils/constant.d.ts +27 -0
- package/server/utils/constant.js +24 -0
- package/server/utils/functions.d.ts +139 -0
- package/server/utils/functions.js +226 -0
- package/server/utils/index.d.ts +3 -0
- package/server/utils/index.js +19 -0
- package/strapi-admin.d.ts +3 -0
- package/strapi-admin.js +8 -1
- package/strapi-server.d.ts +273 -0
- package/strapi-server.js +6 -17
- package/tsconfig.tsbuildinfo +1 -0
- package/types/bootstrap.d.ts +13 -0
- package/types/bootstrap.js +3 -0
- package/types/config.d.ts +21 -0
- package/types/config.js +3 -0
- package/types/contentTypes.d.ts +85 -0
- package/types/contentTypes.js +3 -0
- package/types/controllers.d.ts +48 -0
- package/types/controllers.js +5 -0
- package/types/graphQL.d.ts +3 -0
- package/types/graphQL.js +3 -0
- package/types/i18n.d.ts +9 -0
- package/types/i18n.js +3 -0
- package/types/index.d.ts +9 -0
- package/types/index.js +25 -0
- package/types/services.d.ts +74 -0
- package/types/services.js +3 -0
- package/types/utils.d.ts +62 -0
- package/types/utils.js +27 -0
- package/utils/InvalidParamNavigationError.d.ts +4 -0
- package/utils/InvalidParamNavigationError.js +8 -0
- package/utils/NavigationError.d.ts +5 -0
- package/utils/NavigationError.js +7 -7
- package/__mocks__/pages.settings.json +0 -25
- package/__mocks__/strapi.js +0 -207
- package/jest.config.js +0 -14
- package/server/bootstrap.js +0 -52
- package/server/config.js +0 -9
- package/server/content-types/audience/lifecycle.js +0 -8
- package/server/content-types/audience/schema.json +0 -23
- package/server/content-types/navigation/schema.json +0 -45
- package/server/content-types/navigation-item/schema.json +0 -99
- package/server/content-types/navigations-items-related/schema.json +0 -47
- package/server/controllers/navigation.js +0 -105
- package/server/graphql/types/navigation-related.js +0 -25
- package/server/services/__tests__/functions.test.js +0 -48
- package/server/services/__tests__/navigation.test.js +0 -91
- package/server/services/navigation.js +0 -791
- package/server/services/utils/constant.js +0 -21
- package/server/services/utils/functions.js +0 -226
package/utils/NavigationError.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
class NavigationError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
constructor(message, additionalInfo) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.additionalInfo = additionalInfo;
|
|
6
|
+
}
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
module.exports = {
|
|
10
|
-
|
|
9
|
+
NavigationError,
|
|
11
10
|
};
|
|
11
|
+
//# sourceMappingURL=NavigationError.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"kind": "collectionType",
|
|
3
|
-
"collectionName": "pages",
|
|
4
|
-
"info": {
|
|
5
|
-
"singularName": "page",
|
|
6
|
-
"pluralName": "pages",
|
|
7
|
-
"displayName": "Page",
|
|
8
|
-
"name": "page"
|
|
9
|
-
},
|
|
10
|
-
"options": {
|
|
11
|
-
"increments": true,
|
|
12
|
-
"timestamps": true,
|
|
13
|
-
"searchable": true,
|
|
14
|
-
"previewable": true,
|
|
15
|
-
"draftAndPublish": false
|
|
16
|
-
},
|
|
17
|
-
"pluginOptions": {},
|
|
18
|
-
"attributes": {
|
|
19
|
-
"title": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"required": true
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
package/__mocks__/strapi.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
const { isMatch } = require('lodash');
|
|
2
|
-
|
|
3
|
-
const masterModelMock = {
|
|
4
|
-
findOne: () => ({
|
|
5
|
-
id: 1,
|
|
6
|
-
name: "Main navigation",
|
|
7
|
-
slug: "main-navigation",
|
|
8
|
-
visible: true,
|
|
9
|
-
createdAt: "2021-12-30T14:05:50.276Z",
|
|
10
|
-
updatedAt: "2021-12-30T14:05:50.276Z",
|
|
11
|
-
}),
|
|
12
|
-
findMany: () => [{
|
|
13
|
-
id: 1,
|
|
14
|
-
name: "Main navigation",
|
|
15
|
-
slug: "main-navigation",
|
|
16
|
-
visible: true,
|
|
17
|
-
createdAt: "2021-12-30T14:05:50.276Z",
|
|
18
|
-
updatedAt: "2021-12-30T14:05:50.276Z",
|
|
19
|
-
}],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const itemModelMock = {
|
|
23
|
-
findOne: async () => ({
|
|
24
|
-
id: 1,
|
|
25
|
-
title: "home",
|
|
26
|
-
type: "INTERNAL",
|
|
27
|
-
path: "home1",
|
|
28
|
-
externalPath: null,
|
|
29
|
-
uiRouterKey: "home",
|
|
30
|
-
menuAttached: true,
|
|
31
|
-
order: 1,
|
|
32
|
-
createdAt: "2021-12-31T10:04:54.812Z",
|
|
33
|
-
updatedAt: "2022-01-14T13:36:29.430Z",
|
|
34
|
-
related: {
|
|
35
|
-
id: 1,
|
|
36
|
-
related_id: "1",
|
|
37
|
-
related_type: "api::pages.pages",
|
|
38
|
-
field: "navigation",
|
|
39
|
-
order: 1,
|
|
40
|
-
master: "3",
|
|
41
|
-
createdAt: "2021-12-31T10:04:54.800Z",
|
|
42
|
-
updatedAt: "2021-12-31T10:04:54.800Z",
|
|
43
|
-
navigationItemId: 56,
|
|
44
|
-
},
|
|
45
|
-
parent: null,
|
|
46
|
-
}),
|
|
47
|
-
findMany: async ({ where }) => [{
|
|
48
|
-
id: 1,
|
|
49
|
-
title: "home",
|
|
50
|
-
type: "INTERNAL",
|
|
51
|
-
path: "home",
|
|
52
|
-
externalPath: null,
|
|
53
|
-
uiRouterKey: "home",
|
|
54
|
-
menuAttached: true,
|
|
55
|
-
order: 1,
|
|
56
|
-
createdAt: "2021-12-31T10:04:54.812Z",
|
|
57
|
-
updatedAt: "2022-01-14T13:36:29.430Z",
|
|
58
|
-
master: 1,
|
|
59
|
-
related: {
|
|
60
|
-
id: 1,
|
|
61
|
-
related_id: "1",
|
|
62
|
-
related_type: "api::pages.pages",
|
|
63
|
-
field: "navigation",
|
|
64
|
-
order: 1,
|
|
65
|
-
master: "3",
|
|
66
|
-
createdAt: "2021-12-31T10:04:54.800Z",
|
|
67
|
-
updatedAt: "2021-12-31T10:04:54.800Z",
|
|
68
|
-
navigationItemId: 56,
|
|
69
|
-
},
|
|
70
|
-
parent: null,
|
|
71
|
-
}, {
|
|
72
|
-
id: 2,
|
|
73
|
-
title: "side",
|
|
74
|
-
type: "INTERNAL",
|
|
75
|
-
path: "side",
|
|
76
|
-
externalPath: null,
|
|
77
|
-
uiRouterKey: "side",
|
|
78
|
-
menuAttached: false,
|
|
79
|
-
order: 1,
|
|
80
|
-
createdAt: "2021-12-31T10:04:54.824Z",
|
|
81
|
-
updatedAt: "2021-12-31T12:47:20.508Z",
|
|
82
|
-
master: 1,
|
|
83
|
-
related: {
|
|
84
|
-
id: 2,
|
|
85
|
-
related_id: "2",
|
|
86
|
-
related_type: "api::pages.pages",
|
|
87
|
-
field: "navigation",
|
|
88
|
-
order: 1,
|
|
89
|
-
master: "3",
|
|
90
|
-
createdAt: "2021-12-31T10:04:54.823Z",
|
|
91
|
-
updatedAt: "2021-12-31T10:04:54.823Z",
|
|
92
|
-
navigationItemId: 57,
|
|
93
|
-
},
|
|
94
|
-
parent: {
|
|
95
|
-
id: 1,
|
|
96
|
-
title: "home",
|
|
97
|
-
type: "INTERNAL",
|
|
98
|
-
path: "home1",
|
|
99
|
-
externalPath: null,
|
|
100
|
-
uiRouterKey: "home",
|
|
101
|
-
menuAttached: true,
|
|
102
|
-
order: 1,
|
|
103
|
-
createdAt: "2021-12-31T10:04:54.812Z",
|
|
104
|
-
updatedAt: "2022-01-14T13:36:29.430Z",
|
|
105
|
-
},
|
|
106
|
-
}].filter(item => isMatch(item, where)),
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const pageModelMock = {
|
|
110
|
-
findOne: async ({ where }) => ({
|
|
111
|
-
"id": 1,
|
|
112
|
-
"attributes": {
|
|
113
|
-
"title": "Page nr 1",
|
|
114
|
-
"createdAt": "2022-01-19T08:22:31.244Z",
|
|
115
|
-
"updatedAt": "2022-01-19T08:22:31.244Z",
|
|
116
|
-
"publishedAt": null
|
|
117
|
-
}
|
|
118
|
-
}),
|
|
119
|
-
findMany: async ({ where }) => [{
|
|
120
|
-
"id": 1,
|
|
121
|
-
"attributes": {
|
|
122
|
-
"title": "Page nr 1",
|
|
123
|
-
"createdAt": "2022-01-19T08:22:31.244Z",
|
|
124
|
-
"updatedAt": "2022-01-19T08:22:31.244Z",
|
|
125
|
-
"publishedAt": null
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
"id": 2,
|
|
129
|
-
"attributes": {
|
|
130
|
-
"title": "Page nr 2",
|
|
131
|
-
"createdAt": "2022-01-19T08:22:50.821Z",
|
|
132
|
-
"updatedAt": "2022-01-19T08:22:50.821Z",
|
|
133
|
-
"publishedAt": null
|
|
134
|
-
}
|
|
135
|
-
}]
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const plugins = (strapi) => ({
|
|
140
|
-
navigation: {
|
|
141
|
-
get services() { return require('../server/services') },
|
|
142
|
-
service: (key) => (require('../server/services'))[key]({ strapi }),
|
|
143
|
-
get contentTypes() { return require('../server/content-types') },
|
|
144
|
-
contentType: (key) => preparePluginContentType(require('../server/content-types')[key].schema, 'navigation'),
|
|
145
|
-
config: (key) => ({
|
|
146
|
-
...require('../server/config').default,
|
|
147
|
-
contentTypes: ['api::pages.pages'],
|
|
148
|
-
})[key],
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const contentTypes = {
|
|
153
|
-
'api::pages.pages': {
|
|
154
|
-
...require('./pages.settings.json'),
|
|
155
|
-
uid: 'api::pages.pages',
|
|
156
|
-
modelName: 'page',
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const preparePluginContentType = (schema, plugin) => {
|
|
161
|
-
const { name } = schema.info;
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
...schema,
|
|
165
|
-
uid: `plugin::${plugin}.${name}`,
|
|
166
|
-
modelName: name,
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const strapiFactory = (plugins, contentTypes) => ({
|
|
171
|
-
get plugins() { return plugins(strapi) },
|
|
172
|
-
plugin: (name) => plugins(strapi)[name],
|
|
173
|
-
get contentTypes() { return contentTypes },
|
|
174
|
-
contentType: (key) => contentTypes[key],
|
|
175
|
-
query: (model) => {
|
|
176
|
-
switch (model) {
|
|
177
|
-
case 'plugin::navigation.navigation':
|
|
178
|
-
return masterModelMock;
|
|
179
|
-
case 'plugin::navigation.navigation-item':
|
|
180
|
-
return itemModelMock;
|
|
181
|
-
case 'api::pages.pages':
|
|
182
|
-
return pageModelMock;
|
|
183
|
-
default:
|
|
184
|
-
return {
|
|
185
|
-
findOne: () => ({}),
|
|
186
|
-
findMany: () => [],
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
store: ({ type, name }) => {
|
|
191
|
-
if (type === 'plugin' && name === 'navigation') {
|
|
192
|
-
return {
|
|
193
|
-
get: ({ key }) => key === 'config' ? {
|
|
194
|
-
...require('../server/config').default,
|
|
195
|
-
contentTypes: ['api::pages.pages']
|
|
196
|
-
} : null,
|
|
197
|
-
set: () => null,
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const setupStrapi = () => {
|
|
204
|
-
Object.defineProperty(global, 'strapi', { value: strapiFactory(plugins, contentTypes) });
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
module.exports = { setupStrapi };
|
package/jest.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
name: 'Unit test',
|
|
3
|
-
testMatch: ['**/__tests__/?(*.)+(spec|test).js'],
|
|
4
|
-
testPathIgnorePatterns: [
|
|
5
|
-
"/node_modules/",
|
|
6
|
-
".tmp",
|
|
7
|
-
".cache",
|
|
8
|
-
"/__mocks__/helpers/"
|
|
9
|
-
],
|
|
10
|
-
testEnvironment: "node",
|
|
11
|
-
transform: {},
|
|
12
|
-
coverageDirectory: "./coverage/",
|
|
13
|
-
collectCoverage: true,
|
|
14
|
-
};
|
package/server/bootstrap.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const { isEmpty } = require("lodash");
|
|
2
|
-
const permissions = require('./../permissions');
|
|
3
|
-
|
|
4
|
-
module.exports = async ({ strapi }) => {
|
|
5
|
-
// Check if the plugin users-permissions is installed because the navigation needs it
|
|
6
|
-
if (Object.keys(strapi.plugins).indexOf("users-permissions") === -1) {
|
|
7
|
-
throw new Error(
|
|
8
|
-
"In order to make the navigation plugin work the users-permissions plugin is required",
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
// Add permissions
|
|
12
|
-
const actions = [
|
|
13
|
-
{
|
|
14
|
-
section: "plugins",
|
|
15
|
-
displayName: "Read",
|
|
16
|
-
uid: permissions.navigation.read,
|
|
17
|
-
pluginName: "navigation",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
section: "plugins",
|
|
21
|
-
displayName: "Update",
|
|
22
|
-
uid: permissions.navigation.update,
|
|
23
|
-
pluginName: "navigation",
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
await strapi.admin.services.permission.actionProvider.registerMany(actions);
|
|
27
|
-
|
|
28
|
-
// Initialize first navigation
|
|
29
|
-
const navigations = await strapi
|
|
30
|
-
.query("plugin::navigation.navigation")
|
|
31
|
-
.findMany();
|
|
32
|
-
if (isEmpty(navigations)) {
|
|
33
|
-
await strapi
|
|
34
|
-
.query("plugin::navigation.navigation")
|
|
35
|
-
.create({
|
|
36
|
-
data: {
|
|
37
|
-
name: 'Main navigation',
|
|
38
|
-
slug: 'main-navigation',
|
|
39
|
-
visible: true,
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Initialize configuration
|
|
45
|
-
const config = await strapi.plugin('navigation').service('navigation').setDefaultConfig()
|
|
46
|
-
|
|
47
|
-
// Initialize graphql configuration
|
|
48
|
-
if (strapi.plugin('graphql')) {
|
|
49
|
-
const graphqlConfiguration = require('./graphql')
|
|
50
|
-
await graphqlConfiguration({ strapi, config });
|
|
51
|
-
}
|
|
52
|
-
};
|
package/server/config.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"collectionName": "audience",
|
|
3
|
-
"info": {
|
|
4
|
-
"singularName": "audience",
|
|
5
|
-
"pluralName": "audiences",
|
|
6
|
-
"displayName": "Audience",
|
|
7
|
-
"name": "audience"
|
|
8
|
-
},
|
|
9
|
-
"options": {
|
|
10
|
-
"increments": true,
|
|
11
|
-
"comment": "Audience"
|
|
12
|
-
},
|
|
13
|
-
"attributes": {
|
|
14
|
-
"name": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"required": true
|
|
17
|
-
},
|
|
18
|
-
"key": {
|
|
19
|
-
"type": "uid",
|
|
20
|
-
"targetField": "name"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"collectionName": "navigations",
|
|
3
|
-
"info": {
|
|
4
|
-
"singularName": "navigation",
|
|
5
|
-
"pluralName": "navigations",
|
|
6
|
-
"displayName": "Navigation",
|
|
7
|
-
"name": "navigation"
|
|
8
|
-
},
|
|
9
|
-
"options": {
|
|
10
|
-
"increments": true,
|
|
11
|
-
"comment": ""
|
|
12
|
-
},
|
|
13
|
-
"pluginOptions": {
|
|
14
|
-
"content-manager": {
|
|
15
|
-
"visible": true
|
|
16
|
-
},
|
|
17
|
-
"content-type-builder": {
|
|
18
|
-
"visible": false
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"attributes": {
|
|
22
|
-
"name": {
|
|
23
|
-
"type": "text",
|
|
24
|
-
"configurable": false,
|
|
25
|
-
"required": true
|
|
26
|
-
},
|
|
27
|
-
"slug": {
|
|
28
|
-
"type": "uid",
|
|
29
|
-
"target": "name",
|
|
30
|
-
"configurable": false,
|
|
31
|
-
"required": true
|
|
32
|
-
},
|
|
33
|
-
"visible": {
|
|
34
|
-
"type": "boolean",
|
|
35
|
-
"default": false,
|
|
36
|
-
"configurable": false
|
|
37
|
-
},
|
|
38
|
-
"items": {
|
|
39
|
-
"type": "relation",
|
|
40
|
-
"relation": "oneToMany",
|
|
41
|
-
"target": "plugin::navigation.navigation-item",
|
|
42
|
-
"configurable": false
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"collectionName": "navigations_items",
|
|
3
|
-
"info": {
|
|
4
|
-
"singularName": "navigation-item",
|
|
5
|
-
"pluralName": "navigation-items",
|
|
6
|
-
"displayName": "Navigation Item",
|
|
7
|
-
"name": "navigation-item"
|
|
8
|
-
},
|
|
9
|
-
"options": {
|
|
10
|
-
"increments": true,
|
|
11
|
-
"timestamps": true,
|
|
12
|
-
"comment": "Navigation Item"
|
|
13
|
-
},
|
|
14
|
-
"pluginOptions": {
|
|
15
|
-
"content-manager": {
|
|
16
|
-
"visible": false
|
|
17
|
-
},
|
|
18
|
-
"content-type-builder": {
|
|
19
|
-
"visible": false
|
|
20
|
-
},
|
|
21
|
-
"i18n": {
|
|
22
|
-
"localized": false
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"attributes": {
|
|
26
|
-
"title": {
|
|
27
|
-
"type": "text",
|
|
28
|
-
"configurable": false,
|
|
29
|
-
"required": true,
|
|
30
|
-
"pluginOptions": {
|
|
31
|
-
"i18n": {
|
|
32
|
-
"localized": false
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"type": {
|
|
37
|
-
"type": "enumeration",
|
|
38
|
-
"enum": [
|
|
39
|
-
"INTERNAL",
|
|
40
|
-
"EXTERNAL",
|
|
41
|
-
"WRAPPER"
|
|
42
|
-
],
|
|
43
|
-
"default": "INTERNAL",
|
|
44
|
-
"configurable": false
|
|
45
|
-
},
|
|
46
|
-
"path": {
|
|
47
|
-
"type": "text",
|
|
48
|
-
"targetField": "title",
|
|
49
|
-
"configurable": false
|
|
50
|
-
},
|
|
51
|
-
"externalPath": {
|
|
52
|
-
"type": "text",
|
|
53
|
-
"configurable": false
|
|
54
|
-
},
|
|
55
|
-
"uiRouterKey": {
|
|
56
|
-
"type": "string",
|
|
57
|
-
"configurable": false
|
|
58
|
-
},
|
|
59
|
-
"menuAttached": {
|
|
60
|
-
"type": "boolean",
|
|
61
|
-
"default": false,
|
|
62
|
-
"configurable": false
|
|
63
|
-
},
|
|
64
|
-
"order": {
|
|
65
|
-
"type": "integer",
|
|
66
|
-
"default": 0,
|
|
67
|
-
"configurable": false
|
|
68
|
-
},
|
|
69
|
-
"collapsed": {
|
|
70
|
-
"type": "boolean",
|
|
71
|
-
"default": false,
|
|
72
|
-
"configurable": false
|
|
73
|
-
},
|
|
74
|
-
"related": {
|
|
75
|
-
"type": "relation",
|
|
76
|
-
"relation": "oneToOne",
|
|
77
|
-
"target": "plugin::navigation.navigations-items-related",
|
|
78
|
-
"configurable": false
|
|
79
|
-
},
|
|
80
|
-
"parent": {
|
|
81
|
-
"type": "relation",
|
|
82
|
-
"relation": "oneToOne",
|
|
83
|
-
"target": "plugin::navigation.navigation-item",
|
|
84
|
-
"configurable": false,
|
|
85
|
-
"default": null
|
|
86
|
-
},
|
|
87
|
-
"master": {
|
|
88
|
-
"type": "relation",
|
|
89
|
-
"relation": "manyToOne",
|
|
90
|
-
"target": "plugin::navigation.navigation",
|
|
91
|
-
"configurable": false
|
|
92
|
-
},
|
|
93
|
-
"audience": {
|
|
94
|
-
"type": "relation",
|
|
95
|
-
"relation": "oneToMany",
|
|
96
|
-
"target": "plugin::navigation.audience"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"collectionName": "navigations_items_related",
|
|
3
|
-
"info": {
|
|
4
|
-
"singularName": "navigations-items-related",
|
|
5
|
-
"pluralName": "navigations-items-relateds",
|
|
6
|
-
"displayName": "Navigations Items Related",
|
|
7
|
-
"name": "navigations_items_related"
|
|
8
|
-
},
|
|
9
|
-
"options": {
|
|
10
|
-
"increments": true,
|
|
11
|
-
"timestamps": false,
|
|
12
|
-
"populateCreatorFields": false
|
|
13
|
-
},
|
|
14
|
-
"pluginOptions": {
|
|
15
|
-
"content-manager": {
|
|
16
|
-
"visible": false
|
|
17
|
-
},
|
|
18
|
-
"content-type-builder": {
|
|
19
|
-
"visible": false
|
|
20
|
-
},
|
|
21
|
-
"i18n": {
|
|
22
|
-
"localized": false
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"attributes": {
|
|
26
|
-
"related_id": {
|
|
27
|
-
"type": "string",
|
|
28
|
-
"required": true
|
|
29
|
-
},
|
|
30
|
-
"related_type": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"required": true
|
|
33
|
-
},
|
|
34
|
-
"field": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"required": true
|
|
37
|
-
},
|
|
38
|
-
"order": {
|
|
39
|
-
"type": "integer",
|
|
40
|
-
"required": true
|
|
41
|
-
},
|
|
42
|
-
"master": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"required": true
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
const { NavigationError } = require('../../utils/NavigationError');
|
|
2
|
-
|
|
3
|
-
const getService = () => strapi.plugin('navigation').service('navigation');
|
|
4
|
-
|
|
5
|
-
const parseParams = (params) =>
|
|
6
|
-
Object.keys(params).reduce((prev, curr) => {
|
|
7
|
-
const value = params[curr];
|
|
8
|
-
const parsedValue = isNaN(Number(value)) ? value : parseInt(value, 10);
|
|
9
|
-
return {
|
|
10
|
-
...prev,
|
|
11
|
-
[curr]: parsedValue,
|
|
12
|
-
};
|
|
13
|
-
}, {});
|
|
14
|
-
|
|
15
|
-
const errorHandler = (ctx) => (error) => {
|
|
16
|
-
if (error instanceof NavigationError) {
|
|
17
|
-
return ctx.badRequest(error.message, error.additionalInfo);
|
|
18
|
-
}
|
|
19
|
-
throw error;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
module.exports = ({strapi}) => ({
|
|
23
|
-
async config() {
|
|
24
|
-
return getService().config();
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
async updateConfig(ctx) {
|
|
28
|
-
try {
|
|
29
|
-
await getService().updateConfig(ctx.request.body);
|
|
30
|
-
} catch (e) {
|
|
31
|
-
errorHandler(ctx)(e);
|
|
32
|
-
}
|
|
33
|
-
return ctx.send({ status: 200 });
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
async restoreConfig(ctx) {
|
|
37
|
-
try {
|
|
38
|
-
await getService().restoreConfig();
|
|
39
|
-
} catch (e) {
|
|
40
|
-
errorHandler(ctx)(e);
|
|
41
|
-
}
|
|
42
|
-
return ctx.send({ status: 200 })
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
async settingsConfig() {
|
|
46
|
-
return getService().config(true);
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
async settingsRestart(ctx) {
|
|
50
|
-
try {
|
|
51
|
-
await getService().restart();
|
|
52
|
-
return ctx.send({ status: 200 });
|
|
53
|
-
} catch (e) {
|
|
54
|
-
errorHandler(ctx)(e);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
async get() {
|
|
59
|
-
return getService().get();
|
|
60
|
-
},
|
|
61
|
-
async getById(ctx) {
|
|
62
|
-
const { params } = ctx;
|
|
63
|
-
const { id } = parseParams(params);
|
|
64
|
-
return getService().getById(id);
|
|
65
|
-
},
|
|
66
|
-
async getContentTypeItems(ctx) {
|
|
67
|
-
const { params } = ctx;
|
|
68
|
-
const { model } = parseParams(params);
|
|
69
|
-
return getService().getContentTypeItems(model)
|
|
70
|
-
},
|
|
71
|
-
post(ctx) {
|
|
72
|
-
const { auditLog } = ctx;
|
|
73
|
-
const { body = {} } = ctx.request;
|
|
74
|
-
return getService().post(body, auditLog);
|
|
75
|
-
},
|
|
76
|
-
put(ctx) {
|
|
77
|
-
const { params, auditLog } = ctx;
|
|
78
|
-
const { id } = parseParams(params);
|
|
79
|
-
const { body = {} } = ctx.request;
|
|
80
|
-
return getService().put(id, body, auditLog)
|
|
81
|
-
.catch(errorHandler(ctx));
|
|
82
|
-
},
|
|
83
|
-
async render(ctx) {
|
|
84
|
-
const { params, query = {} } = ctx;
|
|
85
|
-
const { type, menu: menuOnly, path: rootPath } = query;
|
|
86
|
-
const { idOrSlug } = parseParams(params);
|
|
87
|
-
return getService().render({
|
|
88
|
-
idOrSlug,
|
|
89
|
-
type,
|
|
90
|
-
menuOnly,
|
|
91
|
-
rootPath
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
async renderChild(ctx) {
|
|
95
|
-
const { params, query = {} } = ctx;
|
|
96
|
-
const { type, menu: menuOnly } = query;
|
|
97
|
-
const { idOrSlug, childUIKey } = parseParams(params);
|
|
98
|
-
return getService().renderChildren(
|
|
99
|
-
idOrSlug,
|
|
100
|
-
childUIKey,
|
|
101
|
-
type,
|
|
102
|
-
menuOnly
|
|
103
|
-
);
|
|
104
|
-
},
|
|
105
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module.exports = ({ strapi, nexus, config }) => {
|
|
2
|
-
const related = config.gql?.navigationItemRelated;
|
|
3
|
-
const name = "NavigationRelated";
|
|
4
|
-
|
|
5
|
-
if (related?.length) {
|
|
6
|
-
return nexus.unionType({
|
|
7
|
-
name,
|
|
8
|
-
definition(t) {
|
|
9
|
-
t.members(...related)
|
|
10
|
-
},
|
|
11
|
-
resolveType: (item) => {
|
|
12
|
-
return strapi.contentTypes[item.__contentType]?.globalId
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return nexus.objectType({
|
|
18
|
-
name,
|
|
19
|
-
definition(t) {
|
|
20
|
-
t.int("id")
|
|
21
|
-
t.string("title")
|
|
22
|
-
t.string("name")
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
}
|