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 (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughThis PR adds a new user preference enabling users to configure the default filter type on the Search page. The preference is declared in extension config with Label/Name dropdown options, implemented via a custom hook that retrieves and asynchronously 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
Sequence DiagramsequenceDiagram
participant User
participant SearchFilterDropdown
participant useSearchDefaultFilterType
participant useUserPreference
User->>SearchFilterDropdown: Render
SearchFilterDropdown->>useSearchDefaultFilterType: Call hook
useSearchDefaultFilterType->>useUserPreference: Retrieve console.searchDefaultFilterType
useUserPreference-->>useSearchDefaultFilterType: Return preference (Label/Name) + loaded state
useSearchDefaultFilterType-->>SearchFilterDropdown: Return [filterType, loaded]
SearchFilterDropdown->>SearchFilterDropdown: Set preferredDefault from loaded value
SearchFilterDropdown-->>User: Display dropdown with default (Label or Name)
User->>SearchFilterDropdown: Select filter type (optional)
SearchFilterDropdown->>SearchFilterDropdown: Set userSelected override
SearchFilterDropdown-->>User: Display user selection
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.5.0)frontend/packages/console-app/console-extensions.jsonFile contains syntax errors that prevent linting: Line 1893: Expected a property but instead found '// The query used to compute the number of kube-apiserver instances that are up'.; Line 1904: End of file expected; Line 1904: End of file expected; Line 1905: Expected an array, an object, or a literal but instead found '// API_SERVERS_UP'.; Line 1904: End of file expected; Line 1905: End of file expected; Line 1906: End of file expected; Line 1906: End of file expected; Line 1908: End of file expected; Line 1908: End of file expected; Line 1910: End of file expected; Line 1910: End of file expected; Line 1912: End of file expected; Line 1913: End of file expected; Line 1914: End of file expected; Line 1914: End of file expected; Line 1914: End of file expected; Line 1916: End of file expected; Line 1917: 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 1920: End of file expecte ... [truncated 2765 characters] ... expected; Line 2717: End of file expected; Line 2727: End of file expected; Line 2728: End of file expected; Line 2738: End of file expected; Line 2739: End of file expected; Line 2749: End of file expected; Line 2750: End of file expected; Line 2755: End of file expected; Line 2756: End of file expected; Line 2766: End of file expected; Line 2767: End of file expected; Line 2777: End of file expected; Line 2778: End of file expected; Line 2788: End of file expected; Line 2789: End of file expected; Line 2799: End of file expected; Line 2800: End of file expected; Line 2812: End of file expected; Line 2813: End of file expected; Line 2823: End of file expected; Line 2824: End of file expected; Line 2834: End of file expected; Line 2835: End of file expected; Line 2846: 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. |

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
New Features
Updates