-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhelpers.ts
43 lines (36 loc) · 1.27 KB
/
helpers.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {valueIsDefined} from '..';
import type {EFlag} from '../../types/api/enums';
import type {TVDiskStateInfo, TVSlotId} from '../../types/api/vdisk';
import {
DISK_COLOR_STATE_TO_NUMERIC_SEVERITY,
DISK_NUMERIC_SEVERITY_TO_STATE_COLOR,
NOT_AVAILABLE_SEVERITY_COLOR,
} from './constants';
import type {PreparedVDisk} from './types';
export function isFullVDiskData(
disk: PreparedVDisk | TVDiskStateInfo | TVSlotId,
): disk is PreparedVDisk | TVDiskStateInfo {
return 'VDiskId' in disk;
}
export function getSeverityColor(severity: number | undefined) {
if (severity === undefined) {
return NOT_AVAILABLE_SEVERITY_COLOR;
}
return DISK_NUMERIC_SEVERITY_TO_STATE_COLOR[severity] || NOT_AVAILABLE_SEVERITY_COLOR;
}
export function getColorSeverity(color?: EFlag) {
return color ? DISK_COLOR_STATE_TO_NUMERIC_SEVERITY[color] : 0;
}
export function getPDiskId(nodeId?: string | number | null, pDiskId?: string | number | null) {
if (valueIsDefined(nodeId) && valueIsDefined(pDiskId)) {
return `${nodeId}-${pDiskId}`;
}
return undefined;
}
export function getVDiskSlotBasedId(
nodeId: string | number,
pDiskId: string | number,
vDiskSlotId: string | number,
) {
return [nodeId, pDiskId, vDiskSlotId].join('-');
}