-
-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathinstance.ts
More file actions
28 lines (23 loc) · 902 Bytes
/
instance.ts
File metadata and controls
28 lines (23 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { StatusIndicatorProps } from '@cloudscape-design/components';
export const prettyEnumValue = (value: string): string => {
return value.replace(/_/g, ' ').replace(/^\w/, (c) => c.toUpperCase());
};
export const getHealthStatusIconType = (healthStatus: THealthStatus): StatusIndicatorProps['type'] => {
switch (healthStatus) {
case 'healthy':
return 'success';
case 'warning':
return 'warning';
case 'failure':
return 'error';
default:
return 'info';
}
};
export const formatInstanceStatusText = (instance: IInstance): string => {
const status = instance.status;
if ((status === 'idle' || status === 'busy') && instance.total_blocks !== null && instance.total_blocks > 1) {
return `${instance.busy_blocks}/${instance.total_blocks} Busy`;
}
return prettyEnumValue(status);
};