1- import React from 'react' ;
1+ import React , { useEffect } from 'react' ;
22
33import { translate } from '../translate' ;
44import { CollapseTable } from '../../../common/CollapseTable' ;
@@ -12,20 +12,28 @@ import {
1212 workspaceSelectors ,
1313 stackSelectors ,
1414} from '../../../../../redux/selectors' ;
15+ import { callActionForStacksForPagination } from '../useService' ;
1516
1617interface Props {
1718 filter : any ;
1819 pagination ?: boolean ;
1920 id ?: string ;
2021 isExpended ?: boolean ;
22+ stackComponentId ?: TId ;
2123}
2224export const List : React . FC < Props > = ( {
2325 filter,
2426 pagination,
2527 isExpended,
2628 id,
29+ stackComponentId,
2730} : Props ) => {
2831 const history = useHistory ( ) ;
32+ const { dispatchStackData } = callActionForStacksForPagination ( ) ;
33+ const ITEMS_PER_PAGE = parseInt (
34+ process . env . REACT_APP_ITEMS_PER_PAGE as string ,
35+ ) ;
36+ const DEFAULT_ITEMS_PER_PAGE = 10 ;
2937 const {
3038 openStackIds,
3139 setOpenStackIds,
@@ -37,7 +45,22 @@ export const List: React.FC<Props> = ({
3745 activeSortingDirection,
3846 setActiveSortingDirection,
3947 setSelectedRunIds,
40- } = useService ( { filter, isExpended } ) ;
48+ } = useService ( { filter, isExpended, stackComponentId } ) ;
49+ const stacksPaginated = useSelector ( stackSelectors . mystacksPaginated ) ;
50+
51+ useEffect ( ( ) => {
52+ if ( stackComponentId ) {
53+ dispatchStackData (
54+ 1 ,
55+ ITEMS_PER_PAGE ? ITEMS_PER_PAGE : DEFAULT_ITEMS_PER_PAGE ,
56+ filter ,
57+ activeSortingDirection ?. toLowerCase ( ) + ':' + activeSorting ,
58+ stackComponentId ,
59+ ) ;
60+ }
61+ // eslint-disable-next-line react-hooks/exhaustive-deps
62+ } , [ stackComponentId ] ) ;
63+ console . log ( fetching , 'asdasdasd' ) ;
4164 const expendedRow = filteredStacks . filter ( ( item ) => item . id === id ) ;
4265 const headerCols = GetHeaderCols ( {
4366 expendedRow,
@@ -51,8 +74,8 @@ export const List: React.FC<Props> = ({
5174 setActiveSortingDirection,
5275 } ) ;
5376 const selectedWorkspace = useSelector ( workspaceSelectors . selectedWorkspace ) ;
54- const stacksPaginated = useSelector ( stackSelectors . mystacksPaginated ) ;
5577
78+ // console.log(filter, 'filterfilterfilter');
5679 const openDetailPage = ( stack : TStack ) => {
5780 setSelectedRunIds ( [ ] ) ;
5881 if ( id ) {
0 commit comments