A bit changed the structure
Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -97,6 +97,7 @@ import * as plugins from './plugins';
|
||||
import { techDocsPage } from './components/techdocs/TechDocsPage';
|
||||
import { ApacheAirflowPage } from '@backstage/plugin-apache-airflow';
|
||||
import { PermissionedRoute } from '@backstage/plugin-permission-react';
|
||||
import { AnyPluginOptions } from '@backstage/core-plugin-api';
|
||||
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
|
||||
|
||||
const app = createApp({
|
||||
@@ -138,10 +139,11 @@ const app = createApp({
|
||||
const AppProvider = app.getProvider();
|
||||
const AppRouter = app.getRouter();
|
||||
|
||||
catalogPlugin.reconfigure({
|
||||
// TODO: remove it, only for testing here
|
||||
createButtonTitle: 'Maybe Create Component',
|
||||
});
|
||||
// TODO: remove it, only for testing here
|
||||
catalogPlugin.reconfigure((options: AnyPluginOptions) => ({
|
||||
...options,
|
||||
createButtonTitle: 'Maybe Create',
|
||||
}));
|
||||
|
||||
const routes = (
|
||||
<FlatRoutes>
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
|
||||
import React, { lazy, Suspense } from 'react';
|
||||
import { AnalyticsContext } from '../analytics/AnalyticsContext';
|
||||
import { AnalyticsContext } from '../analytics';
|
||||
import { useApp } from '../app';
|
||||
import { RouteRef, useRouteRef } from '../routing';
|
||||
import { attachComponentData } from './componentData';
|
||||
import { Extension, BackstagePlugin } from '../plugin/types';
|
||||
import { Extension, BackstagePlugin } from '../plugin';
|
||||
import { PluginErrorBoundary } from './PluginErrorBoundary';
|
||||
import { PluginOptionsProvider } from '../plugin-options';
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
AnyExternalRoutes,
|
||||
AnyPluginOptions,
|
||||
PluginFeatureFlagConfig,
|
||||
ReconfigureFunction,
|
||||
} from './types';
|
||||
import { AnyApiFactory } from '../apis';
|
||||
|
||||
@@ -66,8 +67,10 @@ export class PluginImpl<
|
||||
return extension.expose(this);
|
||||
}
|
||||
|
||||
reconfigure(pluginOptions: PluginOptions): void {
|
||||
this.config.options = pluginOptions;
|
||||
reconfigure(fn: ReconfigureFunction): void {
|
||||
if (this.config.options) {
|
||||
this.config.options = fn(this.config.options) as PluginOptions;
|
||||
}
|
||||
}
|
||||
|
||||
getPluginOptions(): PluginOptions {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { RouteRef, SubRouteRef, ExternalRouteRef } from '../routing';
|
||||
import { AnyApiFactory } from '../apis/system';
|
||||
import { AnyApiFactory } from '../apis';
|
||||
|
||||
/**
|
||||
* Plugin extension type.
|
||||
@@ -51,6 +51,10 @@ export type AnyExternalRoutes = { [name: string]: ExternalRouteRef };
|
||||
*/
|
||||
export type AnyPluginOptions = { [name: string]: any };
|
||||
|
||||
export type ReconfigureFunction = (
|
||||
options: AnyPluginOptions,
|
||||
) => AnyPluginOptions;
|
||||
|
||||
/**
|
||||
* Plugin type.
|
||||
*
|
||||
@@ -69,7 +73,7 @@ export type BackstagePlugin<
|
||||
getFeatureFlags(): Iterable<PluginFeatureFlagConfig>;
|
||||
provide<T>(extension: Extension<T>): T;
|
||||
getPluginOptions(): PluginOptions;
|
||||
reconfigure(pluginOptions: PluginOptions): void;
|
||||
reconfigure(fn: ReconfigureFunction): void;
|
||||
routes: Routes;
|
||||
externalRoutes: ExternalRoutes;
|
||||
};
|
||||
@@ -100,14 +104,6 @@ export type PluginConfig<
|
||||
externalRoutes?: ExternalRoutes;
|
||||
featureFlags?: PluginFeatureFlagConfig[];
|
||||
options?: PluginOptions;
|
||||
/**
|
||||
* TODO: Not clear yet does it make sense to do it as a function.
|
||||
* As for me it makes more sense to provide it as an object with default values.
|
||||
* And keep only reconfigure as a function to update default values.
|
||||
* Otherwise it looks like we have 2 places where it is possible to override default values.
|
||||
* @param inputOptions
|
||||
*/
|
||||
pluginOptions(inputOptions: AnyPluginOptions): PluginOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { createComponentRouteRef, viewTechDocRouteRef } from './routes';
|
||||
import {
|
||||
AnyPluginOptions,
|
||||
createApiFactory,
|
||||
createComponentExtension,
|
||||
createPlugin,
|
||||
@@ -73,10 +72,9 @@ export const catalogPlugin = createPlugin({
|
||||
createComponent: createComponentRouteRef,
|
||||
viewTechDoc: viewTechDocRouteRef,
|
||||
},
|
||||
pluginOptions: (inputOptions: AnyPluginOptions) => ({
|
||||
// TODO: remove it, only for testing here
|
||||
createButtonTitle: inputOptions.createButtonTitle || 'Create',
|
||||
}),
|
||||
options: {
|
||||
createButtonTitle: 'Create',
|
||||
},
|
||||
});
|
||||
|
||||
/** @public */
|
||||
|
||||
Reference in New Issue
Block a user