diff --git a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx index ca438b75ac..074c3a64bd 100644 --- a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx +++ b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx @@ -28,9 +28,9 @@ import { MockConfigProvider, MockFilterProvider, MockScrollProvider, + MockPluginProvider, } from '../../testUtils'; import { CostInsightsThemeProvider } from '../CostInsightsPage/CostInsightsThemeProvider'; -import { createPlugin, PluginProvider } from '@backstage/core-plugin-api'; const mockGroupDailyCost: Cost = { id: 'test-group', @@ -39,21 +39,6 @@ const mockGroupDailyCost: Cost = { trendline: trendlineOf(MockAggregatedDailyCosts), }; -type TestInputPluginOptions = { - showTrendLine: boolean; -}; - -type TestPluginOptions = { - showTrendLine: boolean; -}; - -const plugin = createPlugin({ - id: 'my-plugin', - __experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions { - return { showTrendLine: false }; - }, -}); - function renderInContext(children: JSX.Element) { return renderInTestApp( @@ -61,7 +46,7 @@ function renderInContext(children: JSX.Element) { - {children} + {children} diff --git a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx index 687f9bdd39..f91fe472c6 100644 --- a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx +++ b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewChart.tsx @@ -133,7 +133,7 @@ export const CostOverviewChart = ({ ); }; - const { showTrendLine } = useCostInsightsOptions(); + const { hideTrendLine } = useCostInsightsOptions(); return ( @@ -180,7 +180,7 @@ export const CostOverviewChart = ({ stroke="none" yAxisId={data.dailyCost.dataKey} /> - {showTrendLine && ( + {!hideTrendLine && ( @@ -81,7 +66,9 @@ function renderInContext(children: JSX.Element) { - {children} + + {children} + diff --git a/plugins/cost-insights/src/options.ts b/plugins/cost-insights/src/options.ts index 820bea7654..287935d703 100644 --- a/plugins/cost-insights/src/options.ts +++ b/plugins/cost-insights/src/options.ts @@ -17,12 +17,12 @@ import { usePluginOptions } from '@backstage/core-plugin-api'; export type CostInsightsPluginOptions = { - showTrendLine: boolean; + hideTrendLine?: boolean; }; /** @ignore */ export type CostInsightsInputPluginOptions = { - showTrendLine: boolean; + hideTrendLine?: boolean; }; export const useCostInsightsOptions = () => diff --git a/plugins/cost-insights/src/plugin.ts b/plugins/cost-insights/src/plugin.ts index 1d776660ce..c863c9e03a 100644 --- a/plugins/cost-insights/src/plugin.ts +++ b/plugins/cost-insights/src/plugin.ts @@ -49,7 +49,7 @@ export const costInsightsPlugin = createPlugin({ options?: CostInsightsInputPluginOptions, ): CostInsightsPluginOptions { const defaultOptions = { - showTrendLine: true, + hideTrendLine: false, }; return { ...defaultOptions, ...options }; }, diff --git a/plugins/cost-insights/src/testUtils/providers.tsx b/plugins/cost-insights/src/testUtils/providers.tsx index 8088fca3c6..f8d23dda3c 100644 --- a/plugins/cost-insights/src/testUtils/providers.tsx +++ b/plugins/cost-insights/src/testUtils/providers.tsx @@ -26,6 +26,7 @@ import { } from '../hooks/useLastCompleteBillingDate'; import { ScrollContext, ScrollContextProps } from '../hooks/useScroll'; import { Group, Duration } from '../types'; +import { createPlugin, PluginProvider } from '@backstage/core-plugin-api'; export const MockGroups: Group[] = [{ id: 'tech' }, { id: 'mock-group' }]; @@ -144,6 +145,19 @@ export const MockBillingDateProvider = ({ export type MockScrollProviderProps = PropsWithChildren<{}>; +export const MockPluginProvider = ({ children }: PropsWithChildren<{}>) => { + type TestInputPluginOptions = {}; + type TestPluginOptions = {}; + const plugin = createPlugin({ + id: 'my-plugin', + __experimentalConfigure(_: TestInputPluginOptions): TestPluginOptions { + return {}; + }, + }); + + return {children}; +}; + export const MockScrollProvider = ({ children }: MockScrollProviderProps) => { const defaultContext: ScrollContextProps = { scroll: null,