@@ -6,9 +6,11 @@ import {
66 HealthProgressingIcon ,
77 HealthSuspendedIcon ,
88 HealthUnknownIcon ,
9+ SpinningIcon ,
910} from 'src/gitops/utils/components/Icons/Icons' ;
1011import { HealthStatus as HS } from 'src/gitops/utils/constants' ;
1112
13+ import { COLORS } from '@gitops/components/shared/colors' ;
1214import { Button , Popover } from '@patternfly/react-core' ;
1315
1416interface HealthProps {
@@ -64,4 +66,50 @@ const HealthStatus: React.FC<HealthProps> = ({ status, message }) => {
6466 return < div > { showStatus } </ div > ;
6567} ;
6668
69+ export type HealthStatusCode =
70+ | 'Unknown'
71+ | 'Progressing'
72+ | 'Healthy'
73+ | 'Suspended'
74+ | 'Degraded'
75+ | 'Missing' ;
76+
77+ export interface HealthStatusModel {
78+ status : HealthStatusCode ;
79+ message : string ;
80+ }
81+
82+ export const HealthStatusIcon = ( { status } : { status : HealthStatusCode } ) => {
83+ let color = COLORS . health . unknown ;
84+ let icon = 'fa-question-circle' ;
85+
86+ switch ( status ) {
87+ case HS . HEALTHY :
88+ color = COLORS . health . healthy ;
89+ icon = 'fa-heart' ;
90+ break ;
91+ case HS . SUSPENDED :
92+ color = COLORS . health . suspended ;
93+ icon = 'fa-pause-circle' ;
94+ break ;
95+ case HS . DEGRADED :
96+ color = COLORS . health . degraded ;
97+ icon = 'fa-heart-broken' ;
98+ break ;
99+ case HS . PROGRESSING :
100+ color = COLORS . health . progressing ;
101+ icon = `fa fa-circle-notch fa-spin` ;
102+ break ;
103+ case HS . MISSING :
104+ color = COLORS . health . missing ;
105+ icon = 'fa-ghost' ;
106+ break ;
107+ }
108+ return icon . includes ( 'fa-spin' ) ? (
109+ < SpinningIcon color = { color } title = { status } />
110+ ) : (
111+ < i title = { status } className = { 'fa ' + icon + ' utils-health-status-icon' } style = { { color } } />
112+ ) ;
113+ } ;
114+
67115export default HealthStatus ;
0 commit comments