Skip to content

Commit

Permalink
Omit AWS details page filters from available EC2 filters
Browse files Browse the repository at this point in the history
  • Loading branch information
dlabrecq committed Sep 4, 2024
1 parent f899cc1 commit 62f7ba5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/routes/details/awsBreakdown/instances/instances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions src/routes/utils/groupBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 62f7ba5

Please sign in to comment.