11import React from 'react' ;
2- import { Empty } from 'antd' ;
2+ import { Empty , Pagination , Typography } from 'antd' ;
3+ import styled from 'styled-components' ;
34import { StyledTable } from '../../../entity/shared/components/styled/StyledTable' ;
45import { ExecutionRequest } from '../../../../types.generated' ;
56import { ButtonsColumn , SourceColumn , StatusColumn , TimeColumn } from './IngestionExecutionTableColumns' ;
67import { SUCCESS } from '../utils' ;
78import { formatDuration } from '../../../shared/formatDuration' ;
9+ import { SearchCfg } from '../../../../conf' ;
10+
11+ const PaginationInfoContainer = styled . span `
12+ padding: 8px;
13+ padding-left: 16px;
14+ border-top: 1px solid;
15+ border-color: ${ ( props ) => props . theme . styles [ 'border-color-base' ] } ;
16+ display: flex;
17+ justify-content: space-between;
18+ align-items: center;
19+ ` ;
20+
21+ const StyledPagination = styled ( Pagination ) `
22+ margin: 0px;
23+ padding: 0px;
24+ ` ;
25+
26+ const PaginationInfo = styled ( Typography . Text ) `
27+ padding: 0px;
28+ ` ;
829
930interface Props {
1031 executionRequests : ExecutionRequest [ ] ;
1132 setFocusExecutionUrn : ( urn : string ) => void ;
1233 handleViewDetails : ( urn : string ) => void ;
1334 handleCancelExecution : ( urn : string ) => void ;
1435 handleRollbackExecution : ( runId : string ) => void ;
36+ onChangePage : ( number : any ) => void ;
37+ setNumResultsPerPage : ( number : any ) => void ;
38+ totalExecution ?: number | null ;
39+ page ?: any ;
40+ pageSize ?: any ;
41+ lastResultIndex ?: any ;
1542}
1643
1744export default function IngestionExecutionTable ( {
1845 executionRequests,
46+ onChangePage,
1947 setFocusExecutionUrn,
2048 handleViewDetails,
2149 handleCancelExecution,
2250 handleRollbackExecution,
51+ setNumResultsPerPage,
52+ totalExecution,
53+ pageSize,
54+ lastResultIndex,
55+ page,
2356} : Props ) {
2457 const tableColumns = [
2558 {
@@ -69,7 +102,8 @@ export default function IngestionExecutionTable({
69102 } ,
70103 ] ;
71104
72- const mostRecentSuccessfulExecution = executionRequests . find ( ( execution ) => execution . result ?. status === SUCCESS ) ;
105+ const mostRecentSuccessfulExecution =
106+ page === 1 && executionRequests . find ( ( execution ) => execution . result ?. status === SUCCESS ) ;
73107
74108 const tableData = executionRequests . map ( ( execution ) => ( {
75109 urn : execution . urn ,
@@ -79,18 +113,38 @@ export default function IngestionExecutionTable({
79113 executedAt : execution . result ?. startTimeMs ,
80114 duration : execution . result ?. durationMs ,
81115 status : execution . result ?. status ,
82- showRollback : execution . urn === mostRecentSuccessfulExecution ?. urn ,
116+ showRollback : mostRecentSuccessfulExecution && execution ? .urn === mostRecentSuccessfulExecution ?. urn ,
83117 } ) ) ;
84118
85119 return (
86- < StyledTable
87- columns = { tableColumns }
88- dataSource = { tableData }
89- rowKey = "id"
90- locale = { {
91- emptyText : < Empty description = "No Executions found!" image = { Empty . PRESENTED_IMAGE_SIMPLE } /> ,
92- } }
93- pagination = { false }
94- />
120+ < >
121+ < StyledTable
122+ columns = { tableColumns }
123+ dataSource = { tableData }
124+ rowKey = "id"
125+ locale = { {
126+ emptyText : < Empty description = "No Executions found!" image = { Empty . PRESENTED_IMAGE_SIMPLE } /> ,
127+ } }
128+ pagination = { false }
129+ />
130+ < PaginationInfoContainer >
131+ < PaginationInfo >
132+ < b >
133+ { lastResultIndex > 0 ? ( page - 1 ) * pageSize + 1 : 0 } - { lastResultIndex }
134+ </ b > { ' ' }
135+ of < b > { totalExecution } </ b >
136+ </ PaginationInfo >
137+ < StyledPagination
138+ current = { page }
139+ pageSize = { pageSize }
140+ total = { totalExecution as any }
141+ showLessItems
142+ onChange = { onChangePage }
143+ showSizeChanger = { ( totalExecution as any ) > SearchCfg . RESULTS_PER_PAGE }
144+ onShowSizeChange = { ( _currNum , newNum ) => setNumResultsPerPage ( newNum ) }
145+ pageSizeOptions = { [ '10' , '20' , '50' , '100' ] }
146+ />
147+ </ PaginationInfoContainer >
148+ </ >
95149 ) ;
96150}
0 commit comments