2021-10-14 14:37:00 +02:00
|
|
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
2021-03-19 19:04:22 +01:00
|
|
|
import pluginPkg from '../../package.json';
|
2021-03-20 00:54:18 +01:00
|
|
|
import pluginId from './helpers/pluginId';
|
2021-11-10 19:51:00 +01:00
|
|
|
import pluginPermissions from './permissions';
|
2022-03-16 22:09:46 +01:00
|
|
|
// import pluginIcon from './components/PluginIcon';
|
2021-10-14 14:37:00 +02:00
|
|
|
// import getTrad from './helpers/getTrad';
|
2021-03-19 19:04:22 +01:00
|
|
|
|
2021-10-14 14:37:00 +02:00
|
|
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
2021-10-27 16:04:58 +02:00
|
|
|
const { name } = pluginPkg.strapi;
|
2021-03-20 00:54:18 +01:00
|
|
|
|
2021-10-14 14:37:00 +02:00
|
|
|
export default {
|
|
|
|
register(app) {
|
|
|
|
app.registerPlugin({
|
|
|
|
description: pluginDescription,
|
|
|
|
id: pluginId,
|
|
|
|
isReady: true,
|
|
|
|
isRequired: pluginPkg.strapi.required || false,
|
|
|
|
name,
|
|
|
|
});
|
2021-03-20 00:54:18 +01:00
|
|
|
|
2022-03-16 22:09:46 +01:00
|
|
|
app.createSettingSection(
|
|
|
|
{
|
|
|
|
id: pluginId,
|
|
|
|
intlLabel: {
|
|
|
|
id: `${pluginId}.plugin.name`,
|
|
|
|
defaultMessage: 'Config Sync',
|
|
|
|
},
|
2021-10-14 14:37:00 +02:00
|
|
|
},
|
2022-03-16 22:09:46 +01:00
|
|
|
[
|
|
|
|
{
|
|
|
|
intlLabel: {
|
|
|
|
id: `${pluginId}.Settings.Tool.Title`,
|
|
|
|
defaultMessage: 'Tools',
|
|
|
|
},
|
|
|
|
id: 'config-sync-page',
|
|
|
|
to: `/settings/${pluginId}`,
|
|
|
|
Component: async () => {
|
|
|
|
const component = await import(
|
|
|
|
/* webpackChunkName: "config-sync-settings-page" */ './containers/App'
|
|
|
|
);
|
2021-03-19 19:04:22 +01:00
|
|
|
|
2022-03-16 22:09:46 +01:00
|
|
|
return component;
|
|
|
|
},
|
|
|
|
permissions: pluginPermissions['settings'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
);
|
2021-10-14 14:37:00 +02:00
|
|
|
},
|
|
|
|
bootstrap(app) {},
|
|
|
|
async registerTrads({ locales }) {
|
|
|
|
const importedTrads = await Promise.all(
|
|
|
|
locales.map((locale) => {
|
|
|
|
return import(
|
|
|
|
/* webpackChunkName: "config-sync-translation-[request]" */ `./translations/${locale}.json`
|
|
|
|
)
|
|
|
|
.then(({ default: data }) => {
|
|
|
|
return {
|
|
|
|
data: prefixPluginTranslations(data, pluginId),
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
return {
|
|
|
|
data: {},
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
});
|
2021-12-08 16:05:45 +01:00
|
|
|
}),
|
2021-10-14 14:37:00 +02:00
|
|
|
);
|
2021-03-19 19:04:22 +01:00
|
|
|
|
2021-10-14 14:37:00 +02:00
|
|
|
return Promise.resolve(importedTrads);
|
|
|
|
},
|
2021-03-19 19:04:22 +01:00
|
|
|
};
|