From 21a3d3dcac11906600ff5730f05368fc50865c5c Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 2 Dec 2020 18:31:59 +0100 Subject: [PATCH] cost-insights: refactor plugin creation to call createPlugin directly Co-authored-by: blam --- plugins/cost-insights/dev/index.tsx | 23 +++++++++-------------- plugins/cost-insights/src/plugin.ts | 8 +++----- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/plugins/cost-insights/dev/index.tsx b/plugins/cost-insights/dev/index.tsx index fe208d5bb8..bdbb4450fa 100644 --- a/plugins/cost-insights/dev/index.tsx +++ b/plugins/cost-insights/dev/index.tsx @@ -14,20 +14,15 @@ * limitations under the License. */ import { createDevApp } from '@backstage/dev-utils'; -import { createPlugin, createApiFactory } from '@backstage/core'; import { costInsightsApiRef } from '../src/api'; import { ExampleCostInsightsClient } from '../src/client'; -import { pluginConfig } from '../src/plugin'; +import { plugin } from '../src/plugin'; -const devPlugin = createPlugin({ - ...pluginConfig, - apis: [ - createApiFactory({ - api: costInsightsApiRef, - deps: {}, - factory: () => new ExampleCostInsightsClient(), - }), - ], -}); - -createDevApp().registerPlugin(devPlugin).render(); +createDevApp() + .registerPlugin(plugin) + .registerApi({ + api: costInsightsApiRef, + deps: {}, + factory: () => new ExampleCostInsightsClient(), + }) + .render(); diff --git a/plugins/cost-insights/src/plugin.ts b/plugins/cost-insights/src/plugin.ts index 58465f6711..7006d5bf5d 100644 --- a/plugins/cost-insights/src/plugin.ts +++ b/plugins/cost-insights/src/plugin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { createPlugin, createRouteRef, PluginConfig } from '@backstage/core'; +import { createPlugin, createRouteRef } from '@backstage/core'; import { CostInsightsPage } from './components/CostInsightsPage'; import { ProjectGrowthInstructionsPage } from './components/ProjectGrowthInstructionsPage'; import { LabelDataflowInstructionsPage } from './components/LabelDataflowInstructionsPage'; @@ -34,7 +34,7 @@ export const unlabeledDataflowAlertRef = createRouteRef({ title: 'Labeling Dataflow Jobs', }); -export const pluginConfig: PluginConfig = { +export const plugin = createPlugin({ id: 'cost-insights', register({ router, featureFlags }) { router.addRoute(rootRouteRef, CostInsightsPage); @@ -42,6 +42,4 @@ export const pluginConfig: PluginConfig = { router.addRoute(unlabeledDataflowAlertRef, LabelDataflowInstructionsPage); featureFlags.register('cost-insights-currencies'); }, -}; - -export const plugin = createPlugin(pluginConfig); +});