import { formatDistanceToNowStrict } from 'date-fns'; import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection'; import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections'; import type { GrpcConnection } from '../lib/models'; import { count } from '../lib/pluralize'; import { Dropdown } from './core/Dropdown'; import { Icon } from './core/Icon'; import { IconButton } from './core/IconButton'; import { HStack } from './core/Stacks'; interface Props { connections: GrpcConnection[]; activeConnection: GrpcConnection; onPinned: (r: GrpcConnection) => void; } export function RecentConnectionsDropdown({ activeConnection, connections, onPinned }: Props) { const deleteConnection = useDeleteGrpcConnection(activeConnection?.id ?? null); const deleteAllConnections = useDeleteGrpcConnections(activeConnection?.requestId); return ( ({ key: c.id, label: ( {formatDistanceToNowStrict(c.createdAt + 'Z')} ago •{' '} {c.elapsed}ms ), leftSlot: activeConnection?.id === c.id ? : , onSelect: () => onPinned(c), })), ]} > ); }