96 lines
2.6 KiB
JavaScript
Raw Normal View History

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',
to: `users-permissions/roles`,
Component: () => import('./pages/Roles'),
permissions: PERMISSIONS.accessRoles,
},
{
intlLabel: {
id: getTrad('HeaderNav.link.providers'),
defaultMessage: 'Providers',
},
id: 'providers',
to: `users-permissions/providers`,
Component: () => import('./pages/Providers'),
permissions: PERMISSIONS.readProviders,
},
{
intlLabel: {
2021-08-04 19:24:10 +02:00
id: getTrad('HeaderNav.link.emailTemplates'),
defaultMessage: 'Email templates',
},
id: 'email-templates',
to: `users-permissions/email-templates`,
Component: () => import('./pages/EmailTemplates'),
permissions: PERMISSIONS.readEmailTemplates,
},
{
intlLabel: {
2021-08-04 19:24:10 +02:00
id: getTrad('HeaderNav.link.advancedSettings'),
defaultMessage: 'Advanced Settings',
},
id: 'advanced-settings',
to: `users-permissions/advanced-settings`,
Component: () =>
import('./pages/AdvancedSettings').then((mod) => ({
default: mod.ProtectedAdvancedSettingsPage,
})),
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(`./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
};