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.
- package/README.md +17 -7
- package/admin/src/components/AdditionalFieldInput/index.d.ts +5 -0
- package/admin/src/components/AdditionalFieldInput/index.js +71 -0
- package/admin/src/components/AdditionalFieldInput/types.d.ts +14 -0
- package/admin/src/components/AdditionalFieldInput/types.js +3 -0
- package/admin/src/components/Item/index.js +2 -3
- package/admin/src/components/RestartAlert/index.d.ts +1 -1
- package/admin/src/components/TextArrayInput/index.d.ts +14 -0
- package/admin/src/components/TextArrayInput/index.js +45 -0
- package/admin/src/hooks/useAllContentTypes.d.ts +1 -4
- package/admin/src/hooks/useAllContentTypes.js +3 -7
- package/admin/src/hooks/useNavigationConfig.d.ts +1 -1
- package/admin/src/hooks/useNavigationConfig.js +6 -6
- package/admin/src/pages/DataManagerProvider/index.d.ts +1 -1
- package/admin/src/pages/DataManagerProvider/index.js +9 -11
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +12 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +112 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +12 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +20 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +11 -0
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +105 -0
- package/admin/src/pages/SettingsPage/index.d.ts +2 -1
- package/admin/src/pages/SettingsPage/index.js +109 -74
- package/admin/src/pages/SettingsPage/types.d.ts +32 -0
- package/admin/src/pages/SettingsPage/types.js +3 -0
- package/admin/src/pages/SettingsPage/utils/form.d.ts +18 -0
- package/admin/src/pages/SettingsPage/utils/form.js +34 -0
- package/admin/src/pages/SettingsPage/utils/functions.d.ts +2 -2
- package/admin/src/pages/SettingsPage/utils/functions.js +1 -1
- package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +3 -55
- package/admin/src/pages/View/components/NavigationItemForm/index.js +162 -177
- package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +90 -0
- package/admin/src/pages/View/components/NavigationItemForm/types.js +3 -0
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +24 -43
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +78 -45
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +1 -2
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +4 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +11 -0
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{List → AllNavigations}/index.js +32 -31
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{Delete → DeletionConfirm}/index.js +18 -12
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{Error → ErrorDetails}/index.js +10 -10
- package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +24 -0
- package/admin/src/pages/View/components/NavigationManager/Footer/index.js +13 -0
- package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +3 -2
- package/admin/src/pages/View/components/NavigationManager/Form/index.js +7 -2
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +9 -0
- package/admin/src/pages/View/components/NavigationManager/{Edit → NavigationUpdate}/index.js +16 -11
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +10 -0
- package/admin/src/pages/View/components/NavigationManager/{Create → NewNavigation}/index.js +16 -11
- package/admin/src/pages/View/components/NavigationManager/index.d.ts +3 -2
- package/admin/src/pages/View/components/NavigationManager/index.js +22 -21
- package/admin/src/pages/View/components/NavigationManager/types.d.ts +2 -15
- package/admin/src/pages/View/index.d.ts +1 -1
- package/admin/src/pages/View/index.js +1 -1
- package/admin/src/pages/View/utils/parsers.d.ts +1 -0
- package/admin/src/pages/View/utils/parsers.js +8 -7
- package/admin/src/translations/en.json +37 -0
- package/admin/src/translations/index.d.ts +2 -1
- package/admin/src/translations/index.js +1 -1
- package/admin/src/utils/api.d.ts +8 -7
- package/admin/src/utils/api.js +6 -41
- package/admin/src/utils/enums.d.ts +25 -0
- package/admin/src/utils/enums.js +30 -0
- package/admin/src/utils/functions.d.ts +16 -0
- package/admin/src/utils/functions.js +46 -0
- package/admin/src/utils/index.d.ts +3 -17
- package/admin/src/utils/index.js +16 -39
- package/package.json +5 -5
- package/server/config/index.js +6 -4
- package/server/config/setupStrategy.js +13 -1
- package/server/content-types/index.d.ts +5 -25
- package/server/content-types/navigation/index.d.ts +0 -7
- package/server/content-types/navigation/index.js +0 -2
- package/server/content-types/navigation-item/index.d.ts +5 -13
- package/server/content-types/navigation-item/index.js +0 -2
- package/server/content-types/navigation-item/schema.d.ts +5 -0
- package/server/content-types/navigation-item/schema.js +5 -0
- package/server/content-types/navigations-items-related/index.d.ts +0 -5
- package/server/content-types/navigations-items-related/index.js +0 -2
- package/server/controllers/admin.js +1 -1
- package/server/controllers/client.js +2 -1
- package/server/graphql/types/navigation-item.d.ts +2 -1
- package/server/graphql/types/navigation-item.js +26 -2
- package/server/index.d.ts +5 -25
- package/server/services/admin.js +26 -14
- package/server/services/client.js +64 -21
- package/server/services/common.js +25 -6
- package/server/utils/constant.d.ts +0 -3
- package/server/utils/constant.js +1 -2
- package/server/utils/functions.d.ts +12 -12
- package/server/utils/functions.js +60 -22
- package/strapi-server.d.ts +5 -25
- package/tsconfig.tsbuildinfo +1 -1
- package/types/config.d.ts +6 -2
- package/types/contentTypes.d.ts +22 -1
- package/types/services.d.ts +14 -5
- package/types/utils.d.ts +6 -1
- package/types/utils.js +15 -1
- package/admin/src/pages/View/components/NavigationManager/Create/index.d.ts +0 -9
- package/admin/src/pages/View/components/NavigationManager/Delete/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/Edit/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/Error/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/List/index.d.ts +0 -8
- package/admin/src/pages/View/utils/enums.d.ts +0 -9
- package/admin/src/pages/View/utils/enums.js +0 -12
- package/admin/src/utils/getTrad.d.ts +0 -3
- package/admin/src/utils/getTrad.js +0 -9
- package/server/content-types/navigation/lifecycle.d.ts +0 -9
- package/server/content-types/navigation/lifecycle.js +0 -10
- package/server/content-types/navigation-item/lifecycle.d.ts +0 -16
- package/server/content-types/navigation-item/lifecycle.js +0 -31
- package/server/content-types/navigations-items-related/lifecycle.d.ts +0 -8
- package/server/content-types/navigations-items-related/lifecycle.js +0 -22
package/admin/src/utils/index.js
CHANGED
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const react_intl_1 = require("react-intl");
|
|
8
|
-
const lodash_1 = require("lodash");
|
|
9
|
-
const pluginId_1 = __importDefault(require("../pluginId"));
|
|
10
|
-
const getMessage = (input, defaultMessage = '', inPluginScope = true) => {
|
|
11
|
-
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
12
|
-
let formattedId = '';
|
|
13
|
-
if ((0, lodash_1.isString)(input)) {
|
|
14
|
-
formattedId = input;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
formattedId = input?.id;
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
7
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
15
|
};
|
|
24
|
-
exports
|
|
25
|
-
exports
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.ResourceState = {
|
|
29
|
-
RESOLVED: 'RESOLVED',
|
|
30
|
-
LOADING: 'LOADING',
|
|
31
|
-
ERROR: 'ERROR',
|
|
32
|
-
};
|
|
33
|
-
const resolvedResourceFor = (value) => ({
|
|
34
|
-
type: exports.ResourceState.RESOLVED,
|
|
35
|
-
value,
|
|
36
|
-
});
|
|
37
|
-
exports.resolvedResourceFor = resolvedResourceFor;
|
|
38
|
-
const errorStatusResourceFor = (errors) => ({
|
|
39
|
-
type: exports.ResourceState.ERROR,
|
|
40
|
-
errors,
|
|
41
|
-
});
|
|
42
|
-
exports.errorStatusResourceFor = errorStatusResourceFor;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./functions"), exports);
|
|
18
|
+
__exportStar(require("./api"), exports);
|
|
19
|
+
__exportStar(require("./enums"), exports);
|
|
43
20
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-navigation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Strapi - Navigation plugin",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"name": "navigation",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"
|
|
17
|
+
"@sindresorhus/slugify": "1.1.0",
|
|
18
|
+
"@strapi/utils": "^4.3.0",
|
|
19
19
|
"lodash": "^4.17.11",
|
|
20
20
|
"pluralize": "^8.0.0",
|
|
21
21
|
"react": "^16.9.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"reactstrap": "8.4.1",
|
|
28
28
|
"redux-saga": "^0.16.0",
|
|
29
29
|
"request": "^2.83.0",
|
|
30
|
-
"
|
|
30
|
+
"uuid": "^8.3.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
],
|
|
58
58
|
"engines": {
|
|
59
|
-
"node": ">=14.19.
|
|
59
|
+
"node": ">=14.19.3 <=17.x.x",
|
|
60
60
|
"npm": ">=7.x.x"
|
|
61
61
|
},
|
|
62
62
|
"nodemonConfig": {
|
package/server/config/index.js
CHANGED
|
@@ -18,15 +18,17 @@ __exportStar(require("./setupStrategy"), exports);
|
|
|
18
18
|
const config = {
|
|
19
19
|
default: {
|
|
20
20
|
additionalFields: [],
|
|
21
|
+
allowedLevels: 2,
|
|
21
22
|
contentTypes: [],
|
|
22
23
|
contentTypesNameFields: {},
|
|
23
24
|
contentTypesPopulate: {},
|
|
24
|
-
allowedLevels: 2,
|
|
25
|
-
i18nEnabled: false,
|
|
26
|
-
pruneObsoleteI18nNavigations: false,
|
|
27
25
|
gql: {
|
|
28
|
-
navigationItemRelated: []
|
|
26
|
+
navigationItemRelated: [],
|
|
29
27
|
},
|
|
28
|
+
i18nEnabled: false,
|
|
29
|
+
pathDefaultFields: {},
|
|
30
|
+
pruneObsoleteI18nNavigations: false,
|
|
31
|
+
slugify: {},
|
|
30
32
|
},
|
|
31
33
|
};
|
|
32
34
|
exports.default = config;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configSetupStrategy = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
4
5
|
const types_1 = require("../../types");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
5
7
|
const configSetupStrategy = async ({ strapi }) => {
|
|
6
8
|
const pluginStore = strapi.store({
|
|
7
9
|
type: "plugin",
|
|
@@ -21,9 +23,12 @@ const configSetupStrategy = async ({ strapi }) => {
|
|
|
21
23
|
allowedLevels: getWithFallback("allowedLevels"),
|
|
22
24
|
gql: getWithFallback("gql"),
|
|
23
25
|
i18nEnabled: hasI18nPlugin && getWithFallback("i18nEnabled"),
|
|
26
|
+
slugify: (0, lodash_1.pick)(getWithFallback("slugify"), validSlugifyFields),
|
|
24
27
|
pruneObsoleteI18nNavigations: false,
|
|
28
|
+
pathDefaultFields: getWithFallback("pathDefaultFields"),
|
|
25
29
|
};
|
|
26
|
-
|
|
30
|
+
(0, utils_1.validateAdditionalFields)(config.additionalFields);
|
|
31
|
+
await pluginStore.set({
|
|
27
32
|
key: "config",
|
|
28
33
|
value: config,
|
|
29
34
|
});
|
|
@@ -35,4 +40,11 @@ const getWithFallbackFactory = (config, fallback) => (key) => {
|
|
|
35
40
|
(0, types_1.assertNotEmpty)(value, new Error(`[Navigation] Config "${key}" is undefined`));
|
|
36
41
|
return value;
|
|
37
42
|
};
|
|
43
|
+
const validSlugifyFields = [
|
|
44
|
+
"separator",
|
|
45
|
+
"lowercase",
|
|
46
|
+
"decamelize",
|
|
47
|
+
"customReplacements",
|
|
48
|
+
"preserveLeadingUnderscore",
|
|
49
|
+
];
|
|
38
50
|
//# sourceMappingURL=setupStrategy.js.map
|
|
@@ -25,13 +25,6 @@ declare const _default: {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
navigation: {
|
|
28
|
-
lifecycle: {
|
|
29
|
-
renderType: {
|
|
30
|
-
FLAT: string;
|
|
31
|
-
TREE: string;
|
|
32
|
-
RFR: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
28
|
schema: {
|
|
36
29
|
collectionName: string;
|
|
37
30
|
info: {
|
|
@@ -87,19 +80,6 @@ declare const _default: {
|
|
|
87
80
|
};
|
|
88
81
|
};
|
|
89
82
|
"navigation-item": {
|
|
90
|
-
lifecycle: {
|
|
91
|
-
type: {
|
|
92
|
-
INTERNAL: string;
|
|
93
|
-
EXTERNAL: string;
|
|
94
|
-
WRAPPER: string;
|
|
95
|
-
};
|
|
96
|
-
additionalFields: {
|
|
97
|
-
AUDIENCE: string;
|
|
98
|
-
};
|
|
99
|
-
lifecycles: {
|
|
100
|
-
afterFind(results: any): void;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
83
|
schema: {
|
|
104
84
|
collectionName: string;
|
|
105
85
|
info: {
|
|
@@ -193,15 +173,15 @@ declare const _default: {
|
|
|
193
173
|
relation: string;
|
|
194
174
|
target: string;
|
|
195
175
|
};
|
|
176
|
+
additionalFields: {
|
|
177
|
+
type: string;
|
|
178
|
+
require: boolean;
|
|
179
|
+
default: {};
|
|
180
|
+
};
|
|
196
181
|
};
|
|
197
182
|
};
|
|
198
183
|
};
|
|
199
184
|
"navigations-items-related": {
|
|
200
|
-
lifecycle: {
|
|
201
|
-
lifecycles: {
|
|
202
|
-
afterFind(results: any): void;
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
185
|
schema: {
|
|
206
186
|
collectionName: string;
|
|
207
187
|
info: {
|
|
@@ -4,9 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = __importDefault(require("./schema"));
|
|
7
|
-
const lifecycle_1 = __importDefault(require("./lifecycle"));
|
|
8
7
|
exports.default = {
|
|
9
|
-
lifecycle: lifecycle_1.default,
|
|
10
8
|
schema: schema_1.default
|
|
11
9
|
};
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
lifecycle: {
|
|
3
|
-
type: {
|
|
4
|
-
INTERNAL: string;
|
|
5
|
-
EXTERNAL: string;
|
|
6
|
-
WRAPPER: string;
|
|
7
|
-
};
|
|
8
|
-
additionalFields: {
|
|
9
|
-
AUDIENCE: string;
|
|
10
|
-
};
|
|
11
|
-
lifecycles: {
|
|
12
|
-
afterFind(results: any): void;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
2
|
schema: {
|
|
16
3
|
collectionName: string;
|
|
17
4
|
info: {
|
|
@@ -105,6 +92,11 @@ declare const _default: {
|
|
|
105
92
|
relation: string;
|
|
106
93
|
target: string;
|
|
107
94
|
};
|
|
95
|
+
additionalFields: {
|
|
96
|
+
type: string;
|
|
97
|
+
require: boolean;
|
|
98
|
+
default: {};
|
|
99
|
+
};
|
|
108
100
|
};
|
|
109
101
|
};
|
|
110
102
|
};
|
|
@@ -4,9 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = __importDefault(require("./schema"));
|
|
7
|
-
const lifecycle_1 = __importDefault(require("./lifecycle"));
|
|
8
7
|
exports.default = {
|
|
9
|
-
lifecycle: lifecycle_1.default,
|
|
10
8
|
schema: schema_1.default
|
|
11
9
|
};
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,9 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = __importDefault(require("./schema"));
|
|
7
|
-
const lifecycle_1 = __importDefault(require("./lifecycle"));
|
|
8
7
|
exports.default = {
|
|
9
|
-
lifecycle: lifecycle_1.default,
|
|
10
8
|
schema: schema_1.default
|
|
11
9
|
};
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -8,7 +8,7 @@ const clientControllers = {
|
|
|
8
8
|
},
|
|
9
9
|
async render(ctx) {
|
|
10
10
|
const { params, query = {} } = ctx;
|
|
11
|
-
const { type, menu: menuOnly, path: rootPath, locale } = query;
|
|
11
|
+
const { type, menu: menuOnly, path: rootPath, locale, populate } = query;
|
|
12
12
|
const { idOrSlug } = (0, utils_2.parseParams)(params);
|
|
13
13
|
try {
|
|
14
14
|
return await this.getService().render({
|
|
@@ -17,6 +17,7 @@ const clientControllers = {
|
|
|
17
17
|
menuOnly,
|
|
18
18
|
rootPath,
|
|
19
19
|
locale,
|
|
20
|
+
populate
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
module.exports = ({ nexus }) => nexus.objectType({
|
|
2
|
+
module.exports = ({ nexus, config }) => nexus.objectType({
|
|
3
3
|
name: "NavigationItem",
|
|
4
4
|
definition(t) {
|
|
5
5
|
t.nonNull.int("id");
|
|
@@ -14,7 +14,6 @@ module.exports = ({ nexus }) => nexus.objectType({
|
|
|
14
14
|
t.int("master");
|
|
15
15
|
t.list.field("items", { type: 'NavigationItem' });
|
|
16
16
|
t.field("related", { type: 'NavigationItemRelatedData' });
|
|
17
|
-
t.list.string("audience");
|
|
18
17
|
t.string("created_at");
|
|
19
18
|
t.string("updated_at");
|
|
20
19
|
t.string("created_by");
|
|
@@ -23,6 +22,31 @@ module.exports = ({ nexus }) => nexus.objectType({
|
|
|
23
22
|
t.string("updatedAt");
|
|
24
23
|
t.string("createdBy");
|
|
25
24
|
t.string("updatedBy");
|
|
25
|
+
config.additionalFields.forEach(field => {
|
|
26
|
+
if (field !== 'audience') {
|
|
27
|
+
if (field.enabled) {
|
|
28
|
+
switch (field.type) {
|
|
29
|
+
case 'string':
|
|
30
|
+
t.string(field.name);
|
|
31
|
+
break;
|
|
32
|
+
case 'boolean':
|
|
33
|
+
t.boolean(field.name);
|
|
34
|
+
break;
|
|
35
|
+
case 'select':
|
|
36
|
+
if (field.multi)
|
|
37
|
+
t.list.string(field.name);
|
|
38
|
+
else
|
|
39
|
+
t.string(field.name);
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`Type "${JSON.stringify(field.type)}" is unsupported by custom fields`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
t.list.string("audience");
|
|
48
|
+
}
|
|
49
|
+
});
|
|
26
50
|
}
|
|
27
51
|
});
|
|
28
52
|
//# sourceMappingURL=navigation-item.js.map
|
package/server/index.d.ts
CHANGED
|
@@ -28,13 +28,6 @@ declare const _default: {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
navigation: {
|
|
31
|
-
lifecycle: {
|
|
32
|
-
renderType: {
|
|
33
|
-
FLAT: string;
|
|
34
|
-
TREE: string;
|
|
35
|
-
RFR: string;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
31
|
schema: {
|
|
39
32
|
collectionName: string;
|
|
40
33
|
info: {
|
|
@@ -90,19 +83,6 @@ declare const _default: {
|
|
|
90
83
|
};
|
|
91
84
|
};
|
|
92
85
|
"navigation-item": {
|
|
93
|
-
lifecycle: {
|
|
94
|
-
type: {
|
|
95
|
-
INTERNAL: string;
|
|
96
|
-
EXTERNAL: string;
|
|
97
|
-
WRAPPER: string;
|
|
98
|
-
};
|
|
99
|
-
additionalFields: {
|
|
100
|
-
AUDIENCE: string;
|
|
101
|
-
};
|
|
102
|
-
lifecycles: {
|
|
103
|
-
afterFind(results: any): void;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
86
|
schema: {
|
|
107
87
|
collectionName: string;
|
|
108
88
|
info: {
|
|
@@ -196,15 +176,15 @@ declare const _default: {
|
|
|
196
176
|
relation: string;
|
|
197
177
|
target: string;
|
|
198
178
|
};
|
|
179
|
+
additionalFields: {
|
|
180
|
+
type: string;
|
|
181
|
+
require: boolean;
|
|
182
|
+
default: {};
|
|
183
|
+
};
|
|
199
184
|
};
|
|
200
185
|
};
|
|
201
186
|
};
|
|
202
187
|
"navigations-items-related": {
|
|
203
|
-
lifecycle: {
|
|
204
|
-
lifecycles: {
|
|
205
|
-
afterFind(results: any): void;
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
188
|
schema: {
|
|
209
189
|
collectionName: string;
|
|
210
190
|
info: {
|
package/server/services/admin.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("@strapi/utils");
|
|
7
|
-
const slugify_1 = __importDefault(require("slugify"));
|
|
7
|
+
const slugify_1 = __importDefault(require("@sindresorhus/slugify"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const utils_2 = require("../utils");
|
|
10
10
|
const i18n_1 = require("../i18n");
|
|
@@ -12,13 +12,15 @@ const NavigationError_1 = require("../../utils/NavigationError");
|
|
|
12
12
|
const adminService = ({ strapi }) => ({
|
|
13
13
|
async config(viaSettingsPage = false) {
|
|
14
14
|
const commonService = (0, utils_2.getPluginService)('common');
|
|
15
|
-
const { audienceModel } = (0, utils_2.
|
|
15
|
+
const { audienceModel } = (0, utils_2.getPluginModels)();
|
|
16
16
|
const pluginStore = await commonService.getPluginStore();
|
|
17
17
|
const config = await pluginStore.get({ key: 'config' });
|
|
18
18
|
const additionalFields = config.additionalFields;
|
|
19
19
|
const contentTypesNameFields = config.contentTypesNameFields;
|
|
20
20
|
const contentTypesPopulate = config.contentTypesPopulate;
|
|
21
|
+
const pathDefaultFields = config.pathDefaultFields;
|
|
21
22
|
const allowedLevels = config.allowedLevels;
|
|
23
|
+
const slugify = config.slugify;
|
|
22
24
|
const isGQLPluginEnabled = !(0, lodash_1.isNil)(strapi.plugin('graphql'));
|
|
23
25
|
let extendedResult = {
|
|
24
26
|
allowedContentTypes: utils_2.ALLOWED_CONTENT_TYPES,
|
|
@@ -31,18 +33,20 @@ const adminService = ({ strapi }) => ({
|
|
|
31
33
|
default: utils_2.CONTENT_TYPES_NAME_FIELDS_DEFAULTS,
|
|
32
34
|
...((0, lodash_1.isObject)(contentTypesNameFields) ? contentTypesNameFields : {}),
|
|
33
35
|
},
|
|
34
|
-
contentTypesPopulate: {
|
|
35
|
-
|
|
36
|
-
},
|
|
36
|
+
contentTypesPopulate: (0, lodash_1.isObject)(contentTypesPopulate) ? contentTypesPopulate : {},
|
|
37
|
+
pathDefaultFields: (0, lodash_1.isObject)(pathDefaultFields) ? pathDefaultFields : {},
|
|
37
38
|
allowedLevels,
|
|
38
|
-
additionalFields
|
|
39
|
+
additionalFields: viaSettingsPage
|
|
40
|
+
? additionalFields
|
|
41
|
+
: additionalFields.filter(field => typeof field === 'string' || (0, lodash_1.get)(field, 'enabled', false)),
|
|
39
42
|
gql: {
|
|
40
43
|
navigationItemRelated: configContentTypes.map(({ labelSingular }) => labelSingular.replace(/\s+/g, ''))
|
|
41
44
|
},
|
|
42
45
|
isGQLPluginEnabled: viaSettingsPage ? isGQLPluginEnabled : undefined,
|
|
46
|
+
slugify,
|
|
43
47
|
};
|
|
44
48
|
const i18nConfig = await (0, i18n_1.addI18NConfigFields)({ strapi, viaSettingsPage, previousConfig: {} });
|
|
45
|
-
if (additionalFields.includes(
|
|
49
|
+
if (additionalFields.includes('audience')) {
|
|
46
50
|
const audienceItems = await strapi
|
|
47
51
|
.query(audienceModel.uid)
|
|
48
52
|
.findMany({
|
|
@@ -60,7 +64,7 @@ const adminService = ({ strapi }) => ({
|
|
|
60
64
|
};
|
|
61
65
|
},
|
|
62
66
|
async get() {
|
|
63
|
-
const { masterModel } = (0, utils_2.
|
|
67
|
+
const { masterModel } = (0, utils_2.getPluginModels)();
|
|
64
68
|
const entities = await strapi
|
|
65
69
|
.query(masterModel.uid)
|
|
66
70
|
.findMany({
|
|
@@ -71,7 +75,7 @@ const adminService = ({ strapi }) => ({
|
|
|
71
75
|
},
|
|
72
76
|
async getById(id) {
|
|
73
77
|
const commonService = (0, utils_2.getPluginService)('common');
|
|
74
|
-
const { masterModel, itemModel } = (0, utils_2.
|
|
78
|
+
const { masterModel, itemModel } = (0, utils_2.getPluginModels)();
|
|
75
79
|
const entity = await strapi
|
|
76
80
|
.query(masterModel.uid)
|
|
77
81
|
.findOne({ where: { id }, populate: utils_2.DEFAULT_POPULATE });
|
|
@@ -95,11 +99,12 @@ const adminService = ({ strapi }) => ({
|
|
|
95
99
|
const commonService = (0, utils_2.getPluginService)('common');
|
|
96
100
|
const adminService = (0, utils_2.getPluginService)('admin');
|
|
97
101
|
const { enabled: i18nEnabled, defaultLocale } = await (0, i18n_1.getI18nStatus)({ strapi });
|
|
98
|
-
const {
|
|
102
|
+
const { slugify: customSlugifyConfig } = await adminService.config(false);
|
|
103
|
+
const { masterModel } = (0, utils_2.getPluginModels)();
|
|
99
104
|
const { name, visible } = payload;
|
|
100
105
|
const data = {
|
|
101
106
|
name,
|
|
102
|
-
slug: (0, slugify_1.default)(name).toLowerCase(),
|
|
107
|
+
slug: (0, slugify_1.default)(name, customSlugifyConfig).toLowerCase(),
|
|
103
108
|
visible,
|
|
104
109
|
};
|
|
105
110
|
const existingEntity = await strapi
|
|
@@ -122,13 +127,14 @@ const adminService = ({ strapi }) => ({
|
|
|
122
127
|
const adminService = (0, utils_2.getPluginService)('admin');
|
|
123
128
|
const commonService = (0, utils_2.getPluginService)('common');
|
|
124
129
|
const { enabled: i18nEnabled } = await (0, i18n_1.getI18nStatus)({ strapi });
|
|
125
|
-
const {
|
|
130
|
+
const { slugify: customSlugifyConfig } = await adminService.config(false);
|
|
131
|
+
const { masterModel } = (0, utils_2.getPluginModels)();
|
|
126
132
|
const { name, visible } = payload;
|
|
127
133
|
const existingEntity = await adminService.getById(id);
|
|
128
134
|
const detailsHaveChanged = existingEntity.name !== name || existingEntity.visible !== visible;
|
|
129
135
|
if (detailsHaveChanged) {
|
|
130
136
|
const newName = detailsHaveChanged ? name : existingEntity.name;
|
|
131
|
-
const newSlug = detailsHaveChanged ? (0, slugify_1.default)(name).toLowerCase() : existingEntity.slug;
|
|
137
|
+
const newSlug = detailsHaveChanged ? (0, slugify_1.default)(name, customSlugifyConfig).toLowerCase() : existingEntity.slug;
|
|
132
138
|
await strapi.query(masterModel.uid).update({
|
|
133
139
|
where: { id },
|
|
134
140
|
data: {
|
|
@@ -165,7 +171,7 @@ const adminService = ({ strapi }) => ({
|
|
|
165
171
|
return result;
|
|
166
172
|
},
|
|
167
173
|
async delete(id, auditLog) {
|
|
168
|
-
const { masterModel } = (0, utils_2.
|
|
174
|
+
const { masterModel } = (0, utils_2.getPluginModels)();
|
|
169
175
|
const adminService = (0, utils_2.getPluginService)('admin');
|
|
170
176
|
const entity = await adminService.getById(id);
|
|
171
177
|
const { enabled: i18nEnabled } = await (0, i18n_1.getI18nStatus)({ strapi });
|
|
@@ -195,7 +201,13 @@ const adminService = ({ strapi }) => ({
|
|
|
195
201
|
async updateConfig(newConfig) {
|
|
196
202
|
const commonService = (0, utils_2.getPluginService)('common');
|
|
197
203
|
const pluginStore = await commonService.getPluginStore();
|
|
204
|
+
const config = await pluginStore.get({ key: 'config' });
|
|
205
|
+
(0, utils_2.validateAdditionalFields)(newConfig.additionalFields);
|
|
198
206
|
await pluginStore.set({ key: 'config', value: newConfig });
|
|
207
|
+
const removedFields = (0, lodash_1.differenceBy)(config.additionalFields, newConfig.additionalFields, 'name').filter(i => i !== 'audience');
|
|
208
|
+
if (!(0, lodash_1.isEmpty)(removedFields)) {
|
|
209
|
+
await commonService.pruneCustomFields(removedFields);
|
|
210
|
+
}
|
|
199
211
|
},
|
|
200
212
|
async fillFromOtherLocale({ target, source, auditLog }) {
|
|
201
213
|
const { enabled } = await (0, i18n_1.getI18nStatus)({ strapi });
|