merge
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
'example-app': patch
|
||||
'@backstage/core-api': patch
|
||||
'@backstage/plugin-cost-insights': patch
|
||||
---
|
||||
|
||||
Remove cost insights example client from demo app and export from plugin
|
||||
Create cost insights dev plugin using example client
|
||||
Make PluginConfig and dependent types public
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
registry "https://registry.npmjs.org/"
|
||||
disable-self-update-check true
|
||||
lastUpdateCheck 1580389148099
|
||||
yarn-path ".yarn/releases/yarn-1.22.1.js"
|
||||
network-timeout 600000
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
"@roadiehq/backstage-plugin-github-insights": "^0.2.7",
|
||||
"@roadiehq/backstage-plugin-github-pull-requests": "^0.5.2",
|
||||
"@roadiehq/backstage-plugin-travis-ci": "^0.2.5",
|
||||
"dayjs": "^1.9.1",
|
||||
"history": "^5.0.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "^16.12.0",
|
||||
@@ -46,7 +45,6 @@
|
||||
"react-router": "6.0.0-beta.0",
|
||||
"react-router-dom": "6.0.0-beta.0",
|
||||
"react-use": "^15.3.3",
|
||||
"regression": "^2.0.1",
|
||||
"zen-observable": "^0.8.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -58,7 +56,6 @@
|
||||
"@types/jquery": "^3.3.34",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/regression": "^2.0.0",
|
||||
"@types/zen-observable": "^0.8.0",
|
||||
"cross-env": "^7.0.0",
|
||||
"cypress": "^4.2.0",
|
||||
|
||||
@@ -25,8 +25,10 @@ import {
|
||||
GraphQLEndpoints,
|
||||
} from '@backstage/plugin-graphiql';
|
||||
|
||||
import { costInsightsApiRef } from '@backstage/plugin-cost-insights';
|
||||
import { ExampleCostInsightsClient } from './plugins/cost-insights';
|
||||
import {
|
||||
costInsightsApiRef,
|
||||
ExampleCostInsightsClient,
|
||||
} from '@backstage/plugin-cost-insights';
|
||||
|
||||
export const apis = [
|
||||
createApiFactory({
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { ExampleCostInsightsClient } from './ExampleCostInsightsClient';
|
||||
@@ -14,50 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentType } from 'react';
|
||||
import {
|
||||
PluginOutput,
|
||||
RoutePath,
|
||||
RouteOptions,
|
||||
FeatureFlagName,
|
||||
BackstagePlugin,
|
||||
} from './types';
|
||||
import { PluginConfig, PluginOutput, BackstagePlugin } from './types';
|
||||
import { validateBrowserCompat, validateFlagName } from '../app/FeatureFlags';
|
||||
import { RouteRef } from '../routing';
|
||||
import { AnyApiFactory } from '../apis';
|
||||
|
||||
export type PluginConfig = {
|
||||
id: string;
|
||||
apis?: Iterable<AnyApiFactory>;
|
||||
register?(hooks: PluginHooks): void;
|
||||
};
|
||||
|
||||
export type PluginHooks = {
|
||||
router: RouterHooks;
|
||||
featureFlags: FeatureFlagsHooks;
|
||||
};
|
||||
|
||||
export type RouterHooks = {
|
||||
addRoute(
|
||||
target: RouteRef,
|
||||
Component: ComponentType<any>,
|
||||
options?: RouteOptions,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* @deprecated See the `addRoute` method
|
||||
*/
|
||||
registerRoute(
|
||||
path: RoutePath,
|
||||
Component: ComponentType<any>,
|
||||
options?: RouteOptions,
|
||||
): void;
|
||||
};
|
||||
|
||||
export type FeatureFlagsHooks = {
|
||||
register(name: FeatureFlagName): void;
|
||||
};
|
||||
|
||||
export class PluginImpl {
|
||||
private storedOutput?: PluginOutput[];
|
||||
|
||||
|
||||
@@ -73,3 +73,35 @@ export type BackstagePlugin = {
|
||||
output(): PluginOutput[];
|
||||
getApis(): Iterable<AnyApiFactory>;
|
||||
};
|
||||
|
||||
export type PluginConfig = {
|
||||
id: string;
|
||||
apis?: Iterable<AnyApiFactory>;
|
||||
register?(hooks: PluginHooks): void;
|
||||
};
|
||||
|
||||
export type PluginHooks = {
|
||||
router: RouterHooks;
|
||||
featureFlags: FeatureFlagsHooks;
|
||||
};
|
||||
|
||||
export type RouterHooks = {
|
||||
addRoute(
|
||||
target: RouteRef,
|
||||
Component: ComponentType<any>,
|
||||
options?: RouteOptions,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* @deprecated See the `addRoute` method
|
||||
*/
|
||||
registerRoute(
|
||||
path: RoutePath,
|
||||
Component: ComponentType<any>,
|
||||
options?: RouteOptions,
|
||||
): void;
|
||||
};
|
||||
|
||||
export type FeatureFlagsHooks = {
|
||||
register(name: FeatureFlagName): void;
|
||||
};
|
||||
|
||||
@@ -13,8 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { plugin } from '../src/plugin';
|
||||
import { createPlugin, createApiFactory } from '@backstage/core';
|
||||
import { ExampleCostInsightsClient } from '../src/api';
|
||||
import { costInsightsApiRef } from '../src';
|
||||
import { pluginConfig } from '../src/plugin';
|
||||
|
||||
createDevApp().registerPlugin(plugin).render();
|
||||
const devPlugin = createPlugin({
|
||||
...pluginConfig,
|
||||
apis: [
|
||||
createApiFactory({
|
||||
api: costInsightsApiRef,
|
||||
deps: {},
|
||||
factory: () => new ExampleCostInsightsClient(),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
createDevApp().registerPlugin(devPlugin).render();
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"@types/recharts": "^1.8.14",
|
||||
"canvas": "^2.6.1",
|
||||
"classnames": "^2.2.6",
|
||||
"dayjs": "^1.9.4",
|
||||
"history": "^5.0.0",
|
||||
"moment": "^2.27.0",
|
||||
"qs": "^6.9.4",
|
||||
@@ -41,6 +42,7 @@
|
||||
"react-router-dom": "6.0.0-beta.0",
|
||||
"react-use": "^15.3.3",
|
||||
"recharts": "^1.8.5",
|
||||
"regression": "^2.0.1",
|
||||
"yup": "^0.29.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -53,6 +55,7 @@
|
||||
"@types/jest": "^26.0.7",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/recharts": "^1.8.14",
|
||||
"@types/regression": "^2.0.0",
|
||||
"@types/yup": "^0.29.8",
|
||||
"cross-fetch": "^3.0.6",
|
||||
"msw": "^0.21.2"
|
||||
|
||||
+2
-2
@@ -17,11 +17,11 @@
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import regression, { DataPoint } from 'regression';
|
||||
import { CostInsightsApi } from './CostInsightsApi';
|
||||
import {
|
||||
Alert,
|
||||
ChangeStatistic,
|
||||
Cost,
|
||||
CostInsightsApi,
|
||||
DateAggregation,
|
||||
DEFAULT_DATE_FORMAT,
|
||||
Duration,
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
Trendline,
|
||||
UnlabeledDataflowAlert,
|
||||
UnlabeledDataflowData,
|
||||
} from '@backstage/plugin-cost-insights';
|
||||
} from '../types';
|
||||
|
||||
type IntervalFields = {
|
||||
duration: Duration;
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
|
||||
export * from './CostInsightsApi';
|
||||
export * from './ExampleCostInsightsClient';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createPlugin, createRouteRef } from '@backstage/core';
|
||||
import { createPlugin, createRouteRef, PluginConfig } 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 plugin = createPlugin({
|
||||
export const pluginConfig: PluginConfig = {
|
||||
id: 'cost-insights',
|
||||
register({ router, featureFlags }) {
|
||||
router.addRoute(rootRouteRef, CostInsightsPage);
|
||||
@@ -42,4 +42,6 @@ export const plugin = createPlugin({
|
||||
router.addRoute(unlabeledDataflowAlertRef, LabelDataflowInstructionsPage);
|
||||
featureFlags.register('cost-insights-currencies');
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const plugin = createPlugin(pluginConfig);
|
||||
|
||||
@@ -9797,10 +9797,10 @@ dateformat@^3.0.0:
|
||||
resolved "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
|
||||
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
|
||||
|
||||
dayjs@^1.9.1:
|
||||
version "1.9.3"
|
||||
resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.9.3.tgz#b7f94b22ad2a136a4ca02a01ab68ae893fe1a268"
|
||||
integrity sha512-V+1SyIvkS+HmNbN1G7A9+ERbFTV9KTXu6Oor98v2xHmzzpp52OIJhQuJSTywWuBY5pyAEmlwbCi1Me87n/SLOw==
|
||||
dayjs@^1.9.4:
|
||||
version "1.9.4"
|
||||
resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.9.4.tgz#fcde984e227f4296f04e7b05720adad2e1071f1b"
|
||||
integrity sha512-ABSF3alrldf7nM9sQ2U+Ln67NRwmzlLOqG7kK03kck0mw3wlSSEKv/XhKGGxUjQcS57QeiCyNdrFgtj9nWlrng==
|
||||
|
||||
de-indent@^1.0.2:
|
||||
version "1.0.2"
|
||||
|
||||
Reference in New Issue
Block a user