strapi-plugin-navigation 2.1.0-beta.1 → 2.2.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.
Files changed (131) hide show
  1. package/README.md +24 -8
  2. package/admin/src/components/AdditionalFieldInput/index.d.ts +5 -0
  3. package/admin/src/components/AdditionalFieldInput/index.js +71 -0
  4. package/admin/src/components/AdditionalFieldInput/types.d.ts +14 -0
  5. package/admin/src/components/AdditionalFieldInput/types.js +3 -0
  6. package/admin/src/components/Item/index.js +11 -18
  7. package/admin/src/components/RestartAlert/index.d.ts +1 -1
  8. package/admin/src/components/TextArrayInput/index.d.ts +14 -0
  9. package/admin/src/components/TextArrayInput/index.js +45 -0
  10. package/admin/src/hooks/useAllContentTypes.d.ts +1 -4
  11. package/admin/src/hooks/useAllContentTypes.js +3 -7
  12. package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +9 -0
  13. package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +51 -0
  14. package/admin/src/hooks/useNavigationConfig.d.ts +1 -1
  15. package/admin/src/hooks/useNavigationConfig.js +6 -6
  16. package/admin/src/hooks/useNavigationManager.d.ts +7 -0
  17. package/admin/src/hooks/useNavigationManager.js +41 -0
  18. package/admin/src/pages/DataManagerProvider/index.d.ts +1 -1
  19. package/admin/src/pages/DataManagerProvider/index.js +46 -10
  20. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +12 -0
  21. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +112 -0
  22. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +12 -0
  23. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +20 -0
  24. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +11 -0
  25. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +105 -0
  26. package/admin/src/pages/SettingsPage/index.d.ts +2 -1
  27. package/admin/src/pages/SettingsPage/index.js +109 -74
  28. package/admin/src/pages/SettingsPage/types.d.ts +32 -0
  29. package/admin/src/pages/SettingsPage/types.js +3 -0
  30. package/admin/src/pages/SettingsPage/utils/form.d.ts +18 -0
  31. package/admin/src/pages/SettingsPage/utils/form.js +34 -0
  32. package/admin/src/pages/SettingsPage/utils/functions.d.ts +2 -2
  33. package/admin/src/pages/SettingsPage/utils/functions.js +1 -1
  34. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +3 -9
  35. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +2 -47
  36. package/admin/src/pages/View/components/NavigationHeader/index.js +11 -6
  37. package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +3 -49
  38. package/admin/src/pages/View/components/NavigationItemForm/index.js +233 -153
  39. package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +90 -0
  40. package/admin/src/pages/View/components/NavigationItemForm/types.js +3 -0
  41. package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +24 -43
  42. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +84 -48
  43. package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +4 -1
  44. package/admin/src/pages/View/components/NavigationItemPopup/index.js +32 -7
  45. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +4 -0
  46. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +11 -0
  47. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +9 -0
  48. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.js +139 -0
  49. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +9 -0
  50. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.js +34 -0
  51. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +9 -0
  52. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.js +53 -0
  53. package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +24 -0
  54. package/admin/src/pages/View/components/NavigationManager/Footer/index.js +13 -0
  55. package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +20 -0
  56. package/admin/src/pages/View/components/NavigationManager/Form/index.js +103 -0
  57. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +9 -0
  58. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.js +59 -0
  59. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +10 -0
  60. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.js +62 -0
  61. package/admin/src/pages/View/components/NavigationManager/index.d.ts +11 -0
  62. package/admin/src/pages/View/components/NavigationManager/index.js +190 -0
  63. package/admin/src/pages/View/components/NavigationManager/types.d.ts +40 -0
  64. package/admin/src/pages/View/components/NavigationManager/types.js +3 -0
  65. package/admin/src/pages/View/index.d.ts +1 -1
  66. package/admin/src/pages/View/index.js +11 -9
  67. package/admin/src/pages/View/utils/parsers.d.ts +7 -1
  68. package/admin/src/pages/View/utils/parsers.js +18 -9
  69. package/admin/src/translations/en.json +68 -0
  70. package/admin/src/translations/index.d.ts +2 -1
  71. package/admin/src/translations/index.js +1 -1
  72. package/admin/src/utils/api.d.ts +8 -7
  73. package/admin/src/utils/api.js +6 -41
  74. package/admin/src/utils/enums.d.ts +25 -0
  75. package/admin/src/utils/enums.js +30 -0
  76. package/admin/src/utils/functions.d.ts +16 -0
  77. package/admin/src/utils/functions.js +46 -0
  78. package/admin/src/utils/index.d.ts +3 -4
  79. package/admin/src/utils/index.js +16 -24
  80. package/package.json +6 -7
  81. package/server/config/index.js +6 -4
  82. package/server/config/setupStrategy.js +13 -1
  83. package/server/content-types/index.d.ts +5 -25
  84. package/server/content-types/navigation/index.d.ts +0 -7
  85. package/server/content-types/navigation/index.js +0 -2
  86. package/server/content-types/navigation/schema.js +1 -1
  87. package/server/content-types/navigation-item/index.d.ts +5 -13
  88. package/server/content-types/navigation-item/index.js +0 -2
  89. package/server/content-types/navigation-item/schema.d.ts +5 -0
  90. package/server/content-types/navigation-item/schema.js +5 -0
  91. package/server/content-types/navigations-items-related/index.d.ts +0 -5
  92. package/server/content-types/navigations-items-related/index.js +0 -2
  93. package/server/controllers/admin.js +67 -14
  94. package/server/controllers/client.js +43 -19
  95. package/server/graphql/queries/render-navigation.d.ts +0 -2
  96. package/server/graphql/queries/render-navigation.js +10 -8
  97. package/server/graphql/types/navigation-item.d.ts +2 -1
  98. package/server/graphql/types/navigation-item.js +26 -2
  99. package/server/i18n/graphQLEnhancers.js +2 -1
  100. package/server/i18n/serviceEnhancers.d.ts +2 -1
  101. package/server/i18n/serviceEnhancers.js +45 -6
  102. package/server/i18n/types.d.ts +6 -0
  103. package/server/index.d.ts +5 -25
  104. package/server/navigation/setupStrategy.js +3 -1
  105. package/server/routes/admin.js +10 -0
  106. package/server/services/admin.js +104 -37
  107. package/server/services/client.js +64 -21
  108. package/server/services/common.js +26 -7
  109. package/server/utils/constant.d.ts +0 -3
  110. package/server/utils/constant.js +1 -2
  111. package/server/utils/functions.d.ts +13 -12
  112. package/server/utils/functions.js +62 -22
  113. package/strapi-server.d.ts +5 -25
  114. package/tsconfig.tsbuildinfo +1 -1
  115. package/types/config.d.ts +6 -2
  116. package/types/contentTypes.d.ts +22 -1
  117. package/types/controllers.d.ts +21 -8
  118. package/types/services.d.ts +20 -5
  119. package/types/utils.d.ts +10 -1
  120. package/types/utils.js +18 -3
  121. package/utils/InvalidParamNavigationError.js +0 -3
  122. package/admin/src/pages/View/utils/enums.d.ts +0 -9
  123. package/admin/src/pages/View/utils/enums.js +0 -12
  124. package/admin/src/utils/getTrad.d.ts +0 -3
  125. package/admin/src/utils/getTrad.js +0 -9
  126. package/server/content-types/navigation/lifecycle.d.ts +0 -9
  127. package/server/content-types/navigation/lifecycle.js +0 -10
  128. package/server/content-types/navigation-item/lifecycle.d.ts +0 -16
  129. package/server/content-types/navigation-item/lifecycle.js +0 -31
  130. package/server/content-types/navigations-items-related/lifecycle.d.ts +0 -8
  131. package/server/content-types/navigations-items-related/lifecycle.js +0 -22
package/README.md CHANGED
@@ -102,6 +102,12 @@ yarn develop --watch-admin
102
102
 
103
103
  The **UI Navigation** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
104
104
 
105
+ You can manage your multiple navigation containers by going to the **Navigation** manage view by clicking "Manage" button.
106
+
107
+ <div style="margin: 20px 0" align="center">
108
+ <img style="width: 100%; height: auto;" src="public/assets/manager-view.png" alt="Navigation Manager View" />
109
+ </div>
110
+
105
111
  As a next step you must configure your the plugin by the way you want to. See [**Configuration**](#🔧-configuration) section.
106
112
 
107
113
  All done. Enjoy 🎉
@@ -112,7 +118,7 @@ Complete installation requirements are exact same as for Strapi itself and can b
112
118
 
113
119
  **Supported Strapi versions**:
114
120
 
115
- - Strapi v4.1.8 (recently tested)
121
+ - Strapi v4.2.0 (recently tested)
116
122
  - Strapi v4.x
117
123
 
118
124
  > This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v3).
@@ -149,25 +155,38 @@ Config for this plugin is stored as a part of the `config/plugins.js` or `config
149
155
  navigation: {
150
156
  enabled: true,
151
157
  config: {
152
- additionalFields: ['audience'],
158
+ additionalFields: ['audience', { name: 'my_custom_field', type: 'boolean', label: 'My custom field' }],
153
159
  contentTypes: ['api::page.page'],
154
160
  contentTypesNameFields: {
155
161
  'api::page.page': ['title']
156
162
  },
157
163
  allowedLevels: 2,
158
164
  gql: {...},
165
+ slugify: {
166
+ customReplacements: [
167
+ ["🤔", "thinking"],
168
+ ],
169
+ }
159
170
  }
160
171
  }
161
172
  });
162
173
  ```
163
174
 
164
175
  ### Properties
165
- - `additionalFields` - Additional fields: 'audience', more in the future
176
+ - `additionalFields` - Additional fields for navigation items. More **[ here ](#additional-fields)**
166
177
  - `allowedLevels` - Maximum level for which you're able to mark item as "Menu attached"
167
178
  - `contentTypes` - UIDs of related content types
168
179
  - `contentTypesNameFields` - Definition of content type title fields like `'api::<collection name>.<content type name>': ['field_name_1', 'field_name_2']`, if not set titles are pulled from fields like `['title', 'subject', 'name']`. **TIP** - Proper content type uid you can find in the URL of Content Manager where you're managing relevant entities like: `admin/content-manager/collectionType/< THE UID HERE >?page=1&pageSize=10&sort=Title:ASC&plugins[i18n][locale]=en`
169
180
  - `gql` - If you're using GraphQL that's the right place to put all necessary settings. More **[ here ](#gql-configuration)**
170
181
  - `i18nEnabled` - should you want to manage multi-locale content via navigation set this value `Enabled`. More **[ here ](#i18n-internationalization)**
182
+ - `slugify` - allows to extend configuration of our "slugging" solution of choice. To learn more visit the [documentation](https://github.com/sindresorhus/slugify#api). It can be left unset since it's optional. **This option can only be handled by configuration in config file**.
183
+
184
+ ### Properties
185
+
186
+ ### Additional Fields
187
+ It is advised to configure additional fields through the plugin's Settings Page. There you can find the table of custom fields and toggle input for the audience field. When enabled, the audience field can be customized through the content manager. Custom fields can be added, edited, toggled, and removed with the use of the table provided on the Settings Page. When removing custom fields be advised that their values in navigation items will be lost. Disabling the custom fields will not affect the data and can be done with no consequence of loosing information.
188
+
189
+ Creating configuration for additional fields with the `config.js` file should be done with caution. Config object contains the `additionalFields` property of type `Array<CustomField | 'audience'>`, where CustomField is of type `{type: 'string' | 'boolean', name: string, label: string}`. When creating custom fields be advised that the `name` property has to be unique. When editing a custom field it is advised not to edit its `name` and `type` properties. After config has been restored the custom fields that are not present in `config.js` file will be deleted and their values in navigation items will be lost.
171
190
 
172
191
  ## 🔧 GQL Configuration
173
192
  Using navigation with GraphQL requires both plugins to be installed and working. You can find installation guide for GraphQL plugin **[here](https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#graphql)**. To properly configure GQL to work with navigation you should provide `gql` prop. This should contain union types that will be used to define GQL response format for your data while fetching:
@@ -573,11 +592,8 @@ query {
573
592
  "title": "Another page",
574
593
  "path": "/another",
575
594
  "related": {
576
- "id": 2,
577
- "attributes": {
578
- "__typename": "Page",
579
- "Title": "dfdfdf"
580
- }
595
+ "__typename": "Page",
596
+ "Title": "Eg. Page title"
581
597
  },
582
598
  "items": []
583
599
  }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { AdditionalFieldInputProps } from './types';
3
+ declare const AdditionalFieldInput: React.FC<AdditionalFieldInputProps>;
4
+ export default AdditionalFieldInput;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,71 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const types_1 = require("../../../../types");
28
+ const ToggleInput_1 = require("@strapi/design-system/ToggleInput");
29
+ const TextInput_1 = require("@strapi/design-system/TextInput");
30
+ const Select_1 = require("@strapi/design-system/Select");
31
+ const helper_plugin_1 = require("@strapi/helper-plugin");
32
+ const translations_1 = require("../../translations");
33
+ const lodash_1 = require("lodash");
34
+ const react_intl_1 = require("react-intl");
35
+ const DEFAULT_STRING_VALUE = "";
36
+ const handlerFactory = ({ field, prop, onChange }) => ({ target }) => {
37
+ onChange(field.name, target[prop]);
38
+ };
39
+ const AdditionalFieldInput = ({ field, isLoading, onChange, value, error }) => {
40
+ const toggleNotification = (0, helper_plugin_1.useNotification)();
41
+ const { formatMessage } = (0, react_intl_1.useIntl)();
42
+ const defaultInputProps = (0, react_1.useMemo)(() => ({
43
+ id: field.name,
44
+ name: field.name,
45
+ label: field.label,
46
+ disabled: isLoading,
47
+ error: error && formatMessage(error),
48
+ }), [field, isLoading, error]);
49
+ const handleBoolean = (0, react_1.useMemo)(() => handlerFactory({ field, onChange, prop: "checked" }), [onChange, field]);
50
+ const handleString = (0, react_1.useMemo)(() => handlerFactory({ field, onChange, prop: "value" }), [onChange, field]);
51
+ switch (field.type) {
52
+ case 'boolean':
53
+ if (!(0, lodash_1.isNil)(value))
54
+ (0, types_1.assertBoolean)(value);
55
+ return (react_1.default.createElement(ToggleInput_1.ToggleInput, { ...defaultInputProps, checked: !!value, onChange: handleBoolean, onLabel: "true", offLabel: "false" }));
56
+ case 'string':
57
+ if (!(0, lodash_1.isNil)(value))
58
+ (0, types_1.assertString)(value);
59
+ return (react_1.default.createElement(TextInput_1.TextInput, { ...defaultInputProps, onChange: handleString, value: value || DEFAULT_STRING_VALUE }));
60
+ case 'select':
61
+ return (react_1.default.createElement(Select_1.Select, { ...defaultInputProps, onChange: (v) => onChange(field.name, v), value: (0, lodash_1.isNil)(value) ? field.multi ? [] : null : value, multi: field.multi, withTags: field.multi }, field.options.map((option, index) => (react_1.default.createElement(Select_1.Option, { key: `${field.name}-option-${index}`, value: option }, option)))));
62
+ default:
63
+ toggleNotification({
64
+ type: 'warning',
65
+ message: (0, translations_1.getTrad)('notification.error.customField.type'),
66
+ });
67
+ throw new Error(`Type of custom field is unsupported`);
68
+ }
69
+ };
70
+ exports.default = AdditionalFieldInput;
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ import { MessageDescriptor } from "react-intl";
2
+ import { NavigationItemCustomField } from "../../../../types";
3
+ export declare type AdditionalFieldInputProps = {
4
+ field: NavigationItemCustomField;
5
+ isLoading: boolean;
6
+ onChange: (name: string, value: string) => void;
7
+ value: string | boolean | string[] | null;
8
+ error: MessageDescriptor | null;
9
+ };
10
+ export declare type TargetProp = "value" | "checked";
11
+ export declare type Input = {
12
+ prop: TargetProp;
13
+ } & Pick<AdditionalFieldInputProps, "onChange" | "field">;
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -37,7 +37,6 @@ const Link_1 = require("@strapi/design-system/Link");
37
37
  const TextButton_1 = require("@strapi/design-system/TextButton");
38
38
  const Typography_1 = require("@strapi/design-system/Typography");
39
39
  const icons_1 = require("@strapi/icons");
40
- const enums_1 = require("../../pages/View/utils/enums");
41
40
  const ItemCardHeader_1 = __importDefault(require("./ItemCardHeader"));
42
41
  const NavigationItemList_1 = __importDefault(require("../NavigationItemList"));
43
42
  const Wrapper_1 = __importDefault(require("./Wrapper"));
@@ -48,11 +47,11 @@ const utils_1 = require("../../utils");
48
47
  const CollapseButton_1 = __importDefault(require("../CollapseButton"));
49
48
  const Item = (props) => {
50
49
  const { item, isLast = false, level = 0, levelPath = '', allowedLevels, relatedRef, isParentAttachedToMenu, onItemLevelAdd, onItemRemove, onItemRestore, onItemEdit, onItemReOrder, onItemToggleCollapse, error, displayChildren, config = {}, } = props;
51
- const { viewId, title, type, path, removed, externalPath, menuAttached, collapsed, } = item;
52
- const { contentTypes, contentTypesNameFields } = config;
53
- const isExternal = type === enums_1.navigationItemType.EXTERNAL;
54
- const isWrapper = type === enums_1.navigationItemType.WRAPPER;
55
- const isHandledByPublishFlow = contentTypes.find(_ => _.uid === relatedRef.__collectionUid)?.draftAndPublish;
50
+ const { viewId, title, type, path, removed, externalPath, menuAttached, collapsed, structureId, items = [], } = item;
51
+ const { contentTypes = [], contentTypesNameFields } = config;
52
+ const isExternal = type === utils_1.navigationItemType.EXTERNAL;
53
+ const isWrapper = type === utils_1.navigationItemType.WRAPPER;
54
+ const isHandledByPublishFlow = contentTypes.find(_ => _.uid === relatedRef?.__collectionUid)?.draftAndPublish;
56
55
  const isPublished = isHandledByPublishFlow && relatedRef.publishedAt;
57
56
  const isNextMenuAllowedLevel = (0, lodash_1.isNumber)(allowedLevels) ? level < (allowedLevels - 1) : true;
58
57
  const isMenuAllowedLevel = (0, lodash_1.isNumber)(allowedLevels) ? level < allowedLevels : true;
@@ -94,7 +93,7 @@ const Item = (props) => {
94
93
  const [{ isDragging }, drag, dragPreview] = (0, react_dnd_1.useDrag)({
95
94
  type: `${utils_1.ItemTypes.NAVIGATION_ITEM}_${levelPath}`,
96
95
  item: () => {
97
- return { ...item, relatedRef };
96
+ return item;
98
97
  },
99
98
  collect: monitor => ({
100
99
  isDragging: monitor.isDragging(),
@@ -111,29 +110,23 @@ const Item = (props) => {
111
110
  const { isSingle } = contentType;
112
111
  return `/content-manager/${isSingle ? 'singleType' : 'collectionType'}/${entity?.__collectionUid}${!isSingle ? '/' + entity?.id : ''}`;
113
112
  };
113
+ const onNewItemClick = (0, react_1.useCallback)((event) => onItemLevelAdd(event, viewId, isNextMenuAllowedLevel, absolutePath, menuAttached, `${structureId}.${items.length}`), [viewId, isNextMenuAllowedLevel, absolutePath, menuAttached, structureId, items]);
114
114
  return (react_1.default.createElement(Wrapper_1.default, { level: level, isLast: isLast, style: { opacity: isDragging ? 0.2 : 1 }, ref: refs ? refs.dropRef : null },
115
115
  react_1.default.createElement(Card_1.Card, { style: { width: "728px", zIndex: 1, position: "relative", overflow: 'hidden' } },
116
116
  removed && (react_1.default.createElement(ItemCardRemovedOverlay_1.ItemCardRemovedOverlay, null)),
117
117
  react_1.default.createElement("div", { ref: refs.previewRef },
118
118
  react_1.default.createElement(Card_1.CardBody, null,
119
- react_1.default.createElement(ItemCardHeader_1.default, { title: title, path: isExternal ? externalPath : absolutePath, icon: isExternal ? icons_1.Earth : isWrapper ? icons_1.Cog : icons_1.Link, onItemRemove: () => onItemRemove({
120
- ...item,
121
- relatedRef,
122
- }), onItemEdit: () => onItemEdit({
119
+ react_1.default.createElement(ItemCardHeader_1.default, { title: title, path: isExternal ? externalPath : absolutePath, icon: isExternal ? icons_1.Earth : isWrapper ? icons_1.Cog : icons_1.Link, onItemRemove: () => onItemRemove(item), onItemEdit: () => onItemEdit({
123
120
  ...item,
124
121
  isMenuAllowedLevel,
125
122
  isParentAttachedToMenu,
126
- relatedRef,
127
- }, levelPath, isParentAttachedToMenu), onItemRestore: () => onItemRestore({
128
- ...item,
129
- relatedRef,
130
- }), dragRef: refs.dragRef, removed: removed })),
123
+ }, levelPath, isParentAttachedToMenu), onItemRestore: () => onItemRestore(item), dragRef: refs.dragRef, removed: removed })),
131
124
  react_1.default.createElement(Divider_1.Divider, null),
132
125
  !isExternal && (react_1.default.createElement(Card_1.CardBody, { style: { padding: '8px' } },
133
126
  react_1.default.createElement(Flex_1.Flex, { style: { width: '100%' }, direction: "row", alignItems: "center", justifyContent: "space-between" },
134
127
  react_1.default.createElement(Flex_1.Flex, null,
135
- !(0, lodash_1.isEmpty)(item.items) && react_1.default.createElement(CollapseButton_1.default, { toggle: () => onItemToggleCollapse({ ...item, relatedRef }), collapsed: collapsed, itemsCount: item.items.length }),
136
- react_1.default.createElement(TextButton_1.TextButton, { disabled: removed, startIcon: react_1.default.createElement(icons_1.Plus, null), onClick: (e) => onItemLevelAdd(e, viewId, isNextMenuAllowedLevel, absolutePath, menuAttached) },
128
+ !(0, lodash_1.isEmpty)(item.items) && react_1.default.createElement(CollapseButton_1.default, { toggle: () => onItemToggleCollapse(item), collapsed: collapsed, itemsCount: item.items.length }),
129
+ react_1.default.createElement(TextButton_1.TextButton, { disabled: removed, startIcon: react_1.default.createElement(icons_1.Plus, null), onClick: onNewItemClick },
137
130
  react_1.default.createElement(Typography_1.Typography, { variant: "pi", fontWeight: "bold", textColor: removed ? "neutral600" : "primary600" }, (0, utils_1.getMessage)("components.navigationItem.action.newItem")))),
138
131
  relatedItemLabel && (react_1.default.createElement(Flex_1.Flex, { justifyContent: 'center', alignItems: 'center' },
139
132
  isHandledByPublishFlow && (react_1.default.createElement(ItemCardBadge_1.default, { borderColor: `${relatedBadgeColor}200`, backgroundColor: `${relatedBadgeColor}100`, textColor: `${relatedBadgeColor}600`, className: "action", small: true }, (0, utils_1.getMessage)({ id: `components.navigationItem.badge.${isPublished ? 'published' : 'draft'}` }))),
@@ -1,3 +1,3 @@
1
- declare var _default: any;
1
+ declare const _default: any;
2
2
  export default _default;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Effect } from '../../../../types';
3
+ interface IProps {
4
+ onChange: Effect<string[]>;
5
+ initialValue?: string[];
6
+ id?: string;
7
+ name?: string;
8
+ label?: string;
9
+ disabled?: boolean;
10
+ error?: string | string[];
11
+ }
12
+ declare const TextArrayInput: React.FC<IProps>;
13
+ export default TextArrayInput;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,45 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const TextInput_1 = require("@strapi/design-system/TextInput");
28
+ const lodash_1 = require("lodash");
29
+ const TextArrayInput = ({ onChange, initialValue, ...props }) => {
30
+ const [value, setValue] = (0, react_1.useState)((0, lodash_1.isArray)(initialValue)
31
+ ? initialValue.reduce((acc, cur) => `${acc}${cur}; `, "")
32
+ : "");
33
+ const handleOnChange = ({ target: { value } }) => {
34
+ const newValue = value;
35
+ const valuesArray = newValue
36
+ .split(';')
37
+ .map(v => v.trim())
38
+ .filter(v => !!v.length);
39
+ setValue(value);
40
+ onChange(valuesArray);
41
+ };
42
+ return (react_1.default.createElement(TextInput_1.TextInput, { ...props, onChange: handleOnChange, value: value }));
43
+ };
44
+ exports.default = TextArrayInput;
45
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,3 @@
1
+ declare const useAllContentTypes: () => Pick<any, "data" | "isLoading" | "error">;
1
2
  export default useAllContentTypes;
2
- declare function useAllContentTypes(): {
3
- data: any;
4
- isLoading: any;
5
- };
6
3
  //# sourceMappingURL=useAllContentTypes.d.ts.map
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_query_1 = require("react-query");
4
- const helper_plugin_1 = require("@strapi/helper-plugin");
5
- const api_1 = require("../utils/api");
6
- const useAllContentTypes = () => {
7
- const toggleNotification = (0, helper_plugin_1.useNotification)();
8
- const { isLoading, data } = (0, react_query_1.useQuery)('contentTypes', () => (0, api_1.fetchAllContentTypes)(toggleNotification));
9
- return { data, isLoading, };
10
- };
4
+ const lodash_1 = require("lodash");
5
+ const utils_1 = require("../utils");
6
+ const useAllContentTypes = () => (0, lodash_1.pick)((0, react_query_1.useQuery)('contentTypes', () => (0, utils_1.fetchAllContentTypes)()), ["data", "isLoading", "error"]);
11
7
  exports.default = useAllContentTypes;
12
8
  //# sourceMappingURL=useAllContentTypes.js.map
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { ConfirmEffect } from "../pages/View/components/I18nCopyNavigationItems";
3
+ export declare const useI18nCopyNavigationItemsModal: (onConfirm: ConfirmEffect) => {
4
+ setI18nCopyModalOpened: React.Dispatch<React.SetStateAction<boolean>>;
5
+ setI18nCopySourceLocale: React.Dispatch<React.SetStateAction<string | undefined>>;
6
+ i18nCopyItemsModal: JSX.Element | null;
7
+ i18nCopySourceLocale: string | undefined;
8
+ };
9
+ //# sourceMappingURL=useI18nCopyNavigationItemsModal.d.ts.map
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useI18nCopyNavigationItemsModal = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const I18nCopyNavigationItems_1 = require("../pages/View/components/I18nCopyNavigationItems");
29
+ const useI18nCopyNavigationItemsModal = (onConfirm) => {
30
+ const [isOpened, setIsOpened] = (0, react_1.useState)(false);
31
+ const [sourceLocale, setSourceLocale] = (0, react_1.useState)(undefined);
32
+ const onCancel = (0, react_1.useCallback)(() => {
33
+ setIsOpened(false);
34
+ }, [setIsOpened]);
35
+ const onConfirmWithModalClose = (0, react_1.useCallback)(() => {
36
+ if (!sourceLocale) {
37
+ return;
38
+ }
39
+ onConfirm(sourceLocale);
40
+ setIsOpened(false);
41
+ }, [onConfirm, sourceLocale]);
42
+ const modal = (0, react_1.useMemo)(() => isOpened ? (react_1.default.createElement(I18nCopyNavigationItems_1.I18nCopyNavigationItemsModal, { onConfirm: onConfirmWithModalClose, onCancel: onCancel })) : null, [isOpened, onConfirmWithModalClose, onCancel]);
43
+ return (0, react_1.useMemo)(() => ({
44
+ setI18nCopyModalOpened: setIsOpened,
45
+ setI18nCopySourceLocale: setSourceLocale,
46
+ i18nCopyItemsModal: modal,
47
+ i18nCopySourceLocale: sourceLocale,
48
+ }), [setSourceLocale, setIsOpened, modal, sourceLocale]);
49
+ };
50
+ exports.useI18nCopyNavigationItemsModal = useI18nCopyNavigationItemsModal;
51
+ //# sourceMappingURL=useI18nCopyNavigationItemsModal.js.map
@@ -2,7 +2,7 @@ export default useNavigationConfig;
2
2
  declare function useNavigationConfig(): {
3
3
  data: any;
4
4
  isLoading: any;
5
- err: any;
5
+ error: any;
6
6
  submitMutation: (...args: any[]) => Promise<void>;
7
7
  restoreMutation: (...args: any[]) => Promise<void>;
8
8
  restartMutation: (...args: any[]) => Promise<void>;
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_query_1 = require("react-query");
4
4
  const helper_plugin_1 = require("@strapi/helper-plugin");
5
- const api_1 = require("../utils/api");
5
+ const utils_1 = require("../utils");
6
6
  const translations_1 = require("../translations");
7
7
  const useNavigationConfig = () => {
8
8
  const queryClient = (0, react_query_1.useQueryClient)();
9
9
  const toggleNotification = (0, helper_plugin_1.useNotification)();
10
- const { isLoading, data, err } = (0, react_query_1.useQuery)('navigationConfig', () => (0, api_1.fetchNavigationConfig)(toggleNotification));
10
+ const { isLoading, data, error } = (0, react_query_1.useQuery)('navigationConfig', () => (0, utils_1.fetchNavigationConfig)(toggleNotification));
11
11
  const handleError = (type) => {
12
12
  toggleNotification({
13
13
  type: 'warning',
@@ -23,7 +23,7 @@ const useNavigationConfig = () => {
23
23
  };
24
24
  const submitMutation = async (...args) => {
25
25
  try {
26
- await (0, api_1.updateNavigationConfig)(...args);
26
+ await (0, utils_1.updateNavigationConfig)(...args);
27
27
  await handleSuccess('submit');
28
28
  }
29
29
  catch (e) {
@@ -32,7 +32,7 @@ const useNavigationConfig = () => {
32
32
  };
33
33
  const restoreMutation = async (...args) => {
34
34
  try {
35
- await (0, api_1.restoreNavigationConfig)(...args);
35
+ await (0, utils_1.restoreNavigationConfig)(...args);
36
36
  await handleSuccess('restore');
37
37
  }
38
38
  catch (e) {
@@ -41,14 +41,14 @@ const useNavigationConfig = () => {
41
41
  };
42
42
  const restartMutation = async (...args) => {
43
43
  try {
44
- await (0, api_1.restartStrapi)(...args);
44
+ await (0, utils_1.restartStrapi)(...args);
45
45
  await handleSuccess('restart');
46
46
  }
47
47
  catch (e) {
48
48
  handleError('restart');
49
49
  }
50
50
  };
51
- return { data, isLoading, err, submitMutation, restoreMutation, restartMutation };
51
+ return { data, isLoading, error, submitMutation, restoreMutation, restartMutation };
52
52
  };
53
53
  exports.default = useNavigationConfig;
54
54
  //# sourceMappingURL=useNavigationConfig.js.map
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const useNavigationManager: () => {
3
+ navigationManagerModal: JSX.Element | null;
4
+ openNavigationManagerModal: () => void;
5
+ closeNavigationManagerModal: () => void;
6
+ };
7
+ //# sourceMappingURL=useNavigationManager.d.ts.map
@@ -0,0 +1,41 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useNavigationManager = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const NavigationManager_1 = require("../pages/View/components/NavigationManager");
29
+ const useNavigationManager = () => {
30
+ const [isOpened, setIsOpened] = (0, react_1.useState)(false);
31
+ const open = (0, react_1.useCallback)(() => setIsOpened(true), [setIsOpened]);
32
+ const close = (0, react_1.useCallback)(() => setIsOpened(false), [setIsOpened]);
33
+ const modal = (0, react_1.useMemo)(() => isOpened ? (react_1.default.createElement(NavigationManager_1.NavigationManager, { initialState: { view: "INITIAL" }, isOpened: true, onClose: close })) : null, [isOpened, close]);
34
+ return (0, react_1.useMemo)(() => ({
35
+ navigationManagerModal: modal,
36
+ openNavigationManagerModal: open,
37
+ closeNavigationManagerModal: close,
38
+ }), [modal, open, close]);
39
+ };
40
+ exports.useNavigationManager = useNavigationManager;
41
+ //# sourceMappingURL=useNavigationManager.js.map
@@ -1,4 +1,4 @@
1
- declare var _default: React.MemoExoticComponent<{
1
+ declare const _default: React.MemoExoticComponent<{
2
2
  ({ children }: {
3
3
  children: any;
4
4
  }): JSX.Element;