@@ -2,47 +2,69 @@ import { FC } from 'react'
22import { useTranslation } from 'react-i18next'
33import Typography from '@mui/material/Typography'
44import { RoflInstance } from '../../../oasis-nexus/api'
5+ import { COLORS } from '../../../styles/theme/colors'
56import { Table , TableCellAlign , TableColProps } from '../../components/Table'
67import { TablePaginationProps } from '../../components/Table/TablePagination'
8+ import { RoflAppInstanceStatusBadge } from 'app/components/Rofl/RoflAppInstanceStatusBadge'
79
810type InstancesListProps = {
11+ currentEpoch : number | undefined
912 instances : RoflInstance [ ] | undefined
1013 isLoading : boolean
1114 limit : number
1215 pagination : false | TablePaginationProps
1316}
1417
15- export const InstancesList : FC < InstancesListProps > = ( { isLoading, limit, pagination, instances } ) => {
18+ export const InstancesList : FC < InstancesListProps > = ( {
19+ isLoading,
20+ limit,
21+ pagination,
22+ instances,
23+ currentEpoch,
24+ } ) => {
1625 const { t } = useTranslation ( )
1726 const tableColumns : TableColProps [ ] = [
1827 { key : 'rak' , content : t ( 'rofl.rakAbbreviation' ) } ,
1928 { key : 'node' , content : t ( 'rofl.nodeId' ) } ,
20- { key : 'expiration' , content : t ( 'rofl.expirationEpoch' ) , align : TableCellAlign . Right } ,
29+ { key : 'expirationEpoch' , content : t ( 'rofl.expirationEpoch' ) , align : TableCellAlign . Right } ,
30+ { key : 'expirationStatus' , content : t ( 'common.status' ) , align : TableCellAlign . Right } ,
2131 ]
2232
23- const tableRows = instances ?. map ( instance => {
24- return {
25- key : instance . rak ,
26- data : [
27- {
28- key : 'rak' ,
29- content : < Typography variant = "mono" > { instance . rak } </ Typography > ,
30- } ,
31- {
32- key : 'node' ,
33- content : < Typography variant = "mono" > { instance . endorsing_node_id } </ Typography > ,
34- } ,
35- {
36- key : 'expiration' ,
37- content : instance . expiration_epoch . toLocaleString ( ) ,
38- align : TableCellAlign . Right ,
39- } ,
40- ] ,
41- }
42- } )
33+ const tableRows =
34+ currentEpoch !== undefined && instances
35+ ? instances ?. map ( instance => {
36+ const isActive = instance . expiration_epoch > currentEpoch
37+
38+ return {
39+ key : instance . rak ,
40+ backgroundColor : isActive ? 'transparent' : COLORS . grayLight ,
41+ data : [
42+ {
43+ key : 'rak' ,
44+ content : < Typography variant = "mono" > { instance . rak } </ Typography > ,
45+ } ,
46+ {
47+ key : 'node' ,
48+ content : < Typography variant = "mono" > { instance . endorsing_node_id } </ Typography > ,
49+ } ,
50+ {
51+ key : 'expirationEpoch' ,
52+ content : instance . expiration_epoch . toLocaleString ( ) ,
53+ align : TableCellAlign . Right ,
54+ } ,
55+ {
56+ key : 'expirationStatus' ,
57+ content : < RoflAppInstanceStatusBadge isActive = { isActive } /> ,
58+ align : TableCellAlign . Right ,
59+ } ,
60+ ] ,
61+ }
62+ } )
63+ : undefined
4364
4465 return (
4566 < Table
67+ emptyMessage = { t ( 'rofl.emptyInstancesList' ) }
4668 columns = { tableColumns }
4769 rows = { tableRows }
4870 rowsNumber = { limit }
0 commit comments