strapi-plugin-navigation 2.1.0 → 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 (116) hide show
  1. package/README.md +17 -7
  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 +2 -3
  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/useNavigationConfig.d.ts +1 -1
  13. package/admin/src/hooks/useNavigationConfig.js +6 -6
  14. package/admin/src/pages/DataManagerProvider/index.d.ts +1 -1
  15. package/admin/src/pages/DataManagerProvider/index.js +9 -11
  16. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +12 -0
  17. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +112 -0
  18. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +12 -0
  19. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +20 -0
  20. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +11 -0
  21. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +105 -0
  22. package/admin/src/pages/SettingsPage/index.d.ts +2 -1
  23. package/admin/src/pages/SettingsPage/index.js +109 -74
  24. package/admin/src/pages/SettingsPage/types.d.ts +32 -0
  25. package/admin/src/pages/SettingsPage/types.js +3 -0
  26. package/admin/src/pages/SettingsPage/utils/form.d.ts +18 -0
  27. package/admin/src/pages/SettingsPage/utils/form.js +34 -0
  28. package/admin/src/pages/SettingsPage/utils/functions.d.ts +2 -2
  29. package/admin/src/pages/SettingsPage/utils/functions.js +1 -1
  30. package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +3 -55
  31. package/admin/src/pages/View/components/NavigationItemForm/index.js +162 -177
  32. package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +90 -0
  33. package/admin/src/pages/View/components/NavigationItemForm/types.js +3 -0
  34. package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +24 -43
  35. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +78 -45
  36. package/admin/src/pages/View/components/NavigationItemPopup/index.js +1 -2
  37. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +4 -0
  38. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +11 -0
  39. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +9 -0
  40. package/admin/src/pages/View/components/NavigationManager/{List → AllNavigations}/index.js +32 -31
  41. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +9 -0
  42. package/admin/src/pages/View/components/NavigationManager/{Delete → DeletionConfirm}/index.js +18 -12
  43. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +9 -0
  44. package/admin/src/pages/View/components/NavigationManager/{Error → ErrorDetails}/index.js +10 -10
  45. package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +24 -0
  46. package/admin/src/pages/View/components/NavigationManager/Footer/index.js +13 -0
  47. package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +3 -2
  48. package/admin/src/pages/View/components/NavigationManager/Form/index.js +7 -2
  49. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +9 -0
  50. package/admin/src/pages/View/components/NavigationManager/{Edit → NavigationUpdate}/index.js +16 -11
  51. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +10 -0
  52. package/admin/src/pages/View/components/NavigationManager/{Create → NewNavigation}/index.js +16 -11
  53. package/admin/src/pages/View/components/NavigationManager/index.d.ts +3 -2
  54. package/admin/src/pages/View/components/NavigationManager/index.js +22 -21
  55. package/admin/src/pages/View/components/NavigationManager/types.d.ts +2 -15
  56. package/admin/src/pages/View/index.d.ts +1 -1
  57. package/admin/src/pages/View/index.js +1 -1
  58. package/admin/src/pages/View/utils/parsers.d.ts +1 -0
  59. package/admin/src/pages/View/utils/parsers.js +8 -7
  60. package/admin/src/translations/en.json +37 -0
  61. package/admin/src/translations/index.d.ts +2 -1
  62. package/admin/src/translations/index.js +1 -1
  63. package/admin/src/utils/api.d.ts +8 -7
  64. package/admin/src/utils/api.js +6 -41
  65. package/admin/src/utils/enums.d.ts +25 -0
  66. package/admin/src/utils/enums.js +30 -0
  67. package/admin/src/utils/functions.d.ts +16 -0
  68. package/admin/src/utils/functions.js +46 -0
  69. package/admin/src/utils/index.d.ts +3 -17
  70. package/admin/src/utils/index.js +16 -39
  71. package/package.json +5 -5
  72. package/server/config/index.js +6 -4
  73. package/server/config/setupStrategy.js +13 -1
  74. package/server/content-types/index.d.ts +5 -25
  75. package/server/content-types/navigation/index.d.ts +0 -7
  76. package/server/content-types/navigation/index.js +0 -2
  77. package/server/content-types/navigation-item/index.d.ts +5 -13
  78. package/server/content-types/navigation-item/index.js +0 -2
  79. package/server/content-types/navigation-item/schema.d.ts +5 -0
  80. package/server/content-types/navigation-item/schema.js +5 -0
  81. package/server/content-types/navigations-items-related/index.d.ts +0 -5
  82. package/server/content-types/navigations-items-related/index.js +0 -2
  83. package/server/controllers/admin.js +1 -1
  84. package/server/controllers/client.js +2 -1
  85. package/server/graphql/types/navigation-item.d.ts +2 -1
  86. package/server/graphql/types/navigation-item.js +26 -2
  87. package/server/index.d.ts +5 -25
  88. package/server/services/admin.js +26 -14
  89. package/server/services/client.js +64 -21
  90. package/server/services/common.js +25 -6
  91. package/server/utils/constant.d.ts +0 -3
  92. package/server/utils/constant.js +1 -2
  93. package/server/utils/functions.d.ts +12 -12
  94. package/server/utils/functions.js +60 -22
  95. package/strapi-server.d.ts +5 -25
  96. package/tsconfig.tsbuildinfo +1 -1
  97. package/types/config.d.ts +6 -2
  98. package/types/contentTypes.d.ts +22 -1
  99. package/types/services.d.ts +14 -5
  100. package/types/utils.d.ts +6 -1
  101. package/types/utils.js +15 -1
  102. package/admin/src/pages/View/components/NavigationManager/Create/index.d.ts +0 -9
  103. package/admin/src/pages/View/components/NavigationManager/Delete/index.d.ts +0 -8
  104. package/admin/src/pages/View/components/NavigationManager/Edit/index.d.ts +0 -8
  105. package/admin/src/pages/View/components/NavigationManager/Error/index.d.ts +0 -8
  106. package/admin/src/pages/View/components/NavigationManager/List/index.d.ts +0 -8
  107. package/admin/src/pages/View/utils/enums.d.ts +0 -9
  108. package/admin/src/pages/View/utils/enums.js +0 -12
  109. package/admin/src/utils/getTrad.d.ts +0 -3
  110. package/admin/src/utils/getTrad.js +0 -9
  111. package/server/content-types/navigation/lifecycle.d.ts +0 -9
  112. package/server/content-types/navigation/lifecycle.js +0 -10
  113. package/server/content-types/navigation-item/lifecycle.d.ts +0 -16
  114. package/server/content-types/navigation-item/lifecycle.js +0 -31
  115. package/server/content-types/navigations-items-related/lifecycle.d.ts +0 -8
  116. package/server/content-types/navigations-items-related/lifecycle.js +0 -22
@@ -1,45 +1,26 @@
1
- export namespace form {
2
- const fieldsToDisable: never[];
3
- const fieldsToOmit: never[];
4
- function schema(isSingleSelected: any): import("yup/lib/object").OptionalObjectSchema<{
5
- title: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
6
- uiRouterKey: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
7
- type: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
8
- path: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
9
- externalPath: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
10
- menuAttached: yup.BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
11
- relatedType: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
12
- related: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
13
- }, Record<string, any>, import("yup/lib/object").TypeOfShape<{
14
- title: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
15
- uiRouterKey: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
16
- type: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
17
- path: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
18
- externalPath: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
19
- menuAttached: yup.BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
20
- relatedType: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
21
- related: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
22
- }>>;
23
- function schema(isSingleSelected: any): import("yup/lib/object").OptionalObjectSchema<{
24
- title: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
25
- uiRouterKey: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
26
- type: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
27
- path: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
28
- externalPath: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
29
- menuAttached: yup.BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
30
- relatedType: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
31
- related: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
32
- }, Record<string, any>, import("yup/lib/object").TypeOfShape<{
33
- title: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
34
- uiRouterKey: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
35
- type: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
36
- path: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
37
- externalPath: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
38
- menuAttached: yup.BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
39
- relatedType: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
40
- related: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
41
- }>>;
42
- const inputsPrefix: string;
43
- }
44
1
  import * as yup from "yup";
2
+ import { NavigationItemAdditionalField } from "../../../../../../../types";
3
+ import { RawFormPayload } from "../types";
4
+ export declare const schemaFactory: (isSingleSelected: boolean, additionalFields: NavigationItemAdditionalField[]) => import("yup/lib/object").OptionalObjectSchema<{
5
+ title: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
6
+ uiRouterKey: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
7
+ type: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
8
+ path: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
9
+ externalPath: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
10
+ menuAttached: yup.BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
11
+ relatedType: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
12
+ related: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
13
+ additionalFields: import("yup/lib/object").OptionalObjectSchema<{}, Record<string, any>, import("yup/lib/object").TypeOfShape<{}>>;
14
+ }, Record<string, any>, import("yup/lib/object").TypeOfShape<{
15
+ title: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
16
+ uiRouterKey: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
17
+ type: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
18
+ path: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
19
+ externalPath: yup.StringSchema<string | undefined, Record<string, any>, string | undefined>;
20
+ menuAttached: yup.BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
21
+ relatedType: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
22
+ related: import("yup/lib/mixed").MixedSchema<any, Record<string, any>, any>;
23
+ additionalFields: import("yup/lib/object").OptionalObjectSchema<{}, Record<string, any>, import("yup/lib/object").TypeOfShape<{}>>;
24
+ }>>;
25
+ export declare const defaultValues: RawFormPayload;
45
26
  //# sourceMappingURL=form.d.ts.map
@@ -26,11 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.form = void 0;
29
+ exports.defaultValues = exports.schemaFactory = void 0;
30
30
  const yup = __importStar(require("yup"));
31
31
  const lodash_1 = require("lodash");
32
32
  const helper_plugin_1 = require("@strapi/helper-plugin");
33
- const enums_1 = require("../../../utils/enums");
33
+ const utils_1 = require("../../../../../utils");
34
34
  const pluginId_1 = __importDefault(require("../../../../../pluginId"));
35
35
  const externalPathRegexps = [
36
36
  /^mailto:[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/,
@@ -38,49 +38,82 @@ const externalPathRegexps = [
38
38
  /^#.*/,
39
39
  /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/,
40
40
  ];
41
- exports.form = {
42
- fieldsToDisable: [],
43
- fieldsToOmit: [],
44
- schema(isSingleSelected) {
45
- return yup.object({
46
- title: yup.string()
47
- .when('type', {
48
- is: val => val === enums_1.navigationItemType.EXTERNAL,
49
- then: yup.string()
50
- .required(helper_plugin_1.translatedErrors.required),
51
- otherwise: yup.string().notRequired(),
52
- }),
53
- uiRouterKey: yup.string().required(helper_plugin_1.translatedErrors.required),
54
- type: yup.string().required(helper_plugin_1.translatedErrors.required),
55
- path: yup.string()
56
- .when('type', {
57
- is: val => val === enums_1.navigationItemType.INTERNAL || (0, lodash_1.isNil)(val),
58
- then: yup.string().required(helper_plugin_1.translatedErrors.required),
59
- otherwise: yup.string().notRequired(),
60
- }),
61
- externalPath: yup.string()
62
- .when('type', {
63
- is: val => val === enums_1.navigationItemType.EXTERNAL,
64
- then: yup.string()
65
- .required(helper_plugin_1.translatedErrors.required)
66
- .test(`${pluginId_1.default}.popup.item.form.externalPath.validation.type`, externalPath => externalPath ? externalPathRegexps.some(re => re.test(externalPath)) : true),
67
- otherwise: yup.string().notRequired(),
68
- }),
69
- menuAttached: yup.boolean(),
70
- relatedType: yup.mixed()
71
- .when('type', {
72
- is: val => val === enums_1.navigationItemType.INTERNAL || (0, lodash_1.isNil)(val),
73
- then: isSingleSelected ? yup.mixed().notRequired() : yup.mixed().required(helper_plugin_1.translatedErrors.required),
74
- otherwise: yup.mixed().notRequired(),
75
- }),
76
- related: yup.mixed()
77
- .when('type', {
78
- is: val => val === enums_1.navigationItemType.INTERNAL || (0, lodash_1.isNil)(val),
79
- then: isSingleSelected ? yup.mixed().notRequired() : yup.mixed().required(helper_plugin_1.translatedErrors.required),
80
- otherwise: yup.mixed().notRequired(),
81
- }),
82
- });
41
+ const schemaFactory = (isSingleSelected, additionalFields) => {
42
+ return yup.object({
43
+ title: yup.string()
44
+ .when('type', {
45
+ is: (val) => val !== utils_1.navigationItemType.INTERNAL,
46
+ then: yup.string()
47
+ .required(helper_plugin_1.translatedErrors.required),
48
+ otherwise: yup.string().notRequired(),
49
+ }),
50
+ uiRouterKey: yup.string().required(helper_plugin_1.translatedErrors.required),
51
+ type: yup.string().required(helper_plugin_1.translatedErrors.required),
52
+ path: yup.string()
53
+ .when('type', {
54
+ is: (val) => val !== utils_1.navigationItemType.EXTERNAL || (0, lodash_1.isNil)(val),
55
+ then: yup.string().matches(/^\S+$/, "Invalid path string").required(helper_plugin_1.translatedErrors.required),
56
+ otherwise: yup.string().notRequired(),
57
+ }),
58
+ externalPath: yup.string()
59
+ .when('type', {
60
+ is: (val) => val === utils_1.navigationItemType.EXTERNAL,
61
+ then: yup.string()
62
+ .required(helper_plugin_1.translatedErrors.required)
63
+ .test(`${pluginId_1.default}.popup.item.form.externalPath.validation.type`, externalPath => externalPath ? externalPathRegexps.some(re => re.test(externalPath)) : true),
64
+ otherwise: yup.string().notRequired(),
65
+ }),
66
+ menuAttached: yup.boolean(),
67
+ relatedType: yup.mixed()
68
+ .when('type', {
69
+ is: (val) => val === utils_1.navigationItemType.INTERNAL || (0, lodash_1.isNil)(val),
70
+ then: isSingleSelected ? yup.mixed().notRequired() : yup.mixed().required(helper_plugin_1.translatedErrors.required),
71
+ otherwise: yup.mixed().notRequired(),
72
+ }),
73
+ related: yup.mixed()
74
+ .when('type', {
75
+ is: (val) => val === utils_1.navigationItemType.INTERNAL || (0, lodash_1.isNil)(val),
76
+ then: isSingleSelected ? yup.mixed().notRequired() : yup.mixed().required(helper_plugin_1.translatedErrors.required),
77
+ otherwise: yup.mixed().notRequired(),
78
+ }),
79
+ additionalFields: yup.object({
80
+ ...additionalFields.reduce((acc, current) => {
81
+ var value;
82
+ if (typeof current === 'string')
83
+ return acc;
84
+ if (current.type === 'boolean')
85
+ value = yup.bool();
86
+ else if (current.type === 'string')
87
+ value = yup.string();
88
+ else if (current.type === 'select' && current.multi)
89
+ value = yup.array().of(yup.string());
90
+ else if (current.type === 'select' && !current.multi)
91
+ value = yup.string();
92
+ else
93
+ throw new Error(`Type "${current.type}" is unsupported by custom fields`);
94
+ if (current.required)
95
+ value = value.required(helper_plugin_1.translatedErrors.required);
96
+ else
97
+ value = value.notRequired();
98
+ return { ...acc, [current.name]: value };
99
+ }, {})
100
+ })
101
+ });
102
+ };
103
+ exports.schemaFactory = schemaFactory;
104
+ exports.defaultValues = {
105
+ type: "INTERNAL",
106
+ related: "",
107
+ relatedType: "",
108
+ audience: [],
109
+ menuAttached: false,
110
+ title: "",
111
+ externalPath: "",
112
+ path: "",
113
+ additionalFields: {
114
+ boolean: false,
115
+ string: "",
83
116
  },
84
- inputsPrefix: '',
117
+ updated: false,
85
118
  };
86
119
  //# sourceMappingURL=form.js.map
@@ -32,7 +32,6 @@ const lodash_1 = require("lodash");
32
32
  const ModalLayout_1 = require("@strapi/design-system/ModalLayout");
33
33
  const NavigationItemForm_1 = __importDefault(require("../NavigationItemForm"));
34
34
  const parsers_1 = require("../../utils/parsers");
35
- const enums_1 = require("../../utils/enums");
36
35
  const NavigationItemPopupHeader_1 = require("./NavigationItemPopupHeader");
37
36
  const utils_1 = require("../../../../utils");
38
37
  const NavigationItemPopUp = ({ availableLocale, isOpen, isLoading, data, config = {}, onSubmit, onClose, usedContentTypeItems, getContentTypeItems, usedContentTypesData, locale, readNavigationItemFromLocale, }) => {
@@ -44,7 +43,7 @@ const NavigationItemPopUp = ({ availableLocale, isOpen, isLoading, data, config
44
43
  const appendLabelPublicationStatus = (label = '', item = {}, isCollection = false) => {
45
44
  const appendix = (0, parsers_1.isRelationPublished)({
46
45
  relatedRef: item,
47
- type: item.isSingle ? enums_1.navigationItemType.INTERNAL : item.type,
46
+ type: item.isSingle ? utils_1.navigationItemType.INTERNAL : item.type,
48
47
  isCollection,
49
48
  }) ? '' : `[${(0, utils_1.getMessage)('notification.navigation.item.relation.status.draft')}] `.toUpperCase();
50
49
  return `${appendix}${label}`;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const edit: JSX.Element;
3
+ export declare const deleteIcon: JSX.Element;
4
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deleteIcon = exports.edit = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const icons_1 = require("@strapi/icons");
9
+ exports.edit = react_1.default.createElement(icons_1.Pencil, null);
10
+ exports.deleteIcon = react_1.default.createElement(icons_1.Trash, null);
11
+ //# sourceMappingURL=icons.js.map
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Footer } from "../Footer";
3
+ import { CommonProps, ListState } from "../types";
4
+ interface Props extends ListState, CommonProps {
5
+ }
6
+ export declare const AllNavigations: ({ navigations, selected, setState }: Props) => JSX.Element;
7
+ export declare const AllNavigationsFooter: Footer;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -26,21 +26,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.listFooterActions = exports.List = void 0;
29
+ exports.AllNavigationsFooter = exports.AllNavigations = void 0;
30
30
  const BaseCheckbox_1 = require("@strapi/design-system/BaseCheckbox");
31
- const Typography_1 = require("@strapi/design-system/Typography");
32
31
  const Box_1 = require("@strapi/design-system/Box");
33
32
  const Button_1 = require("@strapi/design-system/Button");
34
33
  const Flex_1 = require("@strapi/design-system/Flex");
35
34
  const Grid_1 = require("@strapi/design-system/Grid");
36
35
  const IconButton_1 = require("@strapi/design-system/IconButton");
37
36
  const Table_1 = require("@strapi/design-system/Table");
38
- const icons_1 = require("@strapi/icons");
37
+ const Typography_1 = require("@strapi/design-system/Typography");
38
+ const fp_1 = require("lodash/fp");
39
39
  const react_1 = __importStar(require("react"));
40
40
  const useDataManager_1 = __importDefault(require("../../../../../hooks/useDataManager"));
41
41
  const utils_1 = require("../../../../../utils");
42
- const Create_1 = require("../Create");
43
- const List = ({ navigations, selected, setState }) => {
42
+ const Footer_1 = require("../Footer");
43
+ const NewNavigation_1 = require("../NewNavigation");
44
+ const icons = __importStar(require("./icons"));
45
+ const AllNavigations = ({ navigations, selected, setState }) => {
44
46
  const { config: { i18nEnabled }, } = (0, useDataManager_1.default)();
45
47
  const hasAnySelected = !!selected.length;
46
48
  const toggleSelected = (0, react_1.useCallback)(() => setState({
@@ -48,7 +50,7 @@ const List = ({ navigations, selected, setState }) => {
48
50
  selected: hasAnySelected ? [] : navigations.map((n) => n),
49
51
  view: "LIST",
50
52
  }), [setState, navigations, hasAnySelected]);
51
- const currentlySelectedSet = (0, react_1.useMemo)(() => new Set(selected.map(({ id }) => id)), [selected]);
53
+ const currentlySelectedSet = (0, react_1.useMemo)(() => new Set(selected.map((0, fp_1.prop)("id"))), [selected]);
52
54
  const handleSelect = (navigation, isSelected) => () => {
53
55
  setState({
54
56
  navigations,
@@ -62,9 +64,7 @@ const List = ({ navigations, selected, setState }) => {
62
64
  setState({
63
65
  view: "EDIT",
64
66
  navigation,
65
- alreadyUsedNames: navigations
66
- .map(({ name }) => name)
67
- .filter((name) => name !== navigation.name),
67
+ alreadyUsedNames: navigations.reduce((acc, { name }) => name !== navigation.name ? acc.concat([name]) : acc, []),
68
68
  });
69
69
  };
70
70
  const _delete = (navigations) => () => {
@@ -84,7 +84,7 @@ const List = ({ navigations, selected, setState }) => {
84
84
  },
85
85
  })),
86
86
  react_1.default.createElement(Button_1.Button, { onClick: deleteSelected, variant: "tertiary" }, (0, utils_1.getMessage)("popup.navigation.manage.button.delete")))) : null)),
87
- react_1.default.createElement(Table_1.Table, { rowCount: navigations.length + 1, colCount: i18nEnabled ? 6 : 5 },
87
+ react_1.default.createElement(Table_1.Table, { rowCount: navigations.length, colCount: i18nEnabled ? 6 : 5 },
88
88
  react_1.default.createElement(Table_1.Thead, null,
89
89
  react_1.default.createElement(Table_1.Tr, null,
90
90
  react_1.default.createElement(Table_1.Th, null,
@@ -107,32 +107,33 @@ const List = ({ navigations, selected, setState }) => {
107
107
  react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800" }, navigation.name)),
108
108
  i18nEnabled ? (react_1.default.createElement(Table_1.Td, null,
109
109
  react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800" }, [navigation.localeCode]
110
- .concat(navigation.localizations?.map(({ localeCode }) => localeCode) || [])
110
+ .concat(navigation.localizations?.map((0, fp_1.prop)("localeCode")) || [])
111
111
  .join(", ")))) : null,
112
- react_1.default.createElement(Table_1.Td, null, navigation.visible ? icons.visible : icons.notVisible),
112
+ react_1.default.createElement(Table_1.Td, null, navigation.visible
113
+ ? (0, utils_1.getMessage)("popup.navigation.manage.navigation.visible")
114
+ : (0, utils_1.getMessage)("popup.navigation.manage.navigation.hidden")),
113
115
  react_1.default.createElement(Table_1.Td, null,
114
116
  react_1.default.createElement(Flex_1.Flex, { direction: "row" },
115
117
  react_1.default.createElement(Box_1.Box, { paddingLeft: 1 },
116
118
  react_1.default.createElement(IconButton_1.IconButton, { onClick: edit(navigation), label: (0, utils_1.getMessage)("popup.navigation.manage.button.edit"), noBorder: true, icon: icons.edit })),
117
119
  react_1.default.createElement(Box_1.Box, { paddingLeft: 1 },
118
- react_1.default.createElement(IconButton_1.IconButton, { onClick: _delete([navigation]), label: (0, utils_1.getMessage)("popup.navigation.manage.button.delete"), noBorder: true, icon: icons.delete })))))))))));
119
- };
120
- exports.List = List;
121
- const listFooterActions = ({ onClose, state, setState, navigations, }) => {
122
- return {
123
- startActions: (react_1.default.createElement(Button_1.Button, { onClick: onClose, variant: "tertiary", disabled: state.isLoading }, (0, utils_1.getMessage)("popup.item.form.button.cancel"))),
124
- endActions: (react_1.default.createElement(Button_1.Button, { disabled: state.isLoading, onClick: () => setState({
125
- view: "CREATE",
126
- alreadyUsedNames: navigations.map(({ name }) => name),
127
- current: Create_1.INITIAL_NAVIGATION,
128
- }), variant: "default" }, (0, utils_1.getMessage)("popup.navigation.manage.button.create"))),
129
- };
130
- };
131
- exports.listFooterActions = listFooterActions;
132
- const icons = {
133
- edit: react_1.default.createElement(icons_1.Pencil, null),
134
- delete: react_1.default.createElement(icons_1.Trash, null),
135
- visible: react_1.default.createElement(icons_1.Eye, null),
136
- notVisible: react_1.default.createElement(icons_1.EyeStriked, null),
120
+ react_1.default.createElement(IconButton_1.IconButton, { onClick: _delete([navigation]), label: (0, utils_1.getMessage)("popup.navigation.manage.button.delete"), noBorder: true, icon: icons.deleteIcon })))))))))));
137
121
  };
122
+ exports.AllNavigations = AllNavigations;
123
+ const AllNavigationsFooter = ({ onClose, state, setState, navigations, }) => (react_1.default.createElement(Footer_1.FooterBase, { start: {
124
+ onClick: onClose,
125
+ variant: "tertiary",
126
+ disabled: state.isLoading,
127
+ children: (0, utils_1.getMessage)("popup.item.form.button.cancel"),
128
+ }, end: {
129
+ onClick: () => setState({
130
+ view: "CREATE",
131
+ alreadyUsedNames: navigations.map(({ name }) => name),
132
+ current: NewNavigation_1.INITIAL_NAVIGATION,
133
+ }),
134
+ variant: "default",
135
+ disabled: state.isLoading,
136
+ children: (0, utils_1.getMessage)("popup.navigation.manage.button.create"),
137
+ } }));
138
+ exports.AllNavigationsFooter = AllNavigationsFooter;
138
139
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Footer } from "../Footer";
3
+ import { CommonProps, DeleteState } from "../types";
4
+ interface Props extends DeleteState, CommonProps {
5
+ }
6
+ export declare const DeletionConfirm: ({ navigations }: Props) => JSX.Element;
7
+ export declare const DeleteConfirmFooter: Footer;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -3,26 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deleteFooterActions = exports.Delete = void 0;
7
- const Button_1 = require("@strapi/design-system/Button");
6
+ exports.DeleteConfirmFooter = exports.DeletionConfirm = void 0;
8
7
  const Flex_1 = require("@strapi/design-system/Flex");
9
8
  const Grid_1 = require("@strapi/design-system/Grid");
10
9
  const Typography_1 = require("@strapi/design-system/Typography");
10
+ const fp_1 = require("lodash/fp");
11
11
  const react_1 = __importDefault(require("react"));
12
12
  const utils_1 = require("../../../../../utils");
13
- const Delete = ({ navigations }) => (react_1.default.createElement(Grid_1.Grid, null,
13
+ const Footer_1 = require("../Footer");
14
+ const DeletionConfirm = ({ navigations }) => (react_1.default.createElement(Grid_1.Grid, null,
14
15
  react_1.default.createElement(Grid_1.GridItem, { col: 12, paddingBottom: 1 },
15
16
  react_1.default.createElement(Flex_1.Flex, null,
16
17
  react_1.default.createElement(Typography_1.Typography, { variant: "beta" }, (0, utils_1.getMessage)("popup.navigation.manage.delete.header")))),
17
18
  react_1.default.createElement(Grid_1.GridItem, { col: 12, paddingBottom: 1 },
18
19
  react_1.default.createElement(Typography_1.Typography, { variant: "omega", fontWeight: "semiBold" }, renderItems(navigations)))));
19
- exports.Delete = Delete;
20
- const deleteFooterActions = ({ state, onSubmit, onReset, }) => {
21
- return {
22
- startActions: (react_1.default.createElement(Button_1.Button, { disabled: state.isLoading, onClick: onReset, variant: "tertiary" }, (0, utils_1.getMessage)("popup.item.form.button.cancel"))),
23
- endActions: (react_1.default.createElement(Button_1.Button, { disabled: state.isLoading, onClick: onSubmit, variant: "danger" }, (0, utils_1.getMessage)("popup.navigation.manage.button.delete"))),
24
- };
25
- };
26
- exports.deleteFooterActions = deleteFooterActions;
27
- const renderItems = (navigations) => navigations.map(({ name }) => `"${name}"`).join(", ");
20
+ exports.DeletionConfirm = DeletionConfirm;
21
+ const DeleteConfirmFooter = ({ state, onSubmit, onReset }) => (react_1.default.createElement(Footer_1.FooterBase, { start: {
22
+ children: (0, utils_1.getMessage)("popup.item.form.button.cancel"),
23
+ disabled: state.isLoading,
24
+ onClick: onReset,
25
+ variant: "tertiary",
26
+ }, end: {
27
+ children: (0, utils_1.getMessage)("popup.navigation.manage.button.delete"),
28
+ disabled: state.isLoading,
29
+ onClick: onSubmit,
30
+ variant: "danger",
31
+ } }));
32
+ exports.DeleteConfirmFooter = DeleteConfirmFooter;
33
+ const renderItems = (navigations) => navigations.map((0, fp_1.prop)("name")).join(", ");
28
34
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Footer } from "../Footer";
3
+ import { CommonProps, ErrorState } from "../types";
4
+ interface Props extends ErrorState, CommonProps {
5
+ }
6
+ export declare const ErrorDetails: ({ errors }: Props) => JSX.Element;
7
+ export declare const ErrorDetailsFooter: Footer;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -23,13 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.errorFooterActions = exports.ErrorView = void 0;
27
- const Button_1 = require("@strapi/design-system/Button");
26
+ exports.ErrorDetailsFooter = exports.ErrorDetails = void 0;
28
27
  const Grid_1 = require("@strapi/design-system/Grid");
29
28
  const helper_plugin_1 = require("@strapi/helper-plugin");
30
29
  const react_1 = __importStar(require("react"));
31
30
  const utils_1 = require("../../../../../utils");
32
- const ErrorView = ({ errors }) => {
31
+ const Footer_1 = require("../Footer");
32
+ const ErrorDetails = ({ errors }) => {
33
33
  const toggleNotification = (0, helper_plugin_1.useNotification)();
34
34
  (0, react_1.useEffect)(() => {
35
35
  errors.map((error) => {
@@ -43,11 +43,11 @@ const ErrorView = ({ errors }) => {
43
43
  return (react_1.default.createElement(Grid_1.Grid, null,
44
44
  react_1.default.createElement(Grid_1.GridItem, { col: 12 }, (0, utils_1.getMessage)("popup.navigation.manage.error.message"))));
45
45
  };
46
- exports.ErrorView = ErrorView;
47
- const errorFooterActions = ({ onReset }) => {
48
- return {
49
- endActions: (react_1.default.createElement(Button_1.Button, { onClick: onReset, variant: "secondary" }, (0, utils_1.getMessage)("popup.navigation.manage.button.goBack"))),
50
- };
51
- };
52
- exports.errorFooterActions = errorFooterActions;
46
+ exports.ErrorDetails = ErrorDetails;
47
+ const ErrorDetailsFooter = ({ onReset }) => (react_1.default.createElement(Footer_1.FooterBase, { end: {
48
+ children: (0, utils_1.getMessage)("popup.navigation.manage.button.goBack"),
49
+ onClick: onReset,
50
+ variant: "secondary",
51
+ } }));
52
+ exports.ErrorDetailsFooter = ErrorDetailsFooter;
53
53
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { VoidEffect } from "../../../../../../../types";
3
+ import { Navigation, SetState, State } from "../types";
4
+ interface FooterBaseProps {
5
+ end?: ActionProps;
6
+ start?: ActionProps;
7
+ }
8
+ export declare type Footer = React.FC<{
9
+ navigations: Array<Navigation>;
10
+ onClose?: VoidEffect;
11
+ onReset: VoidEffect;
12
+ onSubmit: VoidEffect;
13
+ setState: SetState;
14
+ state: State;
15
+ }>;
16
+ interface ActionProps {
17
+ children: React.ReactNode;
18
+ disabled?: boolean;
19
+ onClick?: VoidEffect;
20
+ variant: "danger" | "secondary" | "tertiary" | "default";
21
+ }
22
+ export declare const FooterBase: React.FC<FooterBaseProps>;
23
+ export {};
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FooterBase = void 0;
7
+ const Button_1 = require("@strapi/design-system/Button");
8
+ const ModalLayout_1 = require("@strapi/design-system/ModalLayout");
9
+ const react_1 = __importDefault(require("react"));
10
+ const FooterBase = ({ start, end }) => (react_1.default.createElement(ModalLayout_1.ModalFooter, { endActions: renderActions(end), startActions: renderActions(start) }));
11
+ exports.FooterBase = FooterBase;
12
+ const renderActions = (actions) => actions ? (react_1.default.createElement(Button_1.Button, { onClick: actions.onClick, variant: actions.variant, disabled: actions.disabled }, actions.children)) : null;
13
+ //# sourceMappingURL=index.js.map
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { Navigation } from "../types";
3
2
  import { useIntl } from "react-intl";
3
+ import { Effect } from "../../../../../../../types";
4
+ import { Navigation } from "../types";
4
5
  interface Props {
5
6
  navigation: Partial<Navigation>;
6
- onChange: (n: Navigation) => void;
7
+ onChange: Effect<Navigation>;
7
8
  isLoading?: boolean;
8
9
  validationSchema: ReturnType<typeof validationSchemaFactory>;
9
10
  }
@@ -24,13 +24,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.validationSchemaFactory = exports.Form = void 0;
27
- const yup = __importStar(require("yup"));
28
27
  const Grid_1 = require("@strapi/design-system/Grid");
29
28
  const helper_plugin_1 = require("@strapi/helper-plugin");
30
29
  const formik_1 = require("formik");
31
30
  const react_1 = __importStar(require("react"));
31
+ const yup = __importStar(require("yup"));
32
32
  const translations_1 = require("../../../../../translations");
33
+ const lodash_1 = require("lodash");
33
34
  const Form = ({ navigation, onChange: onChangeBase, isLoading, validationSchema, }) => {
35
+ const initialValues = {
36
+ id: (0, lodash_1.get)(navigation, "id", ""),
37
+ name: (0, lodash_1.get)(navigation, "name", ""),
38
+ };
34
39
  const onChange = (0, react_1.useCallback)(({ target: { name, value } }) => {
35
40
  onChangeBase({
36
41
  ...navigation,
@@ -48,7 +53,7 @@ const Form = ({ navigation, onChange: onChangeBase, isLoading, validationSchema,
48
53
  .then(() => setError(null))
49
54
  .catch(setError);
50
55
  }, [navigation, validationSchema, setError]);
51
- return (react_1.default.createElement(formik_1.Formik, { initialValues: navigation, onSubmit: onChangeBase },
56
+ return (react_1.default.createElement(formik_1.Formik, { initialValues: initialValues, onSubmit: onChangeBase },
52
57
  react_1.default.createElement(helper_plugin_1.Form, null,
53
58
  react_1.default.createElement(Grid_1.Grid, { gap: 5 },
54
59
  react_1.default.createElement(Grid_1.GridItem, { col: 6 },
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Footer } from "../Footer";
3
+ import { CommonProps, EditState } from "../types";
4
+ interface Props extends EditState, CommonProps {
5
+ }
6
+ export declare const NavigationUpdate: ({ alreadyUsedNames, current, isLoading, navigation: initialValue, setState, }: Props) => JSX.Element;
7
+ export declare const NavigationUpdateFooter: Footer;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -23,13 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.editFooterActions = exports.Edit = void 0;
27
- const Button_1 = require("@strapi/design-system/Button");
26
+ exports.NavigationUpdateFooter = exports.NavigationUpdate = void 0;
28
27
  const react_1 = __importStar(require("react"));
29
28
  const react_intl_1 = require("react-intl");
30
29
  const utils_1 = require("../../../../../utils");
30
+ const Footer_1 = require("../Footer");
31
31
  const Form_1 = require("../Form");
32
- const Edit = ({ alreadyUsedNames, current, isLoading, navigation: initialValue, setState, }) => {
32
+ const NavigationUpdate = ({ alreadyUsedNames, current, isLoading, navigation: initialValue, setState, }) => {
33
33
  const { formatMessage } = (0, react_intl_1.useIntl)();
34
34
  const onChange = (0, react_1.useCallback)((updated) => {
35
35
  setState({
@@ -43,12 +43,17 @@ const Edit = ({ alreadyUsedNames, current, isLoading, navigation: initialValue,
43
43
  const validationSchema = (0, react_1.useMemo)(() => (0, Form_1.validationSchemaFactory)(alreadyUsedNames, formatMessage), [alreadyUsedNames]);
44
44
  return (react_1.default.createElement(Form_1.Form, { navigation: navigation, onChange: onChange, isLoading: isLoading, validationSchema: validationSchema }));
45
45
  };
46
- exports.Edit = Edit;
47
- const editFooterActions = ({ state, onSubmit, onReset, }) => {
48
- return {
49
- startActions: (react_1.default.createElement(Button_1.Button, { disabled: state.isLoading, onClick: onReset, variant: "tertiary" }, (0, utils_1.getMessage)("popup.item.form.button.cancel"))),
50
- endActions: (react_1.default.createElement(Button_1.Button, { disabled: state.isLoading, onClick: onSubmit, variant: "secondary" }, (0, utils_1.getMessage)("popup.navigation.manage.button.save"))),
51
- };
52
- };
53
- exports.editFooterActions = editFooterActions;
46
+ exports.NavigationUpdate = NavigationUpdate;
47
+ const NavigationUpdateFooter = ({ state, onSubmit, onReset, }) => (react_1.default.createElement(Footer_1.FooterBase, { start: {
48
+ children: (0, utils_1.getMessage)("popup.item.form.button.cancel"),
49
+ disabled: state.isLoading,
50
+ onClick: onReset,
51
+ variant: "tertiary",
52
+ }, end: {
53
+ children: (0, utils_1.getMessage)("popup.navigation.manage.button.save"),
54
+ disabled: state.isLoading,
55
+ onClick: onSubmit,
56
+ variant: "secondary",
57
+ } }));
58
+ exports.NavigationUpdateFooter = NavigationUpdateFooter;
54
59
  //# sourceMappingURL=index.js.map