fix(home): scope topology preview legend by ns + count restricted ns (#655)#735
Merged
Conversation
Two follow-ups from #655 on per-user RBAC visual test: 1. Topology preview card on Home: the SSE topology stream is cluster- wide for small/medium clusters; only the dashboard summary is namespace-filtered server-side. That left the kind legend showing cluster-wide totals while the "<X> resources · <Y> conn" header had already narrowed to the active namespace. Filter the topology client-side in HomeView before passing it to TopologyPreview (and ActivitySummary) so the legend matches the title. No-op on large clusters where forceNamespaceFilter already filters SSE server-side. 2. Cluster info card "0 namespaces" for restricted users: dashboard.go only populated resourceCounts.Namespaces when the user could list namespaces cluster-wide, leaving a misleading "0" for users with a restricted namespace view. Fall back to len(allowedNamespaces), mirroring the same pattern in resource_counts.go. Item #2 from the issue (sidebar count "1" vs page "No Namespace found" asymmetry) is left as-is — genuine product call, neither option is obviously better than the other.
573c196 to
2056fb0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two of the three follow-ups from #655 (per-user RBAC visual-test pass on #609). Item #2 from that issue is intentionally left out — it's a product call, not a clear fix.
1. Home topology preview: legend stayed cluster-wide when a namespace was picked
The SSE topology stream is cluster-wide for small/medium clusters; only the dashboard
summary(the "X resources · Y conn" header) is namespace-filtered server-side. So picking a namespace updated the header but left the kind legend reflecting cluster-wide totals.Verified end-to-end on
prod-cluster-us-east1with theautopushnamespace selected:Fix: a
scopedTopologymemo inHomeViewfilters the topology to the active namespace set on the client (cluster-scoped nodes pass through, dangling edges dropped) before passing it toTopologyPreviewandActivitySummary. No-op on large clusters (≥1000 nodes) whereforceNamespaceFilteralready filters SSE server-side.2. Cluster info card: "0 namespaces" for restricted users
dashboard.goonly populatedResourceCounts.Namespaceswhen the user couldlist namespacescluster-wide. For users restricted to N specific namespaces (no cluster-wide SAR), the count stayed at0— misleading. Fall back tolen(allowedNamespaces), mirroring the same pattern already inresource_counts.go.Note
Low Risk
Low risk: changes are limited to dashboard display logic (client-side topology filtering) and a small server-side fallback for namespace counts, with no auth or data-write behavior modified.
Overview
Fixes mismatches on the Home dashboard when a namespace filter is active by client-filtering the SSE topology before rendering, so
TopologyPreviewandActivitySummarylegends/edges align with the namespace-scoped summary.Also corrects the cluster info/resource counts for RBAC-restricted users by reporting the number of accessible namespaces when the user cannot
list namespacescluster-wide (instead of showing0).Reviewed by Cursor Bugbot for commit 2056fb0. Bugbot is set up for automated code reviews on this repo. Configure here.