From 6f362dba4da6b6f0a6864a142b0e316a42051f91 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 12 Jul 2022 11:14:52 +0200 Subject: [PATCH] Incorporated the feedback. Signed-off-by: bnechyporenko --- packages/app-defaults/src/createApp.tsx | 2 +- packages/core-app-api/api-report.md | 4 ++-- packages/core-app-api/src/app/AppManager.tsx | 12 ++++++------ packages/core-app-api/src/app/types.ts | 4 ++-- packages/core-app-api/src/plugins/collectors.ts | 7 ++----- packages/core-plugin-api/api-report.md | 6 +++--- .../core-plugin-api/src/extensions/extensions.tsx | 2 +- .../src/plugin-options/usePluginOptions.tsx | 4 ++-- packages/core-plugin-api/src/plugin/types.ts | 2 +- 9 files changed, 20 insertions(+), 23 deletions(-) diff --git a/packages/app-defaults/src/createApp.tsx b/packages/app-defaults/src/createApp.tsx index 05e048ffca..9d0c01c633 100644 --- a/packages/app-defaults/src/createApp.tsx +++ b/packages/app-defaults/src/createApp.tsx @@ -50,7 +50,7 @@ export function createApp( ...icons, ...options?.icons, }, - plugins: (options?.plugins as BackstagePlugin[]) ?? [], + plugins: (options?.plugins as BackstagePlugin[]) ?? [], themes: options?.themes ?? themes, }); } diff --git a/packages/core-app-api/api-report.md b/packages/core-app-api/api-report.md index 4792453af1..800699d179 100644 --- a/packages/core-app-api/api-report.md +++ b/packages/core-app-api/api-report.md @@ -155,7 +155,7 @@ export type AppConfigLoader = () => Promise; // @public export type AppContext = { - getPlugins(): BackstagePlugin[]; + getPlugins(): BackstagePlugin[]; getSystemIcon(key: string): IconComponent | undefined; getComponents(): AppComponents; }; @@ -254,7 +254,7 @@ export type AuthApiCreateOptions = { // @public export type BackstageApp = { - getPlugins(): BackstagePlugin[]; + getPlugins(): BackstagePlugin[]; getSystemIcon(key: string): IconComponent | undefined; getProvider(): ComponentType<{}>; getRouter(): ComponentType<{}>; diff --git a/packages/core-app-api/src/app/AppManager.tsx b/packages/core-app-api/src/app/AppManager.tsx index 130d961312..72c69f7da4 100644 --- a/packages/core-app-api/src/app/AppManager.tsx +++ b/packages/core-app-api/src/app/AppManager.tsx @@ -82,8 +82,8 @@ import { resolveRouteBindings } from './resolveRouteBindings'; import { BackstageRouteObject } from '../routing/types'; type CompatiblePlugin = - | BackstagePlugin - | (Omit, 'getFeatureFlags'> & { + | BackstagePlugin + | (Omit & { output(): Array<{ type: 'feature-flag'; name: string }>; }); @@ -145,7 +145,7 @@ function useConfigLoader( class AppContextImpl implements AppContext { constructor(private readonly app: AppManager) {} - getPlugins(): BackstagePlugin[] { + getPlugins(): BackstagePlugin[] { return this.app.getPlugins(); } @@ -186,8 +186,8 @@ export class AppManager implements BackstageApp { this.apiFactoryRegistry = new ApiFactoryRegistry(); } - getPlugins(): BackstagePlugin[] { - return Array.from(this.plugins) as BackstagePlugin[]; + getPlugins(): BackstagePlugin[] { + return Array.from(this.plugins) as BackstagePlugin[]; } getSystemIcon(key: string): IconComponent | undefined { @@ -241,7 +241,7 @@ export class AppManager implements BackstageApp { validateRouteParameters(routing.paths, routing.parents); validateRouteBindings( routeBindings, - this.plugins as Iterable>, + this.plugins as Iterable, ); } diff --git a/packages/core-app-api/src/app/types.ts b/packages/core-app-api/src/app/types.ts index e7436dbf0a..3bf2354e27 100644 --- a/packages/core-app-api/src/app/types.ts +++ b/packages/core-app-api/src/app/types.ts @@ -291,7 +291,7 @@ export type BackstageApp = { /** * Returns all plugins registered for the app. */ - getPlugins(): BackstagePlugin[]; + getPlugins(): BackstagePlugin[]; /** * Get a common or custom icon for this app. @@ -321,7 +321,7 @@ export type AppContext = { /** * Get a list of all plugins that are installed in the app. */ - getPlugins(): BackstagePlugin[]; + getPlugins(): BackstagePlugin[]; /** * Get a common or custom icon for this app. diff --git a/packages/core-app-api/src/plugins/collectors.ts b/packages/core-app-api/src/plugins/collectors.ts index 376a8b709c..41b4b00ea3 100644 --- a/packages/core-app-api/src/plugins/collectors.ts +++ b/packages/core-app-api/src/plugins/collectors.ts @@ -18,12 +18,9 @@ import { BackstagePlugin, getComponentData } from '@backstage/core-plugin-api'; import { createCollector } from '../extensions/traversal'; export const pluginCollector = createCollector( - () => new Set>(), + () => new Set(), (acc, node) => { - const plugin = getComponentData>( - node, - 'core.plugin', - ); + const plugin = getComponentData(node, 'core.plugin'); if (plugin) { acc.add(plugin); } diff --git a/packages/core-plugin-api/api-report.md b/packages/core-plugin-api/api-report.md index 7a8b0c06f3..49e0be3800 100644 --- a/packages/core-plugin-api/api-report.md +++ b/packages/core-plugin-api/api-report.md @@ -147,7 +147,7 @@ export type AppComponents = { // @public export type AppContext = { - getPlugins(): BackstagePlugin_2[]; + getPlugins(): BackstagePlugin_2[]; getSystemIcon(key: string): IconComponent_2 | undefined; getComponents(): AppComponents; }; @@ -404,7 +404,7 @@ export type ErrorBoundaryFallbackProps = { // @public export type Extension = { - expose(plugin: BackstagePlugin): T; + expose(plugin: BackstagePlugin): T; }; // @public @@ -639,7 +639,7 @@ export type PluginFeatureFlagConfig = { name: string; }; -// @public +// @alpha export interface PluginOptionsProviderProps { // (undocumented) children: ReactNode; diff --git a/packages/core-plugin-api/src/extensions/extensions.tsx b/packages/core-plugin-api/src/extensions/extensions.tsx index 1d84d55442..18b815debf 100644 --- a/packages/core-plugin-api/src/extensions/extensions.tsx +++ b/packages/core-plugin-api/src/extensions/extensions.tsx @@ -226,7 +226,7 @@ export function createReactExtension< 'Component'; return { - expose(plugin: BackstagePlugin) { + expose(plugin: BackstagePlugin) { const Result: any = (props: any) => { const app = useApp(); const { Progress } = app.getComponents(); diff --git a/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx b/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx index f5cbb72fcd..82684636d6 100644 --- a/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx +++ b/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx @@ -27,7 +27,7 @@ const contextKey: string = 'plugin-context'; /** * Properties for the PluginProvider component. * - * @public + * @alpha */ export interface PluginOptionsProviderProps { children: ReactNode; @@ -44,7 +44,7 @@ export const PluginProvider = ({ plugin, }: PluginOptionsProviderProps): JSX.Element => { const { Provider } = createVersionedContext<{ - 1: { plugin: BackstagePlugin | undefined }; + 1: { plugin: BackstagePlugin | undefined }; }>(contextKey); return ( diff --git a/packages/core-plugin-api/src/plugin/types.ts b/packages/core-plugin-api/src/plugin/types.ts index 5d5362ad07..37ce6c9e7c 100644 --- a/packages/core-plugin-api/src/plugin/types.ts +++ b/packages/core-plugin-api/src/plugin/types.ts @@ -27,7 +27,7 @@ import { AnyApiFactory } from '../apis'; * @public */ export type Extension = { - expose(plugin: BackstagePlugin): T; + expose(plugin: BackstagePlugin): T; }; /**