Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions admin/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { prefixPluginTranslations } from '@strapi/helper-plugin';

import { Initializer, PluginIcon } from './components';
import pluginPermissions from './permissions';
import reducers from './reducers';
import { getTrad, pluginId, pluginName } from './utils';

Expand All @@ -20,13 +21,14 @@ export default {

return component;
},
permissions: [
permissions: pluginPermissions.access,
/* permissions: [
// Uncomment to set the permissions of the plugin here
// {
// action: '', // the action name should be plugin::plugin-name.actionType
// subject: null,
// },
],
], */
});

app.registerPlugin({
Expand Down
7 changes: 7 additions & 0 deletions admin/src/permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import permissions from '../../permissions';

const pluginPermissions = {
access: [{ action: permissions.render(permissions.menus.read), subject: null }],
};

export default pluginPermissions;
8 changes: 8 additions & 0 deletions permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
render: function (uid) {
return `plugin::menus.${uid}`;
},
menus: {
read: 'read',
},
};
30 changes: 30 additions & 0 deletions server/bootstrap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

const permissions = require('../../permissions');

const assertUserPermissionsAvailability = ({ strapi }) => {
if (!strapi.plugin("users-permissions")) {
throw new Error(
"In order to make the menus plugin work the users-permissions plugin is required"
);
}
};

const setupPermissions = async ({ strapi }) => {
// Add permissions
const actions = [
{
section: "plugins",
displayName: "Read & Update",
uid: permissions.menus.read,
pluginName: "menus",
},
];
await strapi.admin.services.permission.actionProvider.registerMany(actions);
};

module.exports = async ({ strapi }) => {
assertUserPermissionsAvailability({ strapi });

await setupPermissions({ strapi });
};
3 changes: 2 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const bootstrap = require('./bootstrap');
const config = require('./config');
const contentTypes = require('./content-types');
const controllers = require('./controllers');
Expand All @@ -8,7 +9,7 @@ const routes = require('./routes');
const services = require('./services');

module.exports = {
// bootstrap,
bootstrap,
config,
contentTypes,
controllers,
Expand Down