diff --git a/packages/core-plugin-api/src/extensions/extensions.tsx b/packages/core-plugin-api/src/extensions/extensions.tsx index 19da082ee1..b4b5c0bdfc 100644 --- a/packages/core-plugin-api/src/extensions/extensions.tsx +++ b/packages/core-plugin-api/src/extensions/extensions.tsx @@ -19,7 +19,7 @@ import { AnalyticsContext } from '../analytics/AnalyticsContext'; import { useApp } from '../app'; import { RouteRef, useRouteRef } from '../routing'; import { attachComponentData } from './componentData'; -import { Extension, BackstagePlugin } from '../plugin/types'; +import { Extension, BackstagePlugin, AnyMetadata } from '../plugin/types'; import { PluginErrorBoundary } from './PluginErrorBoundary'; /** @@ -73,8 +73,13 @@ export function createRoutableExtension< * variable for this extension. */ name?: string; + + /** + * + */ + metadata?: AnyMetadata; }): Extension { - const { component, mountPoint, name } = options; + const { component, mountPoint, name, metadata } = options; return createReactExtension({ component: { lazy: () => @@ -100,7 +105,7 @@ export function createRoutableExtension< } throw error; } - return ; + return ; }; const componentName = diff --git a/packages/core-plugin-api/src/plugin/index.ts b/packages/core-plugin-api/src/plugin/index.ts index 95f5a6b219..1ebe1b3446 100644 --- a/packages/core-plugin-api/src/plugin/index.ts +++ b/packages/core-plugin-api/src/plugin/index.ts @@ -17,6 +17,7 @@ export { createPlugin } from './Plugin'; export type { AnyExternalRoutes, + AnyMetadata, AnyRoutes, BackstagePlugin, Extension, diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx index f4a31e815a..d74b413dbe 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx @@ -37,12 +37,7 @@ import React from 'react'; import { createComponentRouteRef } from '../../routes'; import { CatalogTable, CatalogTableRow } from '../CatalogTable'; import { CatalogKindHeader } from '../CatalogKindHeader'; - -export type DefaultCatalogMetadataProps = { - createComponentTitle: string; - supportButtonText: string; - supportButton: () => JSX.Element; -}; +import { CatalogPluginMetadata } from '../../plugin'; /** * Props for root catalog pages. @@ -55,7 +50,7 @@ export interface DefaultCatalogPageProps { actions?: TableProps['actions']; initialKind?: string; tableOptions?: TableProps['options']; - metadata?: DefaultCatalogMetadataProps; + metadata?: CatalogPluginMetadata; } export function DefaultCatalogPage(props: DefaultCatalogPageProps) { diff --git a/plugins/catalog/src/plugin.ts b/plugins/catalog/src/plugin.ts index 9e5a335d5f..a8a0951b5d 100644 --- a/plugins/catalog/src/plugin.ts +++ b/plugins/catalog/src/plugin.ts @@ -30,6 +30,7 @@ import { discoveryApiRef, fetchApiRef, storageApiRef, + AnyMetadata, } from '@backstage/core-plugin-api'; import { DefaultStarredEntitiesApi } from './apis'; import { AboutCardProps } from './components/AboutCard'; @@ -44,6 +45,19 @@ import { HasSystemsCardProps } from './components/HasSystemsCard'; import { RelatedEntitiesCardProps } from './components/RelatedEntitiesCard'; import { rootRouteRef } from './routes'; +export interface CatalogPluginMetadata extends AnyMetadata { + createComponentTitle: string; + supportButton: () => Promise; + supportButtonText: string; +} + +const metadata = { + createComponentTitle: 'Create Component', + supportButton: () => + import('@backstage/core-components').then(m => m.SupportButton), + supportButtonText: 'All your software catalog entities', +} as CatalogPluginMetadata; + /** @public */ export const catalogPlugin = createPlugin({ id: 'catalog', @@ -72,12 +86,7 @@ export const catalogPlugin = createPlugin({ createComponent: createComponentRouteRef, viewTechDoc: viewTechDocRouteRef, }, - metadata: { - createComponentTitle: 'Create Component', - supportButton: () => - import('@backstage/core-components').then(m => m.SupportButton), - supportButtonText: 'All your software catalog entities', - }, + metadata, }); /** @public */ @@ -87,6 +96,7 @@ export const CatalogIndexPage: (props: DefaultCatalogPageProps) => JSX.Element = name: 'CatalogIndexPage', component: () => import('./components/CatalogPage').then(m => m.CatalogPage), + metadata, mountPoint: rootRouteRef, }), );