strapi-plugin-navigation 2.0.1 → 2.0.2
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 +19 -3
- package/__mocks__/strapi.js +29 -18
- package/admin/src/components/ConfirmationDialog/index.js +56 -0
- package/admin/src/components/Item/ItemCardHeader/index.js +6 -12
- package/admin/src/components/Item/index.js +8 -9
- package/admin/src/components/RestartAlert/index.js +8 -0
- package/admin/src/hooks/useAllContentTypes.js +13 -0
- package/admin/src/hooks/useNavigationConfig.js +58 -0
- package/admin/src/index.js +24 -1
- package/admin/src/pages/SettingsPage/index.js +311 -0
- package/admin/src/pages/View/components/NavigationItemForm/index.js +4 -5
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +3 -6
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +2 -4
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +2 -4
- package/admin/src/translations/en.json +47 -7
- package/admin/src/translations/fr.json +4 -4
- package/admin/src/utils/api.js +51 -0
- package/admin/src/utils/index.js +20 -0
- package/package.json +4 -4
- package/server/bootstrap.js +30 -1
- package/server/controllers/navigation.js +26 -2
- package/server/graphql/index.js +3 -4
- package/server/graphql/types/content-types-name-fields.js +4 -2
- package/server/graphql/types/navigation-related.js +2 -2
- package/server/routes/admin.js +24 -1
- package/server/services/navigation.js +38 -7
- package/strapi-server.js +0 -2
- package/yarn-error.log +5263 -0
- package/server/register.js +0 -5
|
@@ -19,10 +19,34 @@ const errorHandler = (ctx) => (error) => {
|
|
|
19
19
|
throw error;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
module.exports = {
|
|
22
|
+
module.exports = ({strapi}) => ({
|
|
23
23
|
async config() {
|
|
24
24
|
return getService().config();
|
|
25
25
|
},
|
|
26
|
+
|
|
27
|
+
async updateConfig(ctx) {
|
|
28
|
+
await getService().updateConfig(ctx.request.body)
|
|
29
|
+
return ctx.send({ status: 200 });
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async restoreConfig(ctx) {
|
|
33
|
+
await getService().restoreConfig()
|
|
34
|
+
return ctx.send({ status: 200 })
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
async settingsConfig() {
|
|
38
|
+
return getService().config(true);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
async settingsRestart(ctx) {
|
|
42
|
+
try {
|
|
43
|
+
await getService().restart();
|
|
44
|
+
return ctx.send({ status: 200 });
|
|
45
|
+
} catch (e) {
|
|
46
|
+
errorHandler(ctx, e);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
26
50
|
async get() {
|
|
27
51
|
return getService().get();
|
|
28
52
|
},
|
|
@@ -69,4 +93,4 @@ module.exports = {
|
|
|
69
93
|
menuOnly
|
|
70
94
|
);
|
|
71
95
|
},
|
|
72
|
-
};
|
|
96
|
+
});
|
package/server/graphql/index.js
CHANGED
|
@@ -2,16 +2,15 @@ const getTypes = require('./types');
|
|
|
2
2
|
const getQueries = require('./queries');
|
|
3
3
|
const getResolversConfig = require('./resolvers-config');
|
|
4
4
|
|
|
5
|
-
module.exports = () => {
|
|
5
|
+
module.exports = async ({ strapi, config }) => {
|
|
6
6
|
const extensionService = strapi.plugin('graphql').service('extension');
|
|
7
|
-
|
|
8
7
|
extensionService.shadowCRUD('plugin::navigation.audience').disable();
|
|
9
8
|
extensionService.shadowCRUD('plugin::navigation.navigation').disable();
|
|
10
9
|
extensionService.shadowCRUD('plugin::navigation.navigation-item').disable();
|
|
11
10
|
extensionService.shadowCRUD('plugin::navigation.navigations-items-related').disable();
|
|
12
11
|
|
|
13
|
-
extensionService.use(({ nexus
|
|
14
|
-
const types = getTypes({ strapi, nexus });
|
|
12
|
+
extensionService.use(({strapi, nexus}) => {
|
|
13
|
+
const types = getTypes({ strapi, nexus, config });
|
|
15
14
|
const queries = getQueries({ strapi, nexus });
|
|
16
15
|
const resolversConfig = getResolversConfig({ strapi });
|
|
17
16
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module.exports = ({ nexus }) => nexus.objectType({
|
|
2
2
|
name: "ContentTypesNameFields",
|
|
3
|
-
definition(t) {
|
|
3
|
+
async definition(t) {
|
|
4
4
|
t.nonNull.list.nonNull.string("default")
|
|
5
|
-
const
|
|
5
|
+
const pluginStore = strapi.store({ type: 'plugin', name: 'navigation' });
|
|
6
|
+
const config = await pluginStore.get({ key: 'config' });
|
|
7
|
+
const contentTypesNameFields = config.contentTypesNameFields;
|
|
6
8
|
Object.keys(contentTypesNameFields || {}).forEach(key => t.nonNull.list.string(key))
|
|
7
9
|
}
|
|
8
10
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module.exports = ({ strapi, nexus }) => {
|
|
2
|
-
const related =
|
|
1
|
+
module.exports = ({ strapi, nexus, config }) => {
|
|
2
|
+
const related = config.gql?.navigationItemRelated;
|
|
3
3
|
const name = "NavigationRelated";
|
|
4
4
|
|
|
5
5
|
if (related?.length) {
|
package/server/routes/admin.js
CHANGED
|
@@ -16,6 +16,16 @@ module.exports = {
|
|
|
16
16
|
path: '/config',
|
|
17
17
|
handler: 'navigation.config',
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
method: 'PUT',
|
|
21
|
+
path: '/config',
|
|
22
|
+
handler: 'navigation.updateConfig',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
method: 'DELETE',
|
|
26
|
+
path: '/config',
|
|
27
|
+
handler: 'navigation.restoreConfig',
|
|
28
|
+
},
|
|
19
29
|
{
|
|
20
30
|
method: 'GET',
|
|
21
31
|
path: '/:id',
|
|
@@ -33,6 +43,19 @@ module.exports = {
|
|
|
33
43
|
policies: [
|
|
34
44
|
'admin::isAuthenticatedAdmin'
|
|
35
45
|
]
|
|
36
|
-
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
method: 'GET',
|
|
49
|
+
path: '/settings/config',
|
|
50
|
+
handler: 'navigation.settingsConfig',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
method: 'GET',
|
|
54
|
+
path: '/settings/restart',
|
|
55
|
+
handler: 'navigation.settingsRestart',
|
|
56
|
+
config: {
|
|
57
|
+
policies: [],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
37
60
|
]
|
|
38
61
|
}
|
|
@@ -19,7 +19,7 @@ const { KIND_TYPES } = require('./utils/constant');
|
|
|
19
19
|
const utilsFunctionsFactory = require('./utils/functions');
|
|
20
20
|
const { renderType } = require('../content-types/navigation/lifecycle');
|
|
21
21
|
const { type: itemType, additionalFields: configAdditionalFields } = require('../content-types/navigation-item').lifecycle;
|
|
22
|
-
const { NotFoundError } =
|
|
22
|
+
const { NotFoundError } = require('@strapi/utils').errors
|
|
23
23
|
const excludedContentTypes = ['strapi::'];
|
|
24
24
|
const contentTypesNameFieldsDefaults = ['title', 'subject', 'name'];
|
|
25
25
|
|
|
@@ -65,12 +65,19 @@ module.exports = ({ strapi }) => {
|
|
|
65
65
|
};
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
+
async restart() {
|
|
69
|
+
setImmediate(() => strapi.reload());
|
|
70
|
+
},
|
|
71
|
+
|
|
68
72
|
// Get plugin config
|
|
69
|
-
async config() {
|
|
70
|
-
const {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
73
|
+
async config(viaSettingsPage = false) {
|
|
74
|
+
const { audienceModel, service } = utilsFunctions.extractMeta(strapi.plugins);
|
|
75
|
+
const pluginStore = await strapi.store({ type: 'plugin', name: 'navigation' });
|
|
76
|
+
const config = await pluginStore.get({ key: 'config' });
|
|
77
|
+
const additionalFields = config.additionalFields;
|
|
78
|
+
const contentTypesNameFields = config.contentTypesNameFields;
|
|
79
|
+
const allowedLevels = config.allowedLevels;
|
|
80
|
+
const isGQLPluginEnabled = !isNil(strapi.plugin('graphql'));
|
|
74
81
|
|
|
75
82
|
let extendedResult = {};
|
|
76
83
|
const result = {
|
|
@@ -81,6 +88,7 @@ module.exports = ({ strapi }) => {
|
|
|
81
88
|
},
|
|
82
89
|
allowedLevels,
|
|
83
90
|
additionalFields,
|
|
91
|
+
isGQLPluginEnabled: viaSettingsPage ? isGQLPluginEnabled : undefined,
|
|
84
92
|
};
|
|
85
93
|
|
|
86
94
|
if (additionalFields.includes(configAdditionalFields.AUDIENCE)) {
|
|
@@ -102,10 +110,33 @@ module.exports = ({ strapi }) => {
|
|
|
102
110
|
};
|
|
103
111
|
},
|
|
104
112
|
|
|
113
|
+
async updateConfig(newConfig) {
|
|
114
|
+
const pluginStore = await strapi.store({ type: 'plugin', name: 'navigation' });
|
|
115
|
+
await pluginStore.set({ key: 'config', value: newConfig });
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
async restoreConfig() {
|
|
119
|
+
const pluginStore = await strapi.store({ type: 'plugin', name: 'navigation' });
|
|
120
|
+
const defaultConfig = await strapi.plugin('navigation').config
|
|
121
|
+
|
|
122
|
+
await pluginStore.delete({ key: 'config' })
|
|
123
|
+
await pluginStore.set({
|
|
124
|
+
key: 'config', value: {
|
|
125
|
+
additionalFields: defaultConfig('additionalFields'),
|
|
126
|
+
contentTypes: defaultConfig('contentTypes'),
|
|
127
|
+
contentTypesNameFields: defaultConfig('contentTypesNameFields'),
|
|
128
|
+
allowedLevels: defaultConfig('allowedLevels'),
|
|
129
|
+
gql: defaultConfig('gql'),
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
|
|
105
134
|
async configContentTypes() {
|
|
135
|
+
const pluginStore = strapi.store({ type: 'plugin', name: 'navigation' });
|
|
136
|
+
const config = await pluginStore.get({ key: 'config' });
|
|
106
137
|
const eligibleContentTypes =
|
|
107
138
|
await Promise.all(
|
|
108
|
-
|
|
139
|
+
config.contentTypes
|
|
109
140
|
.filter(contentType => !!strapi.contentTypes[contentType])
|
|
110
141
|
.map(
|
|
111
142
|
async (key) => {
|
package/strapi-server.js
CHANGED
|
@@ -4,7 +4,6 @@ const routes = require('./server/routes');
|
|
|
4
4
|
const controllers = require('./server/controllers');
|
|
5
5
|
const contentTypes = require('./server/content-types');
|
|
6
6
|
const config = require('./server/config');
|
|
7
|
-
const register = require('./server/register');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
module.exports = () => {
|
|
@@ -15,6 +14,5 @@ module.exports = () => {
|
|
|
15
14
|
controllers,
|
|
16
15
|
services,
|
|
17
16
|
contentTypes,
|
|
18
|
-
register,
|
|
19
17
|
};
|
|
20
18
|
};
|