diff --git a/ui/app/peers/peersTable.tsx b/ui/app/peers/peersTable.tsx index e1819c46dc..cf64635cd0 100644 --- a/ui/app/peers/peersTable.tsx +++ b/ui/app/peers/peersTable.tsx @@ -1,7 +1,9 @@ 'use client'; import { DropDialog } from '@/components/DropDialog'; import PeerButton from '@/components/PeerComponent'; -import PeerTypeLabel, { DBTypeToGoodText } from '@/components/PeerTypeComponent'; +import PeerTypeLabel, { + DBTypeToGoodText, +} from '@/components/PeerTypeComponent'; import { DBType, Peer } from '@/grpc_generated/peers'; import { Label } from '@/lib/Label'; import { SearchField } from '@/lib/SearchField'; @@ -32,20 +34,32 @@ function PeerRow({ peer }: { peer: Peer }) { function PeersTable({ title, peers }: { title: string; peers: Peer[] }) { const [searchQuery, setSearchQuery] = useState(''); - const [filteredType, setFilteredType] = useState(undefined); + const [filteredType, setFilteredType] = useState( + undefined + ); const rows = useMemo( () => - peers.filter((peer) => { - return peer.name.toLowerCase().includes(searchQuery.toLowerCase()); - }).filter((peer) => { - return (filteredType == undefined) || (peer.type == filteredType); - }), + peers + .filter((peer) => { + return peer.name.toLowerCase().includes(searchQuery.toLowerCase()); + }) + .filter((peer) => { + return filteredType == undefined || peer.type == filteredType; + }), [peers, searchQuery, filteredType] ); - const allTypesOption: { value: DBType | undefined; label: string; } = { value: undefined, label: 'All' }; - const availableTypes: { value: DBType | undefined; label: string; }[] = [...new Set(peers.flatMap((peer) => { - return { value: peer.type, label: DBTypeToGoodText(peer.type) }; - }))]; + const allTypesOption: { value: DBType | undefined; label: string } = { + value: undefined, + label: 'All', + }; + const availableTypes: { value: DBType | undefined; label: string }[] = + Array.from( + new Map( // Map filters out duplicates + peers.flatMap((peer) => [ + [peer.type, { value: peer.type, label: DBTypeToGoodText(peer.type) }], + ]) + ).values() + ); availableTypes.unshift(allTypesOption); return ( @@ -56,14 +70,20 @@ function PeersTable({ title, peers }: { title: string; peers: Peer[] }) { right: ( <> { setFilteredType(val?.value); }} defaultValue={allTypesOption} - /> + ) => setSearchQuery(e.target.value)} /> + onChange={(e: React.ChangeEvent) => + setSearchQuery(e.target.value) + } + /> + ), }} header={ diff --git a/ui/components/PeerTypeComponent.tsx b/ui/components/PeerTypeComponent.tsx index 3346bb20c8..089c41b92d 100644 --- a/ui/components/PeerTypeComponent.tsx +++ b/ui/components/PeerTypeComponent.tsx @@ -13,7 +13,7 @@ export const DBTypeToGoodText = (ptype: DBType) => { case DBType.EVENTHUB: return 'Event Hubs'; case DBType.EVENTHUB_GROUP: - return 'Event Hubs'; + return 'Event Hubs (Group)'; case DBType.BIGQUERY: return 'BigQuery'; case DBType.S3: