2021-07-28 08:16:15 +02:00
|
|
|
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
|
|
|
|
2023-06-20 13:15:59 +02:00
|
|
|
import { PERMISSIONS } from './constants';
|
2020-08-03 16:49:40 +02:00
|
|
|
import getTrad from './utils/getTrad';
|
2019-04-16 16:55:53 +02:00
|
|
|
|
2021-05-10 14:02:47 +02:00
|
|
|
const name = pluginPkg.strapi.name;
|
2019-04-16 16:55:53 +02:00
|
|
|
|
2021-05-10 14:02:47 +02:00
|
|
|
export default {
|
|
|
|
register(app) {
|
2021-06-08 09:02:20 +02:00
|
|
|
// Create the plugin's settings section
|
2021-06-09 12:22:02 +02:00
|
|
|
app.createSettingSection(
|
2021-06-08 09:02:20 +02:00
|
|
|
{
|
2023-08-11 15:17:01 +02:00
|
|
|
id: 'users-permissions',
|
2021-06-08 09:02:20 +02:00
|
|
|
intlLabel: {
|
|
|
|
id: getTrad('Settings.section-label'),
|
|
|
|
defaultMessage: 'Users & Permissions plugin',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[
|
|
|
|
{
|
|
|
|
intlLabel: {
|
2022-03-15 10:25:43 +01:00
|
|
|
id: 'global.roles',
|
2021-06-08 09:02:20 +02:00
|
|
|
defaultMessage: 'Roles',
|
|
|
|
},
|
|
|
|
id: 'roles',
|
2024-01-15 11:13:36 +00:00
|
|
|
to: `users-permissions/roles`,
|
|
|
|
Component: () => import('./pages/Roles'),
|
2023-06-20 13:15:59 +02:00
|
|
|
permissions: PERMISSIONS.accessRoles,
|
2021-06-08 09:02:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
intlLabel: {
|
|
|
|
id: getTrad('HeaderNav.link.providers'),
|
|
|
|
defaultMessage: 'Providers',
|
|
|
|
},
|
|
|
|
id: 'providers',
|
2024-01-15 11:13:36 +00:00
|
|
|
to: `users-permissions/providers`,
|
|
|
|
Component: () => import('./pages/Providers'),
|
2023-06-20 13:15:59 +02:00
|
|
|
permissions: PERMISSIONS.readProviders,
|
2021-06-08 09:02:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
intlLabel: {
|
2021-08-04 19:24:10 +02:00
|
|
|
id: getTrad('HeaderNav.link.emailTemplates'),
|
2021-06-08 09:02:20 +02:00
|
|
|
defaultMessage: 'Email templates',
|
|
|
|
},
|
|
|
|
id: 'email-templates',
|
2024-01-15 11:13:36 +00:00
|
|
|
to: `users-permissions/email-templates`,
|
|
|
|
Component: () => import('./pages/EmailTemplates'),
|
2023-06-20 13:15:59 +02:00
|
|
|
permissions: PERMISSIONS.readEmailTemplates,
|
2021-06-08 09:02:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
intlLabel: {
|
2021-08-04 19:24:10 +02:00
|
|
|
id: getTrad('HeaderNav.link.advancedSettings'),
|
2021-06-08 09:02:20 +02:00
|
|
|
defaultMessage: 'Advanced Settings',
|
|
|
|
},
|
|
|
|
id: 'advanced-settings',
|
2024-01-15 11:13:36 +00:00
|
|
|
to: `users-permissions/advanced-settings`,
|
2024-03-05 08:50:41 +00:00
|
|
|
Component: () =>
|
|
|
|
import('./pages/AdvancedSettings').then((mod) => ({
|
|
|
|
default: mod.ProtectedAdvancedSettingsPage,
|
|
|
|
})),
|
2023-06-20 13:15:59 +02:00
|
|
|
permissions: PERMISSIONS.readAdvancedSettings,
|
2021-06-08 09:02:20 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2021-05-10 14:02:47 +02:00
|
|
|
app.registerPlugin({
|
2023-08-11 15:17:01 +02:00
|
|
|
id: 'users-permissions',
|
2021-05-10 14:02:47 +02:00
|
|
|
name,
|
|
|
|
});
|
|
|
|
},
|
2021-07-21 09:05:20 +02:00
|
|
|
bootstrap() {},
|
2021-06-09 11:22:23 +02:00
|
|
|
async registerTrads({ locales }) {
|
|
|
|
const importedTrads = await Promise.all(
|
2022-08-08 23:33:39 +02:00
|
|
|
locales.map((locale) => {
|
2023-10-30 11:36:16 +00:00
|
|
|
return import(`./translations/${locale}.json`)
|
2021-06-09 11:22:23 +02:00
|
|
|
.then(({ default: data }) => {
|
|
|
|
return {
|
2023-08-11 15:17:01 +02:00
|
|
|
data: prefixPluginTranslations(data, 'users-permissions'),
|
2021-06-09 11:22:23 +02:00
|
|
|
locale,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
return {
|
|
|
|
data: {},
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
return Promise.resolve(importedTrads);
|
|
|
|
},
|
2019-04-16 16:55:53 +02:00
|
|
|
};
|