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
|
@@ -1,309 +1,327 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
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]; } };
|
|
7
|
+
}
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
31
|
+
const react_intl_1 = require("react-intl");
|
|
32
|
+
const prop_types_1 = __importDefault(require("prop-types"));
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
|
35
|
+
const DataManagerContext_1 = __importDefault(require("../../contexts/DataManagerContext"));
|
|
36
|
+
const getTrad_1 = __importDefault(require("../../utils/getTrad"));
|
|
37
|
+
const pluginId_1 = __importDefault(require("../../pluginId"));
|
|
38
|
+
const init_1 = __importDefault(require("./init"));
|
|
39
|
+
const reducer_1 = __importStar(require("./reducer"));
|
|
40
|
+
const actions_1 = require("./actions");
|
|
41
|
+
const parsers_1 = require("../View/utils/parsers");
|
|
42
|
+
const utils_1 = require("../../utils");
|
|
43
|
+
const i18nAwareItems = ({ items, config }) => config.i18nEnabled ? items.filter(({ localeCode }) => localeCode === config.defaultLocale) : items;
|
|
36
44
|
const DataManagerProvider = ({ children }) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
45
|
+
const [reducerState, dispatch] = (0, react_1.useReducer)(reducer_1.default, reducer_1.initialState, init_1.default);
|
|
46
|
+
const toggleNotification = (0, helper_plugin_1.useNotification)();
|
|
47
|
+
const { autoReload } = (0, helper_plugin_1.useAppInfos)();
|
|
48
|
+
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
49
|
+
const { items, config, activeItem, initialData, changedActiveItem, navigationPopupOpened, navigationItemPopupOpened, isLoading, isLoadingForDataToBeSet, isLoadingForDetailsDataToBeSet, isLoadingForAdditionalDataToBeSet, isLoadingForSubmit, error, availableLocale, } = reducerState;
|
|
50
|
+
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
51
|
+
const formatMessageRef = (0, react_1.useRef)();
|
|
52
|
+
formatMessageRef.current = formatMessage;
|
|
53
|
+
const getLayoutSettingRef = (0, react_1.useRef)();
|
|
54
|
+
getLayoutSettingRef.current = (settingName) => (0, lodash_1.get)({}, ["settings", settingName], "");
|
|
55
|
+
const isInDevelopmentMode = autoReload;
|
|
56
|
+
const abortController = new AbortController();
|
|
57
|
+
const { signal } = abortController;
|
|
58
|
+
const getDataRef = (0, react_1.useRef)();
|
|
59
|
+
const menuViewMatch = (0, react_router_dom_1.useRouteMatch)(`/plugins/${pluginId_1.default}/:id`);
|
|
60
|
+
const activeId = (0, lodash_1.get)(menuViewMatch, "params.id", null);
|
|
61
|
+
const passedActiveItems = (0, react_1.useMemo)(() => {
|
|
62
|
+
return i18nAwareItems({ config, items });
|
|
63
|
+
}, [config, items]);
|
|
64
|
+
const getNavigation = async (id, navigationConfig) => {
|
|
65
|
+
try {
|
|
66
|
+
if (activeId || id) {
|
|
67
|
+
dispatch({
|
|
68
|
+
type: actions_1.GET_NAVIGATION_DATA,
|
|
69
|
+
});
|
|
70
|
+
const activeItem = await (0, helper_plugin_1.request)(`/${pluginId_1.default}/${activeId || id}`, {
|
|
71
|
+
method: "GET",
|
|
72
|
+
signal,
|
|
73
|
+
});
|
|
74
|
+
dispatch({
|
|
75
|
+
type: actions_1.GET_NAVIGATION_DATA_SUCCEEDED,
|
|
76
|
+
activeItem: {
|
|
77
|
+
...activeItem,
|
|
78
|
+
items: (0, parsers_1.prepareItemToViewPayload)({
|
|
79
|
+
config: navigationConfig,
|
|
80
|
+
items: activeItem.items,
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
console.error({ err });
|
|
88
|
+
toggleNotification({
|
|
89
|
+
type: 'warning',
|
|
90
|
+
message: { id: (0, getTrad_1.default)('notification.error') },
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
getDataRef.current = async (id) => {
|
|
95
|
+
try {
|
|
96
|
+
dispatch({
|
|
97
|
+
type: actions_1.GET_CONFIG,
|
|
98
|
+
});
|
|
99
|
+
const config = await (0, helper_plugin_1.request)(`/${pluginId_1.default}/config`, {
|
|
100
|
+
method: "GET",
|
|
101
|
+
signal,
|
|
102
|
+
});
|
|
103
|
+
dispatch({
|
|
104
|
+
type: actions_1.GET_CONFIG_SUCCEEDED,
|
|
105
|
+
config,
|
|
106
|
+
});
|
|
107
|
+
dispatch({
|
|
108
|
+
type: actions_1.GET_LIST_DATA,
|
|
109
|
+
});
|
|
110
|
+
const items = await (0, helper_plugin_1.request)(`/${pluginId_1.default}`, {
|
|
111
|
+
method: "GET",
|
|
112
|
+
signal,
|
|
113
|
+
});
|
|
114
|
+
dispatch({
|
|
115
|
+
type: actions_1.GET_LIST_DATA_SUCCEEDED,
|
|
116
|
+
items,
|
|
117
|
+
});
|
|
118
|
+
if (id || !(0, lodash_1.isEmpty)(items)) {
|
|
119
|
+
await getNavigation(id || (0, lodash_1.first)(i18nAwareItems({ items, config })).id, config);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.error({ err });
|
|
124
|
+
toggleNotification({
|
|
125
|
+
type: 'warning',
|
|
126
|
+
message: { id: (0, getTrad_1.default)('notification.error') },
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
(0, react_1.useEffect)(() => {
|
|
131
|
+
getDataRef.current();
|
|
132
|
+
}, []);
|
|
133
|
+
(0, react_1.useEffect)(() => {
|
|
134
|
+
if (!isLoading) {
|
|
135
|
+
getNavigation();
|
|
136
|
+
}
|
|
137
|
+
}, [isLoading, pathname]);
|
|
138
|
+
(0, react_1.useEffect)(() => {
|
|
139
|
+
if (!autoReload) {
|
|
140
|
+
toggleNotification({
|
|
141
|
+
type: 'info',
|
|
142
|
+
message: { id: (0, getTrad_1.default)('notification.info.autoreaload-disable') },
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}, [autoReload]);
|
|
146
|
+
const getContentTypeItems = async ({ modelUID, query, locale }) => {
|
|
77
147
|
dispatch({
|
|
78
|
-
|
|
148
|
+
type: actions_1.GET_CONTENT_TYPE_ITEMS,
|
|
79
149
|
});
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
150
|
+
const url = `/navigation/content-type-items/${modelUID}`;
|
|
151
|
+
const queryParams = new URLSearchParams();
|
|
152
|
+
queryParams.append('_publicationState', 'preview');
|
|
153
|
+
if (query) {
|
|
154
|
+
queryParams.append('_q', query);
|
|
155
|
+
}
|
|
156
|
+
if (locale) {
|
|
157
|
+
queryParams.append('localeCode', locale);
|
|
158
|
+
}
|
|
159
|
+
const contentTypeItems = await (0, helper_plugin_1.request)(`${url}?${queryParams.toString()}`, {
|
|
160
|
+
method: "GET",
|
|
161
|
+
signal,
|
|
84
162
|
});
|
|
85
|
-
|
|
163
|
+
const fetchedContentType = (0, lodash_1.find)(config.contentTypes, ct => ct.uid === modelUID);
|
|
164
|
+
const isArray = Array.isArray(contentTypeItems);
|
|
86
165
|
dispatch({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
166
|
+
type: actions_1.GET_CONTENT_TYPE_ITEMS_SUCCEEDED,
|
|
167
|
+
contentTypeItems: (isArray ? contentTypeItems : [contentTypeItems]).map(item => ({
|
|
168
|
+
...item,
|
|
169
|
+
__collectionUid: (0, lodash_1.get)(fetchedContentType, 'collectionUid', modelUID),
|
|
170
|
+
})),
|
|
92
171
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
172
|
+
};
|
|
173
|
+
const handleChangeSelection = (id) => {
|
|
174
|
+
getNavigation(id, config);
|
|
175
|
+
};
|
|
176
|
+
const handleLocalizationSelection = (id) => {
|
|
177
|
+
getNavigation(id, config);
|
|
178
|
+
};
|
|
179
|
+
const handleI18nCopy = async (sourceId, targetId) => {
|
|
180
|
+
dispatch({
|
|
181
|
+
type: actions_1.I18N_COPY_NAVIGATION
|
|
182
|
+
});
|
|
183
|
+
const url = `/navigation/i18n/copy/${sourceId}/${targetId}`;
|
|
184
|
+
await (0, helper_plugin_1.request)(url, {
|
|
185
|
+
method: "PUT",
|
|
186
|
+
signal,
|
|
187
|
+
});
|
|
188
|
+
dispatch({
|
|
189
|
+
type: actions_1.I18N_COPY_NAVIGATION_SUCCESS,
|
|
190
|
+
});
|
|
191
|
+
handleChangeSelection(targetId);
|
|
192
|
+
};
|
|
193
|
+
const readNavigationItemFromLocale = async ({ locale, structureId }) => {
|
|
194
|
+
try {
|
|
195
|
+
const source = changedActiveItem.localizations?.find((navigation) => navigation.locale === locale);
|
|
196
|
+
if (!source) {
|
|
197
|
+
return (0, utils_1.errorStatusResourceFor)(['popup.item.form.i18n.locale.error.unavailable']);
|
|
198
|
+
}
|
|
199
|
+
const url = `/navigation/i18n/item/read/${source.id}/${changedActiveItem.id}?path=${structureId}`;
|
|
200
|
+
return (0, utils_1.resolvedResourceFor)(await (0, helper_plugin_1.request)(url, {
|
|
201
|
+
method: "GET",
|
|
202
|
+
signal,
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
let messageKey;
|
|
207
|
+
if (error instanceof Error) {
|
|
208
|
+
messageKey = (0, lodash_1.get)(error, 'response.payload.error.details.messageKey');
|
|
209
|
+
}
|
|
210
|
+
return (0, utils_1.errorStatusResourceFor)([messageKey ?? 'popup.item.form.i18n.locale.error.generic']);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const handleChangeNavigationPopupVisibility = (visible) => {
|
|
214
|
+
dispatch({
|
|
215
|
+
type: actions_1.CHANGE_NAVIGATION_POPUP_VISIBILITY,
|
|
216
|
+
navigationPopupOpened: visible,
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
const handleChangeNavigationItemPopupVisibility = (visible) => {
|
|
220
|
+
dispatch({
|
|
221
|
+
type: actions_1.CHANGE_NAVIGATION_ITEM_POPUP_VISIBILITY,
|
|
222
|
+
navigationItemPopupOpened: visible,
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
const handleChangeNavigationData = (payload, forceClosePopups) => {
|
|
226
|
+
dispatch({
|
|
227
|
+
type: actions_1.CHANGE_NAVIGATION_DATA,
|
|
228
|
+
changedActiveItem: payload,
|
|
229
|
+
forceClosePopups,
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
const handleResetNavigationData = () => {
|
|
233
|
+
dispatch({
|
|
234
|
+
type: actions_1.RESET_NAVIGATION_DATA,
|
|
235
|
+
activeItem,
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
const handleSubmitNavigation = async (formatMessage, payload = {}) => {
|
|
239
|
+
try {
|
|
240
|
+
dispatch({
|
|
241
|
+
type: actions_1.SUBMIT_NAVIGATION,
|
|
242
|
+
});
|
|
243
|
+
const nagivationId = payload.id ? `/${payload.id}` : "";
|
|
244
|
+
const method = payload.id ? "PUT" : "POST";
|
|
245
|
+
const navigation = await (0, helper_plugin_1.request)(`/${pluginId_1.default}${nagivationId}`, {
|
|
246
|
+
method,
|
|
247
|
+
signal,
|
|
248
|
+
body: payload,
|
|
249
|
+
});
|
|
250
|
+
dispatch({
|
|
251
|
+
type: actions_1.SUBMIT_NAVIGATION_SUCCEEDED,
|
|
252
|
+
navigation: {
|
|
253
|
+
...navigation,
|
|
254
|
+
items: (0, parsers_1.prepareItemToViewPayload)({
|
|
255
|
+
config,
|
|
256
|
+
items: navigation.items,
|
|
257
|
+
}),
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
toggleNotification({
|
|
261
|
+
type: 'success',
|
|
262
|
+
message: { id: (0, getTrad_1.default)('notification.navigation.submit') },
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
dispatch({
|
|
267
|
+
type: actions_1.SUBMIT_NAVIGATION_ERROR,
|
|
268
|
+
error: err.response.payload.data
|
|
269
|
+
});
|
|
270
|
+
console.error({ err: err.response });
|
|
271
|
+
if (err.response.payload.data && err.response.payload.data.errorTitles) {
|
|
272
|
+
return toggleNotification({
|
|
273
|
+
type: 'warning',
|
|
274
|
+
message: {
|
|
275
|
+
id: formatMessage((0, getTrad_1.default)('notification.navigation.error'), { ...err.response.payload.data, errorTitles: err.response.payload.data.errorTitles.join(' and ') })
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
toggleNotification({
|
|
280
|
+
type: 'warning',
|
|
281
|
+
message: { id: (0, getTrad_1.default)('notification.error') },
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const handleNavigationsDeletion = async (ids) => Promise.all(ids.map((id) => handleNavigationDeletion(id)));
|
|
286
|
+
const handleNavigationDeletion = (id) => (0, helper_plugin_1.request)(`/${pluginId_1.default}/${id}`, {
|
|
287
|
+
method: "DELETE",
|
|
122
288
|
signal,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
dispatch({
|
|
126
|
-
type: GET_LIST_DATA_SUCCEEDED,
|
|
127
|
-
items,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (id || !isEmpty(items)) {
|
|
131
|
-
await getNavigation(id || first(items).id, config);
|
|
132
|
-
}
|
|
133
|
-
} catch (err) {
|
|
134
|
-
console.error({ err });
|
|
135
|
-
toggleNotification({
|
|
136
|
-
type: 'warning',
|
|
137
|
-
message: { id: getTrad('notification.error') },
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
getDataRef.current();
|
|
144
|
-
}, []);
|
|
145
|
-
|
|
146
|
-
useEffect(() => {
|
|
147
|
-
// We need to set the modifiedData after the data has been retrieved
|
|
148
|
-
// and also on pathname change
|
|
149
|
-
if (!isLoading) {
|
|
150
|
-
getNavigation();
|
|
151
|
-
}
|
|
152
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
|
-
}, [isLoading, pathname]);
|
|
154
|
-
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
if (!autoReload) {
|
|
157
|
-
toggleNotification({
|
|
158
|
-
type: 'info',
|
|
159
|
-
message: { id: getTrad('notification.info.autoreaload-disable') },
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}, [autoReload]);
|
|
163
|
-
|
|
164
|
-
const getContentTypeItems = async ({ modelUID, query }) => {
|
|
165
|
-
dispatch({
|
|
166
|
-
type: GET_CONTENT_TYPE_ITEMS,
|
|
167
|
-
});
|
|
168
|
-
const url =`/navigation/content-type-items/${modelUID}`;
|
|
169
|
-
const queryParams = new URLSearchParams();
|
|
170
|
-
queryParams.append('_publicationState', 'preview');
|
|
171
|
-
if (query) {
|
|
172
|
-
queryParams.append('_q', query);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const contentTypeItems = await request(`${url}?${queryParams.toString()}`, {
|
|
176
|
-
method: "GET",
|
|
177
|
-
signal,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const fetchedContentType = find(config.contentTypes, ct => ct.uid === modelUID);
|
|
181
|
-
const isArray = Array.isArray(contentTypeItems);
|
|
182
|
-
dispatch({
|
|
183
|
-
type: GET_CONTENT_TYPE_ITEMS_SUCCEEDED,
|
|
184
|
-
contentTypeItems: (isArray ? contentTypeItems : [contentTypeItems]).map(item => ({
|
|
185
|
-
...item,
|
|
186
|
-
__collectionUid: get(fetchedContentType, 'collectionUid', modelUID),
|
|
187
|
-
})),
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const handleChangeSelection = (id) => {
|
|
192
|
-
getNavigation(id, config);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const handleChangeNavigationPopupVisibility = (visible) => {
|
|
196
|
-
dispatch({
|
|
197
|
-
type: CHANGE_NAVIGATION_POPUP_VISIBILITY,
|
|
198
|
-
navigationPopupOpened: visible,
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const handleChangeNavigationItemPopupVisibility = (visible) => {
|
|
203
|
-
dispatch({
|
|
204
|
-
type: CHANGE_NAVIGATION_ITEM_POPUP_VISIBILITY,
|
|
205
|
-
navigationItemPopupOpened: visible,
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const handleChangeNavigationData = (payload, forceClosePopups) => {
|
|
210
|
-
dispatch({
|
|
211
|
-
type: CHANGE_NAVIGATION_DATA,
|
|
212
|
-
changedActiveItem: payload,
|
|
213
|
-
forceClosePopups,
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const handleResetNavigationData = () => {
|
|
218
|
-
dispatch({
|
|
219
|
-
type: RESET_NAVIGATION_DATA,
|
|
220
|
-
activeItem,
|
|
221
289
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (err.response.payload.data && err.response.payload.data.errorTitles) {
|
|
256
|
-
return toggleNotification({
|
|
257
|
-
type: 'warning',
|
|
258
|
-
message: {
|
|
259
|
-
id: formatMessage(
|
|
260
|
-
getTrad('notification.navigation.error'),
|
|
261
|
-
{ ...err.response.payload.data, errorTitles: err.response.payload.data.errorTitles.join(' and ') },
|
|
262
|
-
)
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
toggleNotification({
|
|
267
|
-
type: 'warning',
|
|
268
|
-
message: { id: getTrad('notification.error') },
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
return (
|
|
274
|
-
<DataManagerContext.Provider
|
|
275
|
-
value={{
|
|
276
|
-
items,
|
|
277
|
-
activeItem,
|
|
278
|
-
initialData,
|
|
279
|
-
changedActiveItem,
|
|
280
|
-
config,
|
|
281
|
-
navigationPopupOpened,
|
|
282
|
-
navigationItemPopupOpened,
|
|
283
|
-
isLoading:
|
|
284
|
-
isLoading ||
|
|
285
|
-
isLoadingForDataToBeSet ||
|
|
286
|
-
isLoadingForDetailsDataToBeSet,
|
|
287
|
-
isLoadingForAdditionalDataToBeSet,
|
|
288
|
-
isLoadingForSubmit,
|
|
289
|
-
handleChangeNavigationPopupVisibility,
|
|
290
|
-
handleChangeNavigationItemPopupVisibility,
|
|
291
|
-
handleChangeSelection,
|
|
292
|
-
handleChangeNavigationData,
|
|
293
|
-
handleResetNavigationData,
|
|
294
|
-
handleSubmitNavigation,
|
|
295
|
-
getContentTypeItems,
|
|
296
|
-
isInDevelopmentMode,
|
|
297
|
-
error,
|
|
298
|
-
}}
|
|
299
|
-
>
|
|
300
|
-
{isLoading ? <LoadingIndicatorPage /> : children}
|
|
301
|
-
</DataManagerContext.Provider>
|
|
302
|
-
);
|
|
290
|
+
const hardReset = () => {
|
|
291
|
+
return getDataRef.current();
|
|
292
|
+
};
|
|
293
|
+
return (react_1.default.createElement(DataManagerContext_1.default.Provider, { value: {
|
|
294
|
+
items: passedActiveItems,
|
|
295
|
+
activeItem,
|
|
296
|
+
initialData,
|
|
297
|
+
changedActiveItem,
|
|
298
|
+
config,
|
|
299
|
+
navigationPopupOpened,
|
|
300
|
+
navigationItemPopupOpened,
|
|
301
|
+
isLoading: isLoading ||
|
|
302
|
+
isLoadingForDataToBeSet ||
|
|
303
|
+
isLoadingForDetailsDataToBeSet,
|
|
304
|
+
isLoadingForAdditionalDataToBeSet,
|
|
305
|
+
isLoadingForSubmit,
|
|
306
|
+
handleChangeNavigationPopupVisibility,
|
|
307
|
+
handleChangeNavigationItemPopupVisibility,
|
|
308
|
+
handleChangeSelection,
|
|
309
|
+
handleLocalizationSelection,
|
|
310
|
+
handleChangeNavigationData,
|
|
311
|
+
handleResetNavigationData,
|
|
312
|
+
handleSubmitNavigation,
|
|
313
|
+
handleI18nCopy,
|
|
314
|
+
getContentTypeItems,
|
|
315
|
+
isInDevelopmentMode,
|
|
316
|
+
error,
|
|
317
|
+
availableLocale,
|
|
318
|
+
readNavigationItemFromLocale,
|
|
319
|
+
handleNavigationsDeletion,
|
|
320
|
+
hardReset,
|
|
321
|
+
} }, isLoading ? react_1.default.createElement(helper_plugin_1.LoadingIndicatorPage, null) : children));
|
|
303
322
|
};
|
|
304
|
-
|
|
305
323
|
DataManagerProvider.propTypes = {
|
|
306
|
-
|
|
324
|
+
children: prop_types_1.default.node.isRequired,
|
|
307
325
|
};
|
|
308
|
-
|
|
309
|
-
|
|
326
|
+
exports.default = (0, react_1.memo)(DataManagerProvider);
|
|
327
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default reducer;
|
|
2
|
+
declare function reducer(state: any, action: any): any;
|
|
3
|
+
export namespace initialState {
|
|
4
|
+
const items: never[];
|
|
5
|
+
const activeItem: undefined;
|
|
6
|
+
const changedActiveItem: undefined;
|
|
7
|
+
const navigationPopupOpened: boolean;
|
|
8
|
+
const navigationItemPopupOpened: boolean;
|
|
9
|
+
const config: {};
|
|
10
|
+
const isLoading: boolean;
|
|
11
|
+
const isLoadingForDataToBeSet: boolean;
|
|
12
|
+
const isLoadingForDetailsDataToBeSet: boolean;
|
|
13
|
+
const isLoadingForAdditionalDataToBeSet: boolean;
|
|
14
|
+
const isLoadingForSubmit: boolean;
|
|
15
|
+
const error: undefined;
|
|
16
|
+
const i18nEnabled: boolean;
|
|
17
|
+
const availableLocale: never[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=reducer.d.ts.map
|