1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-04-20 23:08:29 +00:00
thatmattlove-hyperglass/hyperglass/ui/components/output/cell.tsx
Wilhelm Schonfeldt 4414d2ec03 fix(ui): improve BGP table field display formatting
- Fix MED field showing N/A when value is 0 (now correctly shows 0)
- Hide Originator field when empty instead of showing N/A
- Hide Age field when not available instead of showing N/A
- Add HideableField component for fields that should be hidden when empty
- Update string output formatting to skip hidden fields in text export

Resolves display issues where valid zero values and unavailable fields
were showing as N/A instead of proper formatting or being hidden.
2025-09-26 13:30:44 +02:00

29 lines
1.1 KiB
TypeScript

import { MonoField, Active, Weight, Age, Communities, RPKIState, ASPath, HideableField } from './fields';
import type { CellRenderProps } from '~/types';
interface CellProps {
data: CellRenderProps;
rawData: StructuredResponse;
}
export const Cell = (props: CellProps): JSX.Element => {
const { data, rawData } = props;
const cellId = data.column.id as keyof Route;
const component = {
med: <MonoField v={data.value} />,
age: <Age inSeconds={data.value} />,
prefix: <MonoField v={data.value} />,
next_hop: <MonoField v={data.value} />,
peer_rid: <MonoField v={data.value} />,
source_as: <MonoField v={data.value} />,
active: <Active isActive={data.value} />,
source_rid: <HideableField v={data.value} />,
local_preference: <MonoField v={data.value} />,
communities: <Communities communities={data.value} />,
as_path: <ASPath path={data.value} active={data.row.values.active} />,
rpki_state: <RPKIState state={data.value} active={data.row.values.active} />,
weight: <Weight weight={data.value} winningWeight={rawData.winning_weight} />,
};
return component[cellId] ?? '';
};