cost-insights: refactor plugin creation to call createPlugin directly

Co-authored-by: blam <ben@blam.sh>
This commit is contained in:
Patrik Oldsberg
2020-12-02 18:31:59 +01:00
parent d7bb7bf39b
commit 21a3d3dcac
2 changed files with 12 additions and 19 deletions
+9 -14
View File
@@ -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();
+3 -5
View File
@@ -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);
});