Skip to content

Commit c4e2089

Browse files
committed
feat(table): display and dim filtered BGP routes
Add a 'filtered' flag to the BGP route model and a 'filtered' theme color, and dim filtered rows in the results table (row + cell text colour). This provides the rendering capability; platform parsers set route.filtered when a route is present but not selected/active (e.g. MikroTik filtered routes). Stacked series (5/10): builds on pr/huawei-structured-bgp.
1 parent d1104f8 commit c4e2089

7 files changed

Lines changed: 18 additions & 2 deletions

File tree

docs/pages/configuration/config/web-ui.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ hyperglass allows you to customize the colors and fonts used in the Web UI.
243243
| `web.theme.colors.dark` | <Color hex="#010101"/> |
244244
| `web.theme.colors.light` | <Color hex="#f5f6f7"/> |
245245
| `web.theme.colors.gray` | <Color hex="#c1c7cc"/> |
246+
| `web.theme.colors.filtered` | <Color hex="#c1c7cc"/> |
246247
| `web.theme.colors.red` | <Color hex="#d84b4b"/> |
247248
| `web.theme.colors.orange` | <Color hex="#ff6b35"/> |
248249
| `web.theme.colors.yellow` | <Color hex="#edae49"/> |
@@ -253,6 +254,8 @@ hyperglass allows you to customize the colors and fonts used in the Web UI.
253254
| `web.theme.colors.pink` | <Color hex="#f2607d"/> |
254255
| `web.theme.colors.purple` | <Color hex="#8d30b5"/> |
255256

257+
The `filtered` color is used to dim BGP routes that are present but not selected/active in the structured table (for example, MikroTik routes flagged filtered, disabled, or unreachable). It defaults to the same value as `gray`.
258+
256259
##### Functional Colors
257260

258261
| Parameter | Default Value |

hyperglass/models/config/web.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class ThemeColors(HyperglassModel):
137137
dark: Color = "#010101"
138138
light: Color = "#f5f6f7"
139139
gray: Color = "#c1c7cc"
140+
filtered: Color = "#c1c7cc"
140141
red: Color = "#d84b4b"
141142
orange: Color = "#ff6b35"
142143
yellow: Color = "#edae49"

hyperglass/models/data/bgp_route.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class BGPRoute(HyperglassModel):
3434
source_rid: str
3535
peer_rid: str
3636
rpki_state: int
37+
filtered: bool = False
3738

3839
@field_validator("communities")
3940
def validate_communities(cls, value):

hyperglass/ui/components/table/cell.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import type { BoxProps } from '@chakra-ui/react';
66
interface TableCellProps extends Omit<BoxProps, 'align'> {
77
bordersVertical?: [boolean, number];
88
align?: 'left' | 'right' | 'center';
9+
dimText?: boolean;
910
}
1011

1112
export const TableCell = (props: TableCellProps): JSX.Element => {
12-
const { bordersVertical = [false, 0], align, ...rest } = props;
13+
const { bordersVertical = [false, 0], align, dimText = false, ...rest } = props;
1314
const [doVerticalBorders, index] = bordersVertical;
1415
const borderLeftColor = useColorValue('blackAlpha.100', 'whiteAlpha.100');
16+
const filteredTextColor = useColorValue('filtered.400', 'filtered.500');
1517

1618
let borderProps = {};
1719
if (doVerticalBorders && index !== 0) {
@@ -25,6 +27,7 @@ export const TableCell = (props: TableCellProps): JSX.Element => {
2527
w="1%"
2628
textAlign={align}
2729
whiteSpace="nowrap"
30+
color={dimText ? filteredTextColor : undefined}
2831
{...borderProps}
2932
{...rest}
3033
/>

hyperglass/ui/components/table/main.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ export const Table = (props: TableProps): JSX.Element => {
122122
<TableBody>
123123
{page.map((row, key) => {
124124
prepareRow(row);
125+
const dimText = row.original.filtered;
125126
return (
126127
<TableRow
127128
index={key}
128129
doStripe={striped}
129130
highlightBg={rowHighlightBg}
130131
doHorizontalBorders={bordersHorizontal}
131132
highlight={row.values[rowHighlightProp ?? ''] ?? false}
133+
dimText={dimText}
132134
{...row.getRowProps()}
133135
>
134136
{row.cells.map((cell, i) => {
@@ -137,6 +139,7 @@ export const Table = (props: TableProps): JSX.Element => {
137139
<TableCell
138140
align={cell.column.align}
139141
bordersVertical={[bordersVertical, i]}
142+
dimText={dimText}
140143
{...cell.getCellProps()}
141144
>
142145
{typeof Cell !== 'undefined' ? (

hyperglass/ui/components/table/row.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface TableRowProps extends BoxProps {
88
highlightBg?: Theme.ColorNames;
99
doHorizontalBorders?: boolean;
1010
highlight?: boolean;
11+
dimText?: boolean;
1112
doStripe?: boolean;
1213
index: number;
1314
}
@@ -19,6 +20,7 @@ export const TableRow = (props: TableRowProps): JSX.Element => {
1920
highlight = false,
2021
highlightBg = 'primary',
2122
doHorizontalBorders = false,
23+
dimText = false,
2224
...rest
2325
} = props;
2426

@@ -40,12 +42,14 @@ export const TableRow = (props: TableRowProps): JSX.Element => {
4042
}
4143
const defaultBg = useColorValue('white', 'black');
4244
const color = useOpposingColor(bg ?? defaultBg);
45+
const filteredTextColor = useColorValue('filtered.400', 'filtered.500');
46+
const rowTextColor = dimText ? filteredTextColor : color;
4347
const borderProps = doHorizontalBorders && index !== 0 ? rowBorder : {};
4448

4549
return (
4650
<chakra.tr
4751
bg={bg}
48-
css={{ '& > td': { color } }}
52+
css={{ '& > td': { color: rowTextColor } }}
4953
fontWeight={highlight ? 'bold' : undefined}
5054
_hover={{
5155
cursor: 'pointer',

hyperglass/ui/types/globals.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export declare global {
3030
source_rid: string;
3131
peer_rid: string;
3232
rpki_state: RPKIState;
33+
filtered: boolean;
3334
};
3435

3536
type RouteField = { [K in keyof Route]: Route[K] };

0 commit comments

Comments
 (0)