Draft(WIP): Add reconfigure to plugin

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2022-05-09 16:49:36 +02:00
parent 6be0e38b56
commit f45d3da189
4 changed files with 27 additions and 16 deletions
@@ -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) {
+16 -6
View File
@@ -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,
}),
);