/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/content-releases/admin/src/index.ts
162 строки
5 KB
Andrei L
fix(admin): clean up lazy component registration warnings (#25015)
30 апр 2026, 16:27
Не верифицирован
30 апр 2026, 16:27
90623ba
Код
Авторство
О чём код?
import { PaperPlane } from '@strapi/icons'; import { ReleaseAction } from './components/ReleaseAction'; import { ReleaseActionModalForm } from './components/ReleaseActionModal'; import { addColumnToTableHook } from './components/ReleaseListCell'; import { Panel as ReleasesPanel } from './components/ReleasesPanel'; import { PERMISSIONS, PLUGIN_ID } from './constants'; import { pluginId } from './pluginId'; import { prefixPluginTranslations } from './utils/prefixPluginTranslations'; import type { StrapiApp } from '@strapi/admin/strapi-admin'; import type { DocumentActionComponent, BulkActionComponent, } from '@strapi/content-manager/strapi-admin'; import type { Plugin } from '@strapi/types'; // eslint-disable-next-line import/no-default-export const admin: Plugin.Config.AdminInput = { // eslint-disable-next-line @typescript-eslint/no-explicit-any register(app: StrapiApp) { /** * Hook that adds the locale column in the Release Details table * @constant * @type {string} */ app.createHook('ContentReleases/pages/ReleaseDetails/add-locale-in-releases'); if (window.strapi.features.isEnabled('cms-content-releases')) { app.addMenuLink({ to: `plugins/${pluginId}`, icon: PaperPlane, intlLabel: { id: `${pluginId}.plugin.name`, defaultMessage: 'Releases', }, Component: () => import('./pages/App').then((mod) => ({ default: mod.App })), permissions: PERMISSIONS.main, position: 2, }); // Insert the releases container into the CM's sidebar on the Edit View const contentManagerPluginApis = app.getPlugin('content-manager').apis; if ( 'addEditViewSidePanel' in contentManagerPluginApis && typeof contentManagerPluginApis.addEditViewSidePanel === 'function' ) { contentManagerPluginApis.addEditViewSidePanel([ReleasesPanel]); } // Insert the "add to release" action into the CM's Edit View if ( 'addDocumentAction' in contentManagerPluginApis && typeof contentManagerPluginApis.addDocumentAction === 'function' ) { contentManagerPluginApis.addDocumentAction((actions: DocumentActionComponent[]) => { const indexOfDeleteAction = actions.findIndex((action) => action.type === 'unpublish'); actions.splice(indexOfDeleteAction, 0, ReleaseActionModalForm); return actions; }); } app.addSettingsLink('global', { id: pluginId, to: 'releases', intlLabel: { id: `${pluginId}.plugin.name`, defaultMessage: 'Releases', }, licenseOnly: true, permissions: [], Component() { return import('./pages/ReleasesSettingsPage').then((mod) => ({ default: mod.ProtectedReleasesSettingsPage, })); }, }); if ( 'addBulkAction' in contentManagerPluginApis && typeof contentManagerPluginApis.addBulkAction === 'function' ) { contentManagerPluginApis.addBulkAction((actions: BulkActionComponent[]) => { // We want to add this action to just before the delete action all the time const deleteActionIndex = actions.findIndex((action) => action.type === 'delete'); actions.splice(deleteActionIndex, 0, ReleaseAction); return actions; }); } // Hook that adds a column into the CM's LV table app.registerHook('Admin/CM/pages/ListView/inject-column-in-table', addColumnToTableHook); app.widgets.register([ { icon: PaperPlane, title: { id: `${PLUGIN_ID}.widget.upcoming-releases.title`, defaultMessage: 'Upcoming releases', }, component: async () => { const { UpcomingReleasesWidget } = await import('./components/Widgets'); return UpcomingReleasesWidget; }, pluginId: PLUGIN_ID, id: 'upcoming-releases', link: { label: { id: `${PLUGIN_ID}.widget.upcoming-releases.link`, defaultMessage: 'Open Releases', }, href: '/plugins/content-releases', }, }, ]); } else if ( !window.strapi.features.isEnabled('cms-content-releases') && window.strapi?.flags?.promoteEE ) { app.addSettingsLink('global', { id: pluginId, to: 'purchase-content-releases', intlLabel: { id: `${pluginId}.plugin.name`, defaultMessage: 'Releases', }, permissions: [], Component() { return import('./pages/PurchaseContentReleases').then((mod) => ({ default: mod.PurchaseContentReleases, })); }, licenseOnly: true, }); } }, async registerTrads({ locales }: { locales: string[] }) { const importedTrads = await Promise.all( locales.map((locale) => { return import(`./translations/${locale}.json`) .then(({ default: data }) => { return { data: prefixPluginTranslations(data, 'content-releases'), locale, }; }) .catch(() => { return { data: {}, locale, }; }); }) ); return Promise.resolve(importedTrads); }, }; // eslint-disable-next-line import/no-default-export export default admin;