Draft(WIP): Add reconfigure to plugin
Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -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<T> {
|
||||
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 <InnerComponent {...props} />;
|
||||
return <InnerComponent {...props} {...metadata} />;
|
||||
};
|
||||
|
||||
const componentName =
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
export { createPlugin } from './Plugin';
|
||||
export type {
|
||||
AnyExternalRoutes,
|
||||
AnyMetadata,
|
||||
AnyRoutes,
|
||||
BackstagePlugin,
|
||||
Extension,
|
||||
|
||||
@@ -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<CatalogTableRow>['actions'];
|
||||
initialKind?: string;
|
||||
tableOptions?: TableProps<CatalogTableRow>['options'];
|
||||
metadata?: DefaultCatalogMetadataProps;
|
||||
metadata?: CatalogPluginMetadata;
|
||||
}
|
||||
|
||||
export function DefaultCatalogPage(props: DefaultCatalogPageProps) {
|
||||
|
||||
@@ -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<JSX.Element>;
|
||||
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,
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user