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-10-14 14:37:00 +02:00
|
|
|
// import pluginPermissions from './permissions';
|
|
|
|
// 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;
|
|
|
|
const { icon, 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,
|
|
|
|
icon,
|
|
|
|
id: pluginId,
|
|
|
|
isReady: true,
|
|
|
|
isRequired: pluginPkg.strapi.required || false,
|
|
|
|
name,
|
|
|
|
});
|
2021-03-20 00:54:18 +01:00
|
|
|
|
2021-10-14 14:37:00 +02:00
|
|
|
app.addMenuLink({
|
|
|
|
to: `/plugins/${pluginId}`,
|
|
|
|
icon,
|
|
|
|
intlLabel: {
|
|
|
|
id: `${pluginId}.plugin.name`,
|
|
|
|
defaultMessage: 'Config Sync',
|
|
|
|
},
|
|
|
|
Component: async () => {
|
|
|
|
const component = await import(
|
|
|
|
/* webpackChunkName: "config-sync-settings-page" */ './containers/App'
|
|
|
|
);
|
2021-03-19 19:04:22 +01:00
|
|
|
|
2021-10-14 14:37:00 +02:00
|
|
|
return component;
|
|
|
|
},
|
|
|
|
permissions: [], // TODO: Add permission to view settings page.
|
|
|
|
});
|
|
|
|
},
|
|
|
|
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-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
|
|
|
};
|