feat(ui): autocomplete namespace filter from displayed resources (refs #7405)#16087
Open
callmemorgan wants to merge 3 commits into
Open
feat(ui): autocomplete namespace filter from displayed resources (refs #7405)#16087callmemorgan wants to merge 3 commits into
callmemorgan wants to merge 3 commits into
Conversation
Refs argoproj#7405. The shared NamespaceFilter used on workflows, workflow templates, cron workflows, sensors, event sources, event bindings, and event flow was a free-text input backed only by a 5-entry localStorage history. Users with many namespaces had to retype namespace names from memory. Each of those pages already loads a resource list whose items carry metadata.namespace. Wire that list into the namespace filter so the already-visible namespaces appear as autocomplete suggestions. This is the workflow-derived approach endorsed on argoproj#9140: suggestions never exceed what the user can already list, so no RBAC boundary is crossed. - InputFilter accepts an extraSuggestions prop; merges with localStorage history, dedups, passes the merged list to Autocomplete. - NamespaceFilter accepts an extraNamespaces prop and enables filterSuggestions so typing narrows the merged list. - shared/namespaces.ts gains getUniqueNamespaces<T>(items). - 7 callers wire extraNamespaces from their resource list in scope. - Reports filters has no resource list in scope and keeps existing free-text + localStorage behavior; can be wired through in a follow-up. - New unit test in input-filter.test.tsx covers the merge, ordering, dedup, and empty cases. Signed-off-by: Morgan Allen <[email protected]>
Required by the feature-pr-handling CI check for feat: PRs. Signed-off-by: Morgan Allen <[email protected]>
9a91ca6 to
bf195cf
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.
Fixes #7405
Motivation
The UI namespace filter (used on workflows, workflow templates, cron workflows, sensors, event sources, event bindings, event flow) is currently a free-text input backed only by a 5-entry localStorage history. Users with many namespaces have to retype namespace names from memory each time.
Issue #7405 has tracked this for 4+ years. In a comment on the dup #9140, @agilgur5 noted that one safe and proper way to provide namespace autocomplete is to derive suggestions from the namespaces of workflows the user has already loaded — since the user already has
listpermission on those namespaces, this leaks no information beyond k8s RBAC's existing answer.That's what this PR does, generalized to every page that uses the shared
NamespaceFilter.Modifications
shared/components/input-filter.tsxgains an optionalextraSuggestions?: string[]prop. Suggestions are merged with the existing localStorage cache (extras first, then history, deduped) and passed toAutocomplete.shared/components/namespace-filter.tsxgains a matchingextraNamespaces?: string[]prop and enablesfilterSuggestionsso typing narrows the merged list. The managed-namespace short-circuit is unchanged.shared/namespaces.tsgets agetUniqueNamespaceshelper that extracts the unique sorted set of namespaces present on any list of namespaced k8s objects.NamespaceFilternow passextraNamespacesderived from the resource list each page already loads:props.workflowstemplatespropcronWorkflowspropworkflowEventBindingsstateeventSourcesstatesensorsstateeventSources + sensors + workflowsreports/reports-filters.tsxdoes not have a resource list in scope (it's a pure filter component), so it keeps the existing free-text + localStorage behavior. Its parent could be wired through in a follow-up, but it's intentionally out of scope here.InputFiltercovers the merge/dedup/order/empty-state behavior.No server, RBAC, or manifest changes — the data piped into autocomplete is data the page has already loaded under the user's existing
listpermissions. Cluster-wide list responses already includemetadata.namespaceper item (e.g.,workflow-template-list.tsx:90), which is what populates the suggestions.This is purposefully a small fix. Some honest limitations:
Those limitations could be addressed by a future server-side
ListNamespacesendpoint, which would be a separate design discussion involving manifest/RBAC changes — explicitly out of scope here. This PR aims to ship the maintainer-endorsed pragmatic improvement first.Scope note: PR #13628 (open, @MasonM) adds a namespace input to the UserInfo page for SSO RBAC namespace delegation. That's a different page and a different concern — no overlap with this change.
Verification
yarn --cwd ui lintpasses.yarn --cwd ui testpasses; new test cases ininput-filter.test.tsxcover:extraSuggestionsundefined → behavior identical to before (only the localStorage cache appears inAutocomplete.items).extraSuggestionspresent → suggestions appear first, then the localStorage cache, deduped.extraSuggestions→ empty items list.yarn --cwd ui startand confirmed that on/workflows,/workflow-templates,/cron-workflows,/sensors,/event-sources,/workflow-event-bindings,/event-flowthe Namespace field's autocomplete now lists the namespaces of currently-visible resources and narrows them as you type. Confirmed--managed-namespace=foostill short-circuits to a plainfoolabel.Documentation
No user-facing documentation change required — this is a UX improvement to an existing filter with no new configuration, flag, or API surface.
AI
Claude (Anthropic) was used to:
NamespaceFiltercallers and confirm what data each had in scope.util/auth.CanIArgo,server/auth.CanI) and their callers.ListNamespacesto a separate design discussion).All code in this PR was reviewed by the author before commit.