@@ -4,36 +4,14 @@ import { EmptyState } from '@patternfly/react-core';
44import { SystemEventResponseApi } from '@api' ;
55import { Link } from 'react-router-dom' ;
66import { resolveResourcePath } from '@app/utils/parseFuncs' ;
7- import { CheckCircleIcon , ErrorCircleOIcon , WarningTriangleIcon , InboxIcon } from '@patternfly/react-icons' ;
7+ import { InboxIcon } from '@patternfly/react-icons' ;
8+ import { getResultIcon } from '@app/utils/renderUtils' ;
9+ import { ResultStatus } from '@app/types/types' ;
810
911interface ActivityTableProps {
1012 events : SystemEventResponseApi [ ] ;
1113}
1214
13- const getResultIcon = ( result : string ) => {
14- const PATTERNFLY_COLORS = {
15- success : 'var(--pf-t--global--color--status--success--default)' ,
16- danger : 'var(--pf-t--global--color--status--danger--default)' ,
17- warning : 'var(--pf-t--global--color--status--warning--default)' ,
18- } as const ;
19-
20- switch ( result . toLowerCase ( ) ) {
21- case 'ok' :
22- case 'success' :
23- return < CheckCircleIcon color = { PATTERNFLY_COLORS . success } /> ;
24- case 'failed' :
25- case 'failure' :
26- case 'error' :
27- return < ErrorCircleOIcon color = { PATTERNFLY_COLORS . danger } /> ;
28- case 'warning' :
29- case 'partial' :
30- case 'pending' :
31- return < WarningTriangleIcon color = { PATTERNFLY_COLORS . warning } /> ;
32- default :
33- return < WarningTriangleIcon color = { PATTERNFLY_COLORS . warning } /> ;
34- }
35- } ;
36-
3715export const ActivityTable : React . FunctionComponent < ActivityTableProps > = ( { events } ) => {
3816 if ( events . length === 0 ) {
3917 return < EmptyState headingLevel = "h4" icon = { InboxIcon } titleText = "No recent events" > </ EmptyState > ;
@@ -56,7 +34,7 @@ export const ActivityTable: React.FunctionComponent<ActivityTableProps> = ({ eve
5634 < Td > { event . timestamp ? new Date ( event . timestamp ) . toLocaleString ( 'es-ES' ) : '-' } </ Td >
5735 < Td > { event . action } </ Td >
5836 < Td >
59- { getResultIcon ( event . result ) } { event . result }
37+ { getResultIcon ( event . result as ResultStatus ) } { event . result }
6038 </ Td >
6139 < Td >
6240 < Link to = { resolveResourcePath ( event . resourceType ?? '-' , event . resourceId ?? '-' ) } >
0 commit comments