mirror of
https://github.com/strapi/strapi.git
synced 2026-06-02 16:27:47 +00:00
* fix(admin): don't warn when Component is missing in addMenuLink/addSettingsLink * fix: add some missing StrapiApp types * fix(admin): clean up lazy component registrations --------- Co-authored-by: Bassel Kanso <basselkanso82@gmail.com>
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
/* eslint-disable check-file/filename-naming-convention */
|
|
|
|
import { Cloud } from '@strapi/icons';
|
|
|
|
import { Initializer } from './components/Initializer';
|
|
import { pluginId } from './pluginId';
|
|
import { prefixPluginTranslations } from './utils/prefixPluginTranslations';
|
|
|
|
import type { StrapiApp } from '@strapi/admin/strapi-admin';
|
|
|
|
const pluginName = 'Deploy';
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default {
|
|
register(app: StrapiApp) {
|
|
const { backendURL } = window.strapi;
|
|
|
|
// Only add the plugin menu link and registering it if the project is on development (localhost).
|
|
if (backendURL?.includes('localhost')) {
|
|
app.addMenuLink({
|
|
to: `plugins/${pluginId}`,
|
|
icon: Cloud,
|
|
intlLabel: {
|
|
id: `${pluginId}.Plugin.name`,
|
|
defaultMessage: pluginName,
|
|
},
|
|
Component: () => import('./pages/App').then((mod) => ({ default: mod.App })),
|
|
permissions: [],
|
|
});
|
|
const plugin = {
|
|
id: pluginId,
|
|
initializer: Initializer,
|
|
isReady: false,
|
|
name: pluginName,
|
|
};
|
|
|
|
app.registerPlugin(plugin);
|
|
}
|
|
},
|
|
|
|
async registerTrads(app: any) {
|
|
const { locales } = app;
|
|
|
|
const importedTrads = await Promise.all(
|
|
(locales as any[]).map((locale) => {
|
|
return import(`./translations/${locale}.json`)
|
|
.then(({ default: data }) => {
|
|
return {
|
|
data: prefixPluginTranslations(data, pluginId),
|
|
locale,
|
|
};
|
|
})
|
|
.catch(() => {
|
|
return {
|
|
data: {},
|
|
locale,
|
|
};
|
|
});
|
|
})
|
|
);
|
|
|
|
return Promise.resolve(importedTrads);
|
|
},
|
|
};
|