From a5ecdb99f036e1a24e6565f4db23f5190cf9b119 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Wed, 16 Nov 2022 10:57:36 +0100 Subject: [PATCH] Making a possibility to hide a trending line in a cost insights plugin Signed-off-by: bnechyporenko --- .changeset/yellow-forks-knock.md | 5 ++++ plugins/cost-insights/api-report.md | 2 +- .../CostOverviewCard/CostOverviewChart.tsx | 25 +++++++++------- plugins/cost-insights/src/options.ts | 29 +++++++++++++++++++ plugins/cost-insights/src/plugin.ts | 12 ++++++++ 5 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 .changeset/yellow-forks-knock.md create mode 100644 plugins/cost-insights/src/options.ts diff --git a/.changeset/yellow-forks-knock.md b/.changeset/yellow-forks-knock.md new file mode 100644 index 0000000000..98c4b5b675 --- /dev/null +++ b/.changeset/yellow-forks-knock.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +Making a possibility to hide a trending line in a cost insights plugin diff --git a/plugins/cost-insights/api-report.md b/plugins/cost-insights/api-report.md index dd4e404450..27f7c94f21 100644 --- a/plugins/cost-insights/api-report.md +++ b/plugins/cost-insights/api-report.md @@ -316,7 +316,7 @@ const costInsightsPlugin: BackstagePlugin< unlabeledDataflowAlerts: RouteRef; }, {}, - {} + CostInsightsInputPluginOptions >; export { costInsightsPlugin }; export { costInsightsPlugin as plugin }; diff --git a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx index 1c58bf58e6..687f9bdd39 100644 --- a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx +++ b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx @@ -48,7 +48,8 @@ import { useCostOverviewStyles as useStyles } from '../../utils/styles'; import { groupByDate, toDataMax, trendFrom } from '../../utils/charts'; import { aggregationSort } from '../../utils/sort'; import { CostOverviewLegend } from './CostOverviewLegend'; -import { TooltipRenderer } from '../../types/Tooltip'; +import { TooltipRenderer } from '../../types'; +import { useCostInsightsOptions } from '../../options'; type CostOverviewChartProps = { metric: Maybe; @@ -132,6 +133,8 @@ export const CostOverviewChart = ({ ); }; + const { showTrendLine } = useCostInsightsOptions(); + return ( - + {showTrendLine && ( + + )} {metric && ( + usePluginOptions(); diff --git a/plugins/cost-insights/src/plugin.ts b/plugins/cost-insights/src/plugin.ts index 04d58d1877..1d776660ce 100644 --- a/plugins/cost-insights/src/plugin.ts +++ b/plugins/cost-insights/src/plugin.ts @@ -19,6 +19,10 @@ import { createRouteRef, createRoutableExtension, } from '@backstage/core-plugin-api'; +import { + CostInsightsInputPluginOptions, + CostInsightsPluginOptions, +} from './options'; export const rootRouteRef = createRouteRef({ id: 'cost-insights', @@ -41,6 +45,14 @@ export const costInsightsPlugin = createPlugin({ growthAlerts: projectGrowthAlertRef, unlabeledDataflowAlerts: unlabeledDataflowAlertRef, }, + __experimentalConfigure( + options?: CostInsightsInputPluginOptions, + ): CostInsightsPluginOptions { + const defaultOptions = { + showTrendLine: true, + }; + return { ...defaultOptions, ...options }; + }, }); /** @public */