RFE-4925: Add user preference for default Search filter type#16601
RFE-4925: Add user preference for default Search filter type#16601Alwinator wants to merge 1 commit into
Conversation
|
@Alwinator: This pull request references RFE-4925 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature request to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (6)
WalkthroughThis PR adds a new user preference enabling users to configure the default filter type on the Search page. The preference is declared with Label/Name dropdown options, implemented via a custom hook that retrieves and loads the user's selection, and integrated into the SearchFilterDropdown component to apply the default while preserving manual user selections. ChangesSearch Default Filter Type Preference
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.4.16)frontend/packages/console-app/console-extensions.jsonFile contains syntax errors that prevent linting: Line 1900: Expected a property but instead found '// The query used to compute the number of kube-apiserver instances that are up'.; Line 1911: End of file expected; Line 1911: End of file expected; Line 1912: Expected an array, an object, or a literal but instead found '// API_SERVERS_UP'.; Line 1911: End of file expected; Line 1912: End of file expected; Line 1913: End of file expected; Line 1913: End of file expected; Line 1915: End of file expected; Line 1915: End of file expected; Line 1917: End of file expected; Line 1917: End of file expected; Line 1919: End of file expected; Line 1920: End of file expected; Line 1921: End of file expected; Line 1921: End of file expected; Line 1921: End of file expected; Line 1923: End of file expected; Line 1924: End of file expected; Line 1924: End of file expected; Line 1924: End of file expected; Line 1926: End of file expected; Line 1927: End of file expected; Line 1927: End of file expecte ... [truncated 2765 characters] ... expected; Line 2724: End of file expected; Line 2734: End of file expected; Line 2735: End of file expected; Line 2745: End of file expected; Line 2746: End of file expected; Line 2756: End of file expected; Line 2757: End of file expected; Line 2762: End of file expected; Line 2763: End of file expected; Line 2773: End of file expected; Line 2774: End of file expected; Line 2784: End of file expected; Line 2785: End of file expected; Line 2795: End of file expected; Line 2796: End of file expected; Line 2806: End of file expected; Line 2807: End of file expected; Line 2819: End of file expected; Line 2820: End of file expected; Line 2830: End of file expected; Line 2831: End of file expected; Line 2841: End of file expected; Line 2842: End of file expected; Line 2853: End of file expected Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Alwinator The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Alwinator. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
@Alwinator: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |

Analysis / Root cause:
On the Search page, the filter dropdown lets users search resources by Label or by Name. The selection always defaults to Label on every page load, and there is no way to change that default. Users who primarily search by Name have to re-select it each time they open the Search page.
This adds a user preference so each user can choose which filter type is preselected on the Search page. The default behavior is unchanged (still Label) for users who don't set a preference.
Solution description:
console.searchDefaultFilterType.useSearchDefaultFilterTypehook (mirroring the existinguseExactSearchhook) that reads the preference viauseUserPreference, defaulting toLabel.SearchFilterDropdownto read the preference and apply it to the dropdown's initialselectedstate. The default is applied once, gated on the preference's loaded flag, via auseRefguard so it never overrides a manual selection the user makes in the dropdown and avoids a flash of the wrong default.yarn i18nto extract the new translatable strings intopackages/console-app/locales/en/console-app.json.Changed files:
frontend/packages/console-app/console-extensions.json— newconsole.user-preference/itemdropdown extension.frontend/packages/console-app/src/components/user-preferences/search/useSearchDefaultFilterType.ts— new hook.frontend/public/components/search-filter-dropdown.tsx— apply preferred default on load.frontend/packages/console-app/locales/en/console-app.json— extracted i18n keys.Screenshots / screen recording:
Test setup:
No special setup required.
Test cases:
Default behavior: With no preference set, open Administration → Search (or the perspective's Search) — the filter dropdown defaults to Label.
Set preference: Go to User Preferences → General → Default search filter, select Name. Open the Search page — the filter dropdown is preselected to Name.
Switch back: Set the preference back to Label; the Search page dropdown defaults to Label again.
Manual override is preserved: With the preference set to Name, open the Search page, then manually switch the dropdown to Label — it should not snap back to Name.
Autosave: Changing the preference is autosaved (no explicit save action needed).
Unit tests:
frontend/packages/console-app/src/components/user-preferences/search/__tests__/useSearchDefaultFilterType.spec.tsfrontend/public/components/__tests__/search-filter-dropdown.spec.tsxRun with:
Browser conformance:
Additional info:
Label/Name) intentionally match thesearchFilterValuesenum so no mapping is required between the preference and the dropdown.console.user-preference/itemextension point.Reviewers and assignees:
Console Approver:
/assign @openshift/team-ux-review
Docs approver:
/assign @openshift/team-ux-review
PX approver:
/assign @openshift/team-ux-review
Summary by CodeRabbit