diff --git a/.changeset/wicked-games-search.md b/.changeset/wicked-games-search.md index 7fedc786b2..5264995a2d 100644 --- a/.changeset/wicked-games-search.md +++ b/.changeset/wicked-games-search.md @@ -2,4 +2,4 @@ '@backstage/plugin-cost-insights': patch --- -added an optional config entry to allow users to control the threshold value for the 'negligible' change in costs +added an optional config entry `costInsights.engineerThreshold` to allow users to control the threshold value for the 'negligible' change in costs. diff --git a/plugins/cost-insights/README.md b/plugins/cost-insights/README.md index de9e2d5596..4aee74ef0a 100644 --- a/plugins/cost-insights/README.md +++ b/plugins/cost-insights/README.md @@ -222,7 +222,7 @@ costInsights: rate: 3.5 ``` -### costChangeNegligibleThreshold (Optional; default 0.5) +### engineerThreshold (Optional; default 0.5) This threshold determines whether to show 'Negligible', or a percentage with a fraction of 'engineers' for cost savings or cost excess on top of the charts. A threshold of 0.5 means that `Negligible` is shown when the difference in costs is lower than that fraction of engineers in that time frame, diff --git a/plugins/cost-insights/config.d.ts b/plugins/cost-insights/config.d.ts index 5317485555..e2387d62bd 100644 --- a/plugins/cost-insights/config.d.ts +++ b/plugins/cost-insights/config.d.ts @@ -21,6 +21,11 @@ export interface Config { */ engineerCost: number; + /** + * @visibility frontend + */ + engineerThreshold: number; + /** * @visibility frontend */ diff --git a/plugins/cost-insights/src/hooks/useConfig.tsx b/plugins/cost-insights/src/hooks/useConfig.tsx index 92b4c6c9f7..d1b3a4788e 100644 --- a/plugins/cost-insights/src/hooks/useConfig.tsx +++ b/plugins/cost-insights/src/hooks/useConfig.tsx @@ -22,7 +22,7 @@ import React, { useState, } from 'react'; import { Config as BackstageConfig } from '@backstage/config'; -import { Currency, Icon, Metric, Product } from '../types'; +import { Currency, EngineerThreshold, Icon, Metric, Product } from '../types'; import { getIcon } from '../utils/navigation'; import { validateCurrencies, validateMetrics } from '../utils/config'; import { createCurrencyFormat, defaultCurrencies } from '../utils/currency'; @@ -84,7 +84,7 @@ const defaultState: ConfigContextProps = { products: [], icons: [], engineerCost: 0, - engineerThreshold: 0.5, + engineerThreshold: EngineerThreshold, currencies: defaultCurrencies, }; diff --git a/plugins/cost-insights/src/testUtils/providers.tsx b/plugins/cost-insights/src/testUtils/providers.tsx index 29123d974b..9522dfb702 100644 --- a/plugins/cost-insights/src/testUtils/providers.tsx +++ b/plugins/cost-insights/src/testUtils/providers.tsx @@ -31,7 +31,7 @@ import { ScrollContext, ScrollContextProps, } from '../hooks'; -import { Duration } from '../types'; +import { Duration, EngineerThreshold } from '../types'; import { createCurrencyFormat } from '../utils/currency'; export type MockFilterProviderProps = PropsWithChildren< @@ -95,7 +95,7 @@ export const MockConfigProvider = (props: MockConfigProviderProps) => { products: [], icons: [], engineerCost: 0, - engineerThreshold: 0.5, + engineerThreshold: EngineerThreshold, currencies: [], };