diff --git a/src/routes/details/awsBreakdown/instances/instances.tsx b/src/routes/details/awsBreakdown/instances/instances.tsx index 9ce52705c..355675279 100644 --- a/src/routes/details/awsBreakdown/instances/instances.tsx +++ b/src/routes/details/awsBreakdown/instances/instances.tsx @@ -20,7 +20,7 @@ import { ColumnManagementModal, initHiddenColumns } from 'routes/details/compone import { styles } from 'routes/optimizations/optimizationsBreakdown/optimizationsBreakdown.styles'; import type { ComputedReportItem } from 'routes/utils/computedReport/getComputedReportItems'; import { getUnsortedComputedReportItems } from 'routes/utils/computedReport/getComputedReportItems'; -import { getFilterByTagKey } from 'routes/utils/groupBy'; +import { getExcludeTagKey, getFilterByTagKey } from 'routes/utils/groupBy'; import * as queryUtils from 'routes/utils/query'; import type { RootState } from 'store'; import { FetchStatus } from 'store/common'; @@ -369,9 +369,10 @@ const useMapToProps = ({ currency, query }): InstancesStateProps => { }, [currency, query]); return { - hasAccountFilter: queryState?.filter_by?.[accountKey] !== undefined, - hasRegionFilter: queryState?.filter_by?.[regionKey] !== undefined, - hasTagFilter: getFilterByTagKey(queryState) !== undefined, + hasAccountFilter: + queryState?.filter_by?.[accountKey] !== undefined || queryState?.exclude?.[accountKey] !== undefined, + hasRegionFilter: queryState?.filter_by?.[regionKey] !== undefined || queryState?.exclude?.[regionKey] !== undefined, + hasTagFilter: getFilterByTagKey(queryState) !== undefined || getExcludeTagKey(queryState), report, reportError, reportFetchStatus, diff --git a/src/routes/utils/groupBy.ts b/src/routes/utils/groupBy.ts index 85d7d5672..056286b23 100644 --- a/src/routes/utils/groupBy.ts +++ b/src/routes/utils/groupBy.ts @@ -55,6 +55,21 @@ export const getGroupByTagKey = (query: Query) => { return groupByTagKey; }; +export const getExcludeTagKey = (query: Query) => { + let excludeTagKey; + + if (query?.exclude) { + for (const groupBy of Object.keys(query.exclude)) { + const tagIndex = groupBy.indexOf(tagPrefix); + if (tagIndex !== -1) { + excludeTagKey = groupBy.substring(tagIndex + tagPrefix.length) as any; + break; + } + } + } + return excludeTagKey; +}; + export const getFilterByTagKey = (query: Query) => { let filterByTagKey;