@@ -19,7 +19,11 @@ import { DataViewTh, DataViewTr } from '@patternfly/react-data-view/dist/esm/Dat
1919import { CubesIcon } from '@patternfly/react-icons' ;
2020import { Tbody , Td , ThProps , Tr } from '@patternfly/react-table' ;
2121
22- import { GitOpsDataViewTable , useGitOpsDataViewSort } from '../../shared/DataView' ;
22+ import {
23+ GitOpsDataViewTable ,
24+ useGitOpsDataViewSort ,
25+ useGitOpsListPagePagination ,
26+ } from '../../shared/DataView' ;
2327
2428import './History.scss' ;
2529
@@ -35,14 +39,26 @@ const HistoryList: React.FC<HistoryListProps> = ({ history, obj }) => {
3539 [ ] ,
3640 ) ;
3741
38- const { sortBy, direction, getSortParams } = useGitOpsDataViewSort ( columnSortConfig ) ;
42+ const { searchParams, sortBy, direction, getSortParams } =
43+ useGitOpsDataViewSort ( columnSortConfig ) ;
3944 const columnsDV = useColumnsDV ( getSortParams ) ;
4045
41- const sortedHistory = React . useMemo ( ( ) => {
42- return sortData ( history , sortBy , direction ) ;
43- } , [ history , sortBy , direction ] ) ;
46+ const displayHistory = React . useMemo (
47+ ( ) => sortData ( [ ...history ] . reverse ( ) , sortBy , direction ) ,
48+ [ history , sortBy , direction ] ,
49+ ) ;
50+
51+ const {
52+ pagination,
53+ pagedItems : pagedHistory ,
54+ itemCount,
55+ } = useGitOpsListPagePagination ( {
56+ items : displayHistory ,
57+ namespace : obj ?. metadata ?. namespace ,
58+ searchParams,
59+ } ) ;
4460
45- const rows = useRowsDV ( sortedHistory , obj ) ;
61+ const rows = useRowsDV ( pagedHistory , obj ) ;
4662
4763 const argoServer = useArgoServer ( obj ) ;
4864 const argoUrl = getApplicationArgoUrl ( argoServer , obj ) ;
@@ -85,7 +101,9 @@ const HistoryList: React.FC<HistoryListProps> = ({ history, obj }) => {
85101 rows = { rows }
86102 columns = { columnsDV }
87103 emptyState = { empty }
88- isEmpty = { rows . length === 0 }
104+ isEmpty = { displayHistory . length === 0 }
105+ itemCount = { itemCount }
106+ pagination = { pagination }
89107 />
90108 </ div >
91109 ) ;
@@ -187,7 +205,7 @@ const useRowsDV = (history: ApplicationHistory[], app: ApplicationKind): DataVie
187205 } ,
188206 ] ) ;
189207 } ) ;
190- return rows . reverse ( ) ;
208+ return rows ;
191209} ;
192210
193211const useColumnsDV = ( getSortParams : ( columnIndex : number ) => ThProps [ 'sort' ] ) => {
0 commit comments