import {Text} from '@gravity-ui/uikit'; import {isNil} from 'lodash'; import {CellWithPopover} from '../../components/CellWithPopover/CellWithPopover'; import {CopyableValue} from '../../components/CopyableValue/CopyableValue'; import {InternalLinkButton} from '../../components/InternalLinkButton'; import {getVDiskLocationItems} from '../../components/VDiskInfo/getVDiskDetails'; import {getPDiskPagePath} from '../../routes'; import {useNewStorageViewEnabled} from '../../store/reducers/capabilities/hooks'; import type {VDiskData} from '../../store/reducers/vdisk/types'; import {cn} from '../../utils/cn'; import type {DiskDetailItem} from '../../utils/disks/diskInfo/getDiskLocationItems'; import {useIsViewerUser} from '../../utils/hooks/useIsUserAllowedToMakeChanges'; import {vDiskPageKeyset} from './i18n'; import './VDiskStorageDetails.scss'; const b = cn('ydb-vdisk-storage-details'); const LOCATION_IDS = ['datacenter', 'rack', 'fqdn', 'pdisk-path']; interface VDiskStorageDetailsProps { className?: string; data?: VDiskData; } function DetailItem({item}: {item: DiskDetailItem}) { const copyText = item.copyText === undefined ? undefined : String(item.copyText); return (
{item.name} {item.content}
); } export function VDiskStorageDetails({className, data = {}}: VDiskStorageDetailsProps) { const isViewerUser = useIsViewerUser(); const newStorageViewEnabled = useNewStorageViewEnabled(); const pDiskPath = isViewerUser && !isNil(data.NodeId) && !isNil(data.PDiskId) ? getPDiskPagePath(data.PDiskId, data.NodeId) : undefined; const items = getVDiskLocationItems(data, { Host: data.NodeHost, Rack: data.NodeRack, DC: data.NodeDC, }).filter(({id}) => newStorageViewEnabled || (id !== 'rack' && id !== 'pdisk-path')); return (
{LOCATION_IDS.map((id) => { const item = items.find((entry) => entry.id === id); return item ? : null; })}
{items .filter(({id}) => !LOCATION_IDS.includes(id)) .map((item) => ( ))} {pDiskPath && ( {vDiskPageKeyset('action_go-to-pdisk')} )}
); }