import React from 'react'; import type {LabelProps} from '@gravity-ui/uikit'; import {ActionTooltip, Flex, HelpMark, Label} from '@gravity-ui/uikit'; import {EFlag} from '../../types/api/enums'; import {cn} from '../../utils/cn'; import {StatusIcon} from '../StatusIconNew/StatusIcon'; import i18n from './i18n'; import {EFlagToDescription} from './utils'; import './EntityStatus.scss'; const b = cn('ydb-entity-status'); export const EFlagToLabelTheme: Record = { [EFlag.Red]: 'danger', [EFlag.Blue]: 'success', [EFlag.Green]: 'success', [EFlag.Grey]: 'unknown', [EFlag.Orange]: 'danger', [EFlag.Yellow]: 'warning', }; const EFlagToStatusName: Record = { get [EFlag.Red]() { return i18n('title_red'); }, get [EFlag.Yellow]() { return i18n('title_yellow'); }, get [EFlag.Orange]() { return i18n('title_orange'); }, get [EFlag.Green]() { return i18n('title_green'); }, get [EFlag.Grey]() { return i18n('title_grey'); }, get [EFlag.Blue]() { return i18n('title_blue'); }, }; interface EntityStatusLabelBaseProps { status: EFlag; className?: string; size?: LabelProps['size']; iconSize?: number; qa?: string; } interface DefaultEntityStatusLabelProps { view?: 'default'; note?: React.ReactNode; children?: React.ReactNode; endContent?: React.ReactNode; withStatusName?: boolean; onClick?: (event: React.MouseEvent) => void; } interface CompactEntityStatusLabelProps { view: 'compact'; note?: never; children?: never; endContent?: never; withStatusName?: never; onClick?: never; } type EntityStatusLabelProps = EntityStatusLabelBaseProps & (DefaultEntityStatusLabelProps | CompactEntityStatusLabelProps); function EntityStatusLabel({ children, className, endContent, status, withStatusName = true, view = 'default', note, size = 'm', iconSize = 14, onClick, qa, }: EntityStatusLabelProps) { if (view === 'compact') { const statusName = EFlagToStatusName[status]; return ( ); } const theme = EFlagToLabelTheme[status]; const isClickable = Boolean(onClick); return ( ); } interface EntityStatusProps { children?: React.ReactNode; className?: string; } export function EntityStatus({className, children}: EntityStatusProps) { return ( {children} ); } EntityStatus.Label = EntityStatusLabel; EntityStatus.displayName = 'EntityStatus';