|
1 | 1 | import { Icon, IconName } from '../icon/Icon.component';
|
2 |
| - |
3 | 2 | import {
|
4 | 3 | STATUS_WARNING,
|
5 | 4 | STATUS_CRITICAL,
|
6 |
| - STATUS_HEALTH, |
7 |
| -} from '../tablev2/TableUtils'; |
| 5 | + STATUS_HEALTHY, |
| 6 | +} from '../../components/constants'; |
| 7 | +import { CoreUITheme } from '../../style/theme'; |
| 8 | +import { Loader } from '../loader/Loader.component'; |
8 | 9 |
|
9 |
| -export enum StatusCluster { |
| 10 | +export enum Status { |
10 | 11 | HEALTHY = 'healthy',
|
11 | 12 | WARNING = 'warning',
|
12 | 13 | CRITICAL = 'critical',
|
13 | 14 | UNKNOWN = 'unknown',
|
| 15 | + LOADING = 'loading', |
14 | 16 | }
|
15 | 17 |
|
16 |
| -export const StatusIcon = ({ status }: { status: StatusCluster }) => { |
17 |
| - const icon: { status: string; name: IconName } = (() => { |
18 |
| - switch (status) { |
19 |
| - case STATUS_HEALTH: |
20 |
| - return { status: 'statusHealthy', name: 'Check-circle' }; |
21 |
| - |
22 |
| - case STATUS_WARNING: |
23 |
| - return { status: 'statusWarning', name: 'Times-circle' }; |
| 18 | +export const StatusIcon = ({ status }: { status: Status }) => { |
| 19 | + if (status === 'loading') { |
| 20 | + return <Loader />; |
| 21 | + } |
| 22 | + const icon: { color: keyof CoreUITheme; name: IconName; label: string } = |
| 23 | + (() => { |
| 24 | + switch (status) { |
| 25 | + case STATUS_HEALTHY: |
| 26 | + return { |
| 27 | + color: 'statusHealthy', |
| 28 | + name: 'Check-circle', |
| 29 | + label: 'Healthy', |
| 30 | + }; |
24 | 31 |
|
25 |
| - case STATUS_CRITICAL: |
26 |
| - return { status: 'statusCritical', name: 'Times-circle' }; |
| 32 | + case STATUS_WARNING: |
| 33 | + return { |
| 34 | + color: 'statusWarning', |
| 35 | + name: 'Times-circle', |
| 36 | + label: 'Warning', |
| 37 | + }; |
27 | 38 |
|
28 |
| - default: |
29 |
| - return { status: 'textTertiary', name: 'Info' }; |
30 |
| - } |
31 |
| - })(); |
| 39 | + case STATUS_CRITICAL: |
| 40 | + return { |
| 41 | + color: 'statusCritical', |
| 42 | + name: 'Times-circle', |
| 43 | + label: 'Critical', |
| 44 | + }; |
| 45 | + default: |
| 46 | + return { color: 'textTertiary', name: 'Info', label: 'Info' }; |
| 47 | + } |
| 48 | + })(); |
32 | 49 |
|
33 |
| - return <Icon color={icon.status} name={icon.name} />; |
| 50 | + return <Icon color={icon.color} name={icon.name} />; |
34 | 51 | };
|
0 commit comments