frontend: ResourceTable: Ignore namespace filter when disabled #7468
Welcome @dlanov! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes-sigs/headlamp'>kubernetes-sigs/headlamp</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes-sigs/headlamp has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:
A few things worth fixing before merge:
1. ResourceListView.tsx:66 vs :80 — the table's namespace-filter bypass doesn't match the header's. The header uses noNamespaceFilter={!withNamespaceFilter} (falls back to a derived default based on resourceClass.isNamespaced), but the table only gets headerProps?.noNamespaceFilter === true, dropping that derived default entirely. For any ResourceListView used without a resourceClass (the plain data+columns overload) and no explicit headerProps.noNamespaceFilter, the namespace selector ends up hidden while the table still applies the stale global namespace filter to rows — reproducing the exact bug this PR is fixing, just for a different set of callers. Suggest computing the effective value once (headerProps?.noNamespaceFilter ?? !withNamespaceFilter) and using it for both the header and the table.
2. ProjectDetails.tsx:378-390 — the Access tab's Role/RoleBinding tables have the same problem. They fetch with an explicit namespaces={project.namespaces} and render no namespace selector, but never pass noNamespaceFilter, so the global namespace filter still silently drops project-scoped rows if the global selection doesn't overlap the project's namespaces.
3. ResourceSearch.tsx:269 — advanced search's result count can disagree with the table. The "Found N results" banner is computed before namespace filtering is applied to the table, so a stale global namespace selection can hide rows the banner says were found, with no selector on the page to explain why.
4. Lower confidence: Resource.tsx:1828 — noSearch (previously purely cosmetic) now also feeds hideNamespaceFilter, giving it a real effect on which rows are shown. Today's only caller is safe, but it's an easy footgun for a future caller.
5. Design note: a caller-supplied filterFunction fully bypasses noNamespaceFilter (ResourceTable.tsx:345), so any namespace-scoped view built with a custom filter function silently keeps the old (buggy) namespace-filtering behavior.
Thanks for the review. Addressed the feedback in 053043b61:
1. ResourceListView now computes one effective noNamespaceFilter value and passes the same value to both SectionFilterHeader and ResourceTable. I preserved the existing behavior for callers that explicitly pass a noNamespaceFilter key with an undefined value.
2. Added noNamespaceFilter to the Project Access Role and RoleBinding tables so the project namespace scope is not further restricted by the global namespace filter.
3. Added noNamespaceFilter to Advanced Search so the displayed rows remain consistent with the reported search-result count.
4. I left the OwnedPodsSection noSearch behavior unchanged. Its current caller is namespace-scoped, and when the namespace selector is hidden, bypassing an unrelated global namespace filter is intentional here.
5. I left custom filterFunction semantics unchanged: a caller-supplied filter continues to replace the default filter and owns its filtering behavior.
Validation: focused tests 30/30; full frontend suite 235/235 files, 3120/3120 tests; tsc, lint, format-check, and git diff --check all pass.
<!-- prch:feedback -->
Thanks for the contribution.
<!-- prch:commit-guidelines -->
Could you take a look at the commit messages in this PR? We follow a Linux kernel style for git commits — see the contributing guide and git log for examples.
<details>
<summary>Commits that need attention</summary>
frontend: address namespace filter review feedback — Description must start with a capital letter — e.g. frontend: HomeButton: Fix the button not frontend: HomeButton: fix the button.</details>
<details>
<summary>Commit guidelines</summary>
<area>: <Description of changes> — description must start with a capital letter.Fixes #NN in commit messages.Good examples:
frontend: HomeButton: Fix so it navigates to homebackend: config: Add enable-dynamic-clusters flag</details>
Please clean up the commit history before merge. The second commit, frontend: address namespace filter review feedback, substantially rewrites the ResourceListView implementation/tests introduced by the first commit and has a vague, lowercase description. Squash the corrective work into the original commit (or otherwise reorder it) and use a meaningful <area>: <Description> title that explains the resulting change.
Pull request overview
Fixes stale global namespace filters hiding rows in namespace-scoped tables without mutating global state.
Changes:
ResourceListView header and table filtering behavior.CI build/lint checks passed; several test and platform checks remain in progress. Commit history cleanup is required.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
<details>
<summary>Show a summary per file</summary>
| File | Description |
| ---- | ----------- |
| frontend/src/redux/filterSlice.ts | Supports bypassing namespace matching. |
| frontend/src/redux/filterSlice.test.ts | Tests bypass and text filtering. |
| frontend/src/lib/util.ts | Forwards the bypass option. |
| frontend/src/components/project/ProjectDetails.tsx | Bypasses unrelated filters in Access tables. |
| frontend/src/components/project/ProjectDetails.test.tsx | Verifies Access table configuration. |
| frontend/src/components/common/Resource/ResourceTable.tsx | Exposes and applies noNamespaceFilter. |
| frontend/src/components/common/Resource/ResourceTable.test.tsx | Tests table filtering and state preservation. |
| frontend/src/components/common/Resource/ResourceListView.tsx | Shares effective filtering behavior. |
| frontend/src/components/common/Resource/ResourceListView.test.tsx | Tests override semantics and wiring. |
| frontend/src/components/advancedSearch/ResourceSearch.tsx | Prevents result-count filtering discrepancies. |
</details>
---
💡 <a href="/kubernetes-sigs/headlamp/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/en/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
Updated. I squashed the corrective commit into the original change, rebased onto the current main branch, and renamed the resulting single commit to frontend: ResourceTable: Ignore namespace filter when disabled. The PR now contains one commit.
@illume Updated the commit history as requested. The PR is now a single commit, frontend: ResourceTable: Ignore namespace filter when disabled, rebased onto current main.
Post-rebase validation: focused tests 30/30, tsc, lint, format-check, and git diff --check all pass.
The exported useFilterFunc API now accepts ignoreNamespaceFilter, but the committed generated page still documents only useFilterFunc(matchCriteria?) (docs/development/api/modules/lib_util.md:382-399). Repository guidance requires API-affecting changes to include regenerated output (docs/development/frontend.md:82-86). Please run npm run docs and commit the resulting API documentation updates so consumers can discover this parameter.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
<!-- prch:feedback -->
Thanks for the contribution.
<!-- prch:copilot-comments -->
There are some open Copilot review comments — could you take a look at them? Please mark each one as resolved once you've addressed it.
Addressed in 11aa0657d. I ran npm run docs, but the currently pinned TypeDoc toolchain attempts a repository-wide generated-docs layout migration (201 tracked files plus a new directory structure), while the checked-in API pages still use the legacy layout. To keep this PR scoped, I updated the existing generated lib_util.md page with the new ignoreNamespaceFilter parameter for both useFilterFunc and the re-exported filterResource API. git diff --check is clean.
@illume Addressed the remaining Copilot API-doc feedback in 11aa0657d and resolved both addressed Copilot threads.
<!-- ccr-overview-v2 -->
Copilot review overview
🟢 Approval recommended
The implementation is coherent, regression-tested, documented, and all current-head CI checks pass.
Review effort: Balanced
Findings: None
<details>
<summary><strong>Resolved since last review (2)</strong></summary>
useFilterFunc API now accepts ignoreNamespaceFilter, but the committed generated…](#discussion_r3886970685)</details>
<!-- prch:feedback -->
Thanks for working on this.
<!-- prch:git-conflicts -->
Looks like there are git conflicts in this PR. Can you fix them up?
<details>
<summary>How to resolve conflicts</summary>
Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.
</details>
@illume Rebased onto current main (317ccc200) and resolved the conflicts, preserving the upstream changes. Local validation passed: 38 focused tests, TypeScript, lint, and formatting. CI is running on the updated commit.
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues are recorded for the namespace-filtering changes, although CI status was not available in the supplied context.
No open issues 🎉
<sub>Review effort: Balanced</sub>
<!-- prch:feedback -->
Thanks for the contribution.
<!-- prch:git-conflicts -->
This PR has git conflicts — could you resolve them?
<details>
<summary>How to resolve conflicts</summary>
Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.
</details>
@illume Rebased onto current main (24dffcd52) and resolved the ResourceListView conflicts while preserving both the newer upstream empty-state behavior and this PR's namespace-filter fix. Local validation passed: 61 focused tests, TypeScript, lint, formatting, and diff checks.
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues are identified for the namespace-filtering fix.
No open issues 🎉
<sub>Review effort: Balanced</sub>
<!-- prch:feedback -->
Thanks for this PR.
<!-- prch:git-conflicts -->
There are git conflicts in this PR that need to be resolved.
<details>
<summary>How to resolve conflicts</summary>
Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.
</details>
@illume Rebased again onto current main (b49841fcb) and resolved the ResourceListView test conflict, preserving the newer upstream empty-state tests and this PR's namespace-filter regression coverage. Local validation passed: 66 focused tests, TypeScript, lint, formatting, and diff checks.
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues are blocking approval of the namespace-filtering changes.
No open issues 🎉
<sub>Review effort: Balanced</sub>
🎉 thanks!
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/headlamp/pull/7468#" title="Author self-approved">dlanov</a>, <a href="https://github.com/kubernetes-sigs/headlamp/pull/7468#pullrequestreview-6080893499" title="Approved">illume</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
illume
dlanov
Summary
This PR fixes namespace-scoped resource tables being hidden by a stale global
namespace filter.
When a namespace filter was selected elsewhere in Headlamp, namespace-scoped
views could still apply that global filter at the table row-filtering layer even
though the namespace selector was hidden. This caused resources from the
currently viewed namespace to disappear.
Rather than restoring the global filter reset from #5157, which was reverted by
#5271 due to crashes, this change makes
ResourceTablerespectnoNamespaceFilterwithout modifying the global namespace selection.Related Issue
Fixes #7467
Changes
when namespace filtering is disabled for the view.
noNamespaceFiltervalue inResourceListViewand useit for both
SectionFilterHeaderandResourceTable, while preservingexisting caller override semantics.
persisted state.
by an unrelated global namespace filter.
count is computed.
ResourceListViewwiring, and theProject Access tables.
Steps to Test
1. In Workloads, select a namespace filter such as namespace A.
2. Navigate to Clusters -> Namespaces and open a different namespace B.
3. Scroll to the Pods section.
4. Verify that pods from namespace B are displayed.
5. Return to a normal namespace-filtered resource list and verify that the
original global namespace filter still applies.
6. Open a Project Access tab whose namespaces do not overlap the global
selection and verify its Role/RoleBinding rows remain visible.
7. In Advanced Search, verify the displayed rows remain consistent with the
reported result count regardless of the global namespace selection.
Automated validation:
npm run tscnpm run lintnpm run format-checkgit diff --checkScreenshots (if applicable)
Not applicable.
Notes for the Reviewer
ResourceListViewnow keeps the header and table aligned on the same effectivenamespace-filter behavior, including callers that explicitly pass an
undefinedoverride value.ResourceTable.filterFunctioncontinues to replace the defaultfilter exactly as before and owns its filtering semantics.