Repository navigation
Commit 86ae0f5
authored
Remember filters across kind and section switches (#2022)
## Description
Refs #1864.
Filters were lost when you moved around. Switching resource kinds
cleared the column and problem filters. Leaving Resources and coming
back through the nav rail opened a bare Pods list. A reload lost
everything.
**Each kind keeps its filters, per cluster**
- Each kind's column and problem filters are saved in localStorage,
keyed by API base + context, so clusters never share them. In Radar Hub
each cluster mounts with its own API base, so each cluster keeps its own
filters there too. Pods → Services → Pods brings the Pods filters back,
and so does a reload or a new tab.
- The URL stays the source of truth. A URL that carries its own list
state (`filters`, `problems`, `search`, `labels`, owner, `resource`, …)
is shown as is. Only a bare `/resources/<kind>` restores the saved
filters, and it writes them into the URL with replace.
- What gets saved is the last filters chosen for that kind, either by
the user or by a link that carries filters. A restore never saves again.
A link without filters (one resource, an owner's pods, a search) leaves
the saved filters alone. Clear filters removes them.
- Each tab keeps what it has shown, in sessionStorage: a reload or a
duplicated tab keeps the tab's own filters, while a new tab opens with
the last saved ones. Filters saved in another tab only seed a kind the
first time this tab opens it.
- Bare `/resources` and the Resources rail item go to the last kind.
This also covers Radar Hub's rail, which links to bare `/resources`.
- Sort is unchanged: it was already remembered per kind.
**Each section returns to its last list (per tab)**
- The nav rail and section shortcuts go back to the section's last list
URL. Detail sub-routes are not remembered, so the rail always lands on
the list.
- Only the params that shape each section's list are kept, from a
per-section allowlist (`viewMemory.ts`). Everything else is dropped: the
namespace pick, the investigation focus, drawers and details opened on
top of the list (e.g. an open Application). A param a view adds later is
forgotten until it is listed, never replayed by mistake.
- It is kept per tab and per cluster in sessionStorage: it survives a
reload and is copied to a duplicated tab, a new tab starts without it,
and switching context keeps each cluster's own.
**Active filters are visible**
- Clear filters is highlighted and shows a count.
- A line says when filters were restored from the last visit, with a
Clear link.
- Active filters show as removable chips above the table, as well as in
the empty state.
**"Apply to all sections"** in the Namespace column filter
- It is offered when at least one namespace is included. It replaces the
header namespace picker's selection with those namespaces and briefly
highlights the picker.
- Once the change lands, the header picker owns the namespace scope: the
Namespace column filter is cleared on every kind of that cluster, not
just the current one. Other column and problem filters stay. If the
change fails, nothing is cleared.
- It also works in Radar Hub: the pick reaches Hub's namespace chip
through `?namespaces=`. It is not offered with cache-scoped namespaces,
where the scope is locked.
**Other changes**
- A kind switch that restores filters adds one history entry instead of
two.
- The URL sync now also reads problem filters, so Back keeps them.
**Notes**
- This stores filter values in localStorage, unlike the `filter-state`
contract used by Applications, GitOps and Checks. The per-cluster key,
the URL-wins rule and the "restored" line are there so saved filters
never show up unexplained.
- New optional props on `ResourcesView`: `rememberedKindSearch`,
`onKindFiltersChange`, `onApplyNamespacesToAllSections`. Hosts that
don't pass them keep today's behavior. Radar Hub gets them through
`@skyhook-io/radar-app` with no change on its side.
## Type of change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
## How has this been tested?
- Unit tests:
- `kindFilterStore.test.ts`: per-cluster and per-group keys, tab
isolation, reload / duplicated tab / new tab, unavailable storage,
clearing one column on every kind.
- `viewMemory.test.ts`: the per-section allowlist, list-only routes,
reload per cluster, never shared with a new tab.
- `ResourcesView.kind-filter-memory.test.ts`: restore of filters,
excludes and problems.
- `ActiveFilterBar.test.tsx`.
- `make tsc`, web `npm test` and the k8s-ui suite pass.
- By hand on a remote EKS cluster:
- Pods filter → Topology → rail back to filtered Pods.
- Kind switch shows the restored line and chips.
- Reload of bare `/resources/pods` restores the filters.
- An open Application → leave → rail returns to the list, not the app.
- The Timeline view survives a rail round-trip.
- Apply to all sections sets the picker and clears a Namespace filter
saved on another kind.
- Tabs: a duplicated tab keeps the source tab's filters and section
memory; after another tab saves different filters, a reload keeps the
tab's own and a new tab gets the latest saved.
- Same flow embedded in a local Radar Hub (local `radar-app` linked into
radar-hub-web, kind cluster): Hub chip set, Namespace filter cleared on
Pods and Deployments, kept after reload.
- [ ] Tested locally with minikube/kind
- [x] Tested against a remote cluster
- [x] Added/updated unit tests
## Checklist
- [x] My code follows the project's coding standards
- [x] I have performed a self-review of my code
- [x] I have added comments where necessary
- [x] My changes generate no new warnings
- [x] Any dependent changes have been merged1 parent fa3f01f commit 86ae0f5
13 files changed
Lines changed: 936 additions & 85 deletions
File tree
- packages/k8s-ui/src/components/resources
- web/src
- components/resources
- utils
| 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 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 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 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 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 | + | |
0 commit comments