Repository navigation
Commit a710e8c
Scope the topology filter sidebar to the selected namespaces (#1686)
Closes #1647.
`TopologyFilterSidebar` was passed `topology?.nodes` — the raw,
cluster-wide, unbuffered node list — while the graph rendered
`filteredTopology`. With a namespace selected, the sidebar's kind rows
and counts therefore described the whole cluster rather than the canvas
(the `Ingress (12)` case in the issue), and because it read `topology`
rather than `displayedTopology`, its counts kept moving while the graph
was paused.
## Change
The sidebar now receives a **namespace-scoped** set derived from
`displayedTopology`.
Scoping is namespace-only, deliberately. `TopologyFilterSidebar` builds
`availableKinds` from `kindCounts` over its `nodes` prop and computes
the footer's visible/hidden totals by intersecting that with
`visibleKinds` (`TopologyFilterSidebar.tsx:150-170`, `:400-415`).
Handing it the already kind-filtered graph nodes would drop every hidden
kind out of the list instead of showing it with a count, and `hidden`
would always read zero — which is what the issue warns about.
The namespace carve-out is now a single shared helper
(`web/src/utils/topology-namespace.ts`) used by **both** the graph's
`filteredTopology` and the sidebar, so the two cannot drift apart again
— that is the acceptance criterion stated as code rather than as a
convention. Nodes with no namespace are cluster-scoped (`Node`,
`PersistentVolume`, `Namespace`) and stay visible in every scope,
matching the existing behaviour.
`hiddenKinds` is read from `displayedTopology` for the same pause
semantics.
## Acceptance criteria
| criterion | how it is met |
| --- | --- |
| Count and list kinds from the namespace-filtered node set |
`filterSidebarNodes` = `scopeNodesToNamespaces(displayedTopology.nodes,
namespaces)` |
| Retain cluster-scoped nodes with no namespace | `isInNamespaceScope`
returns `true` when `data.namespace` is absent or empty |
| Use the pause-buffered `displayedTopology` | the memo reads
`displayedTopology`, not `topology` |
| Do **not** pass the kind-filtered graph nodes | the helper applies the
namespace carve-out only; kind filtering stays in `filteredTopology` |
## Verification
- `npm run tsc` (typescript-7, `--noEmit`) — clean
- `npm run lint` — **0 errors** (351 pre-existing warnings, unchanged)
- `npx vitest run src` — **914 passed**, including 9 new tests in
`web/src/utils/topology-namespace.test.ts`
Two tests in `src/api/client.authRedirect.test.ts` fail, but they are
**pre-existing and flaky**, unrelated to this change: on a clean stash
of this branch that file alone still reports `1 failed | 5 passed`, and
across runs it reports 1 or 2 failures on the same untouched code.
I could not exercise this against a live cluster, so the namespace
behaviour is covered by unit tests on the extracted helper rather than
end to end.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> UI-only topology filtering refactor with extracted helpers and tests;
no auth, API, or data-path changes.
>
> **Overview**
> **Aligns the topology filter sidebar with the namespace-scoped graph**
so kind rows and counts match what you see on the canvas when namespaces
are selected, instead of reflecting the full cluster.
>
> Adds shared helpers in `topology-namespace.ts` (`isInNamespaceScope`,
`scopeNodesToNamespaces`) used by both the graph’s `filteredTopology`
and a new `filterSidebarNodes` memo. Sidebar nodes are
**namespace-scoped only** (from pause-buffered `displayedTopology`), not
kind-filtered, so hidden kinds still appear in the list with correct
visible/hidden footer counts. `hiddenKinds` now comes from
`displayedTopology` so it stays stable while the graph is paused.
>
> Unit tests cover namespace scoping and cluster-scoped nodes (no/empty
namespace).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4915b72. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Nadav Erell <nadaverell@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 0e3dc48 commit a710e8c
3 files changed
Lines changed: 96 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
1604 | 1605 | | |
1605 | 1606 | | |
1606 | 1607 | | |
1607 | | - | |
1608 | | - | |
| 1608 | + | |
1609 | 1609 | | |
1610 | 1610 | | |
1611 | 1611 | | |
| |||
1630 | 1630 | | |
1631 | 1631 | | |
1632 | 1632 | | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
1633 | 1643 | | |
1634 | 1644 | | |
1635 | 1645 | | |
| |||
2182 | 2192 | | |
2183 | 2193 | | |
2184 | 2194 | | |
2185 | | - | |
| 2195 | + | |
2186 | 2196 | | |
2187 | 2197 | | |
2188 | 2198 | | |
2189 | 2199 | | |
2190 | 2200 | | |
2191 | 2201 | | |
2192 | | - | |
| 2202 | + | |
2193 | 2203 | | |
2194 | 2204 | | |
2195 | 2205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments