@@ -36,7 +36,16 @@ import {
3636 ShowOperandsInAllNamespacesRadioGroup ,
3737 useShowOperandsInAllNamespaces ,
3838} from '../shared/AllNamespaces' ;
39- import { GitOpsDataViewTable , useGitOpsDataViewSort } from '../shared/DataView' ;
39+ import {
40+ GitOpsDataViewTable ,
41+ useGitOpsDataViewSort ,
42+ useGitOpsListPagePagination ,
43+ } from '../shared/DataView' ;
44+ import {
45+ filterByConsoleNameAndLabels ,
46+ filterResourcesByLabelQuery ,
47+ parseLabelFilterParam ,
48+ } from '../shared/listPageTextFilters' ;
4049import { MetadataLabels } from '../shared/MetadataLabels/MetadataLabels' ;
4150
4251import { useRolloutActionsProvider } from './hooks/useRolloutActionsProvider' ;
@@ -112,6 +121,8 @@ const RolloutList: React.FC<RolloutListTabProps> = ({
112121
113122 // Get search query from URL parameters
114123 const searchQuery = searchParams . get ( 'q' ) || '' ;
124+ const nameQuery = searchParams . get ( 'name' ) || '' ;
125+ const labelsParam = searchParams . get ( 'labels' ) || '' ;
115126
116127 const { t } = useGitOpsTranslation ( ) ;
117128
@@ -123,22 +134,22 @@ const RolloutList: React.FC<RolloutListTabProps> = ({
123134 const filters = getFilters ( t ) ;
124135 const [ data , filteredData , onFilterChange ] = useListPageFilter ( sortedRollouts , filters ) ;
125136
126- // TODO: use alternate filter since it is deprecated. See DataTableView potentially
127- // Filter by search query if present (after other filters)
128- const filteredBySearch = React . useMemo ( ( ) => {
129- if ( ! searchQuery ) return filteredData ;
137+ const filteredByNameAndLabels = React . useMemo (
138+ ( ) => filterByConsoleNameAndLabels ( filteredData , nameQuery , parseLabelFilterParam ( labelsParam ) ) ,
139+ [ filteredData , nameQuery , labelsParam ] ,
140+ ) ;
130141
131- return filteredData . filter ( ( app ) => {
132- const labels = app . metadata ?. labels || { } ;
133- // Check if any label matches the search query
134- return Object . entries ( labels ) . some ( ( [ key , value ] ) => {
135- const labelSelector = `${ key } =${ value } ` ;
136- return labelSelector . includes ( searchQuery ) || key . includes ( searchQuery ) ;
137- } ) ;
138- } ) ;
139- } , [ filteredData , searchQuery ] ) ;
142+ const filteredBySearch = React . useMemo (
143+ ( ) => filterResourcesByLabelQuery ( filteredByNameAndLabels , searchQuery ) ,
144+ [ filteredByNameAndLabels , searchQuery ] ,
145+ ) ;
140146
141- const rows = useRolloutsRowsDV ( filteredBySearch , namespace , t ) ;
147+ const { pagination, pagedItems, itemCount } = useGitOpsListPagePagination ( {
148+ items : filteredBySearch ,
149+ namespace,
150+ searchParams,
151+ } ) ;
152+ const rows = useRolloutsRowsDV ( pagedItems , namespace , t ) ;
142153
143154 const empty = (
144155 < Tbody >
@@ -206,7 +217,7 @@ const RolloutList: React.FC<RolloutListTabProps> = ({
206217 onFilterChange = { onFilterChange }
207218 />
208219 </ span >
209- { rows . length > 0 && ! loadError && (
220+ { filteredBySearch . length > 0 && ! loadError && (
210221 < span className = "rollout-list-page__topology-link pf-m-mb-sm" >
211222 { topologyLink ( topologyUrl , t ) }
212223 </ span >
@@ -220,6 +231,8 @@ const RolloutList: React.FC<RolloutListTabProps> = ({
220231 emptyState = { empty }
221232 isError = { ! ! loadError }
222233 errorState = { error || undefined }
234+ itemCount = { itemCount }
235+ pagination = { pagination }
223236 />
224237 </ ListPageBody >
225238 </ >
0 commit comments