/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/capacityAlerts.ts
43 строки
1 KB
Anton Standrik
feat(storage): add blob storage capacity metrics (#4167)
05 авг 2026, 17:41
Не верифицирован
05 авг 2026, 17:41
2881245
Код
Авторство
О чём код?
import type {LabelProps} from '@gravity-ui/uikit'; import type {ECapacityAlert} from '../types/api/enums'; import {DATA_SEVERITY} from './disks/constants'; import type {DataSeverity} from './disks/types'; const SEVERITY_TO_THEME: Record<DataSeverity, LabelProps['theme']> = { 0: 'normal', // DATA_SEVERITY.GREY 1: 'success', // DATA_SEVERITY.GREEN 2: 'info', // DATA_SEVERITY.BLUE 3: 'warning', // DATA_SEVERITY.YELLOW 4: 'danger', // DATA_SEVERITY.ORANGE 5: 'danger', // DATA_SEVERITY.RED }; export function normalizeCapacityAlert(value: unknown): string | undefined { return typeof value === 'string' && value.trim() ? value : undefined; } export function getCapacityAlertSeverity(capacityAlert?: ECapacityAlert): DataSeverity { switch (capacityAlert) { case 'GREEN': case 'CYAN': return DATA_SEVERITY.GREEN; case 'LIGHT_YELLOW': return DATA_SEVERITY.YELLOW; case 'YELLOW': case 'LIGHT_ORANGE': case 'PRE_ORANGE': case 'ORANGE': case 'RED': case 'BLACK': return DATA_SEVERITY.RED; default: return DATA_SEVERITY.GREY; } } export function getCapacityAlertTheme(capacityAlert?: ECapacityAlert): LabelProps['theme'] { const severity = getCapacityAlertSeverity(capacityAlert); return SEVERITY_TO_THEME[severity]; }