SRVKP-11167: Add custom DataViewFilterToolbar and useDataViewFilter hook#1003
Conversation
|
@anwesha-palit-redhat: This pull request references SRVKP-11167 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 story to target the "4.22.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. |
|
|
e488c36 to
f5c64d0
Compare
updated and passing now |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anwesha-palit-redhat, arvindk-softwaredev The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
c64fba5
into
openshift-pipelines:master
Summary
Introduces
DataViewFilterToolbar, a reusable filter toolbar component built with PatternFly 6 core components (Toolbar,MenuToggle,Popper,SearchInput,ToolbarFilter) that mirrors the console'sDataViewToolbar+DataViewFilterspattern. This is needed because@patternfly/react-data-viewfilter components (DataViewCheckboxFilter, etc.) cannot be used in dynamic plugins due to a React context mismatch — the host console'sConsoleDataViewrendersDataViewFiltersfrom its own module instance, and the plugin's bundled copy creates a separate context, causing runtime crashes.Introduces
useDataViewFilter, a generic hook that manages filter state (name, label, and configurable checkbox filters) and returns pre-filtered data for use withConsoleDataView.Features
DataViewFiltersUX pattern.key=valueorkeylabel selectors, displayed as removable chips. Supports AND matching across multiple labels.totalCountfor server-side pagination.Why not use
@patternfly/react-data-viewdirectly?ConsoleDataViewinternally rendersDataViewFiltersfrom the host's copy of@patternfly/react-data-view. Filter components passed viaadditionalFilterNodesfrom the plugin come from a different module instance, creating separate React contexts. Since@patternfly/react-data-viewis not in the console's Webpack Module Federation shared modules list, there is no way to share a single instance. This custom toolbar uses only@patternfly/react-corecomponents (which are shared) and pre-filters data before passing it toConsoleDataView, avoiding the context issue entirely.Sample Usage
Key points:
hideNameLabelFilterstoConsoleDataViewto avoid duplicate filter UIhideLabelFilterorhideNameFilteronDataViewFilterToolbarto selectively hide filtersFilterOption.countis mandatory;totalCountis optional (for server-side pagination, renders ascount/totalCount)Test plan
DataViewFilterToolbarrenders the category selector dropdown when multiple filters are configuredConsoleDataView(data is pre-filtered,hideNameLabelFiltersis set)Screenshots / Screen Recordings
custom_filter.mov
Co-authored and Assisted By