From 4bf796eef9af531633557592bc9258defa30eebd Mon Sep 17 00:00:00 2001 From: sumit_chaturvedi Date: Tue, 12 Aug 2025 10:56:00 +0530 Subject: [PATCH] chore(ui): update connection filter labels to connected/disconnected --- ui/components/filters/data-filters.ts | 6 +++ .../ui/custom/custom-dropdown-filter.tsx | 47 ++++++++++++------- ui/types/filters.ts | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/ui/components/filters/data-filters.ts b/ui/components/filters/data-filters.ts index 489e23bb54..ffbd8c1cf9 100644 --- a/ui/components/filters/data-filters.ts +++ b/ui/components/filters/data-filters.ts @@ -6,6 +6,12 @@ export const filterProviders = [ key: "connected", labelCheckboxGroup: "Connection", values: ["false", "true"], + valueLabelMapping: [ + { + false: { label: "Disconnected" }, + true: { label: "Connected" }, + }, + ], }, { key: "provider__in", diff --git a/ui/components/ui/custom/custom-dropdown-filter.tsx b/ui/components/ui/custom/custom-dropdown-filter.tsx index 30bfea3a29..79dab3e405 100644 --- a/ui/components/ui/custom/custom-dropdown-filter.tsx +++ b/ui/components/ui/custom/custom-dropdown-filter.tsx @@ -196,6 +196,8 @@ export const CustomDropdownFilter = ({ (entity as ScanEntity).providerInfo?.uid || value ); + } else if ("label" in entity) { + return entity.label; } else { return ( (entity as ProviderEntity).alias || @@ -207,6 +209,32 @@ export const CustomDropdownFilter = ({ [filter.valueLabelMapping], ); + const renderEntity = (entity: FilterEntity | undefined, value: string) => { + if (!entity) return value; + + if (isScanEntity(entity as ScanEntity)) { + return ; + } + + const maybeProvider = entity as ProviderEntity; + if ("provider" in maybeProvider) { + return ( + + ); + } + + if ("label" in entity) { + return {entity.label}; + } + + return value; + }; + return (
- {entity ? ( - isScanEntity(entity as ScanEntity) ? ( - - ) : ( - - ) - ) : ( - value - )} + {renderEntity(entity, value)} ); })} diff --git a/ui/types/filters.ts b/ui/types/filters.ts index 911a67651c..98de404fa3 100644 --- a/ui/types/filters.ts +++ b/ui/types/filters.ts @@ -1,7 +1,7 @@ import { ProviderEntity } from "./providers"; import { ScanEntity } from "./scans"; -export type FilterEntity = ProviderEntity | ScanEntity; +export type FilterEntity = ProviderEntity | ScanEntity | { label: string }; export interface FilterOption { key: string;