125 lines
3.7 KiB
JavaScript
Raw Normal View History

// NOTE TO PLUGINS DEVELOPERS:
// If you modify this file by adding new options to the plugin entry point
// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
import { prefixPluginTranslations } from '@strapi/helper-plugin';
2023-06-12 16:22:11 +02:00
2019-04-16 16:55:53 +02:00
import pluginPkg from '../../package.json';
2023-06-12 16:22:11 +02:00
import { PERMISSIONS } from './constants';
import getTrad from './utils/getTrad';
2019-04-16 16:55:53 +02:00
const name = pluginPkg.strapi.name;
2019-04-16 16:55:53 +02:00
export default {
register(app) {
// Create the plugin's settings section
app.createSettingSection(
{
2023-08-11 15:17:01 +02:00
id: 'users-permissions',
intlLabel: {
id: getTrad('Settings.section-label'),
defaultMessage: 'Users & Permissions plugin',
},
},
[
{
intlLabel: {
id: 'global.roles',
defaultMessage: 'Roles',
},
id: 'roles',
2023-08-11 15:17:01 +02:00
to: `/settings/users-permissions/roles`,
async Component() {
const component = await import(
/* webpackChunkName: "users-roles-settings-page" */ './pages/Roles'
);
return component;
},
permissions: PERMISSIONS.accessRoles,
},
{
intlLabel: {
id: getTrad('HeaderNav.link.providers'),
defaultMessage: 'Providers',
},
id: 'providers',
2023-08-11 15:17:01 +02:00
to: `/settings/users-permissions/providers`,
async Component() {
const component = await import(
/* webpackChunkName: "users-providers-settings-page" */ './pages/Providers'
);
return component;
},
permissions: PERMISSIONS.readProviders,
},
{
intlLabel: {
2021-08-04 19:24:10 +02:00
id: getTrad('HeaderNav.link.emailTemplates'),
defaultMessage: 'Email templates',
},
id: 'email-templates',
2023-08-11 15:17:01 +02:00
to: `/settings/users-permissions/email-templates`,
async Component() {
const component = await import(
/* webpackChunkName: "users-email-settings-page" */ './pages/EmailTemplates'
);
return component;
},
permissions: PERMISSIONS.readEmailTemplates,
},
{
intlLabel: {
2021-08-04 19:24:10 +02:00
id: getTrad('HeaderNav.link.advancedSettings'),
defaultMessage: 'Advanced Settings',
},
id: 'advanced-settings',
2023-08-11 15:17:01 +02:00
to: `/settings/users-permissions/advanced-settings`,
async Component() {
const component = await import(
/* webpackChunkName: "users-advanced-settings-page" */ './pages/AdvancedSettings'
);
return component;
},
permissions: PERMISSIONS.readAdvancedSettings,
},
]
);
app.registerPlugin({
2023-08-11 15:17:01 +02:00
id: 'users-permissions',
name,
});
},
bootstrap() {},
async registerTrads({ locales }) {
const importedTrads = await Promise.all(
2022-08-08 23:33:39 +02:00
locales.map((locale) => {
return import(
/* webpackChunkName: "users-permissions-translation-[request]" */ `./translations/${locale}.json`
)
.then(({ default: data }) => {
return {
2023-08-11 15:17:01 +02:00
data: prefixPluginTranslations(data, 'users-permissions'),
locale,
};
})
.catch(() => {
return {
data: {},
locale,
};
});
})
);
return Promise.resolve(importedTrads);
},
2019-04-16 16:55:53 +02:00
};