import {ActionTooltip, ArrowToggle, Button, Flex} from '@gravity-ui/uikit'; import type {CellContext, ColumnDef, Row} from '@tanstack/react-table'; import {ColumnHeader} from '../../../../components/Table/Table'; import {formatTimestamp} from '../../../../utils/dataFormatters/dataFormatters'; import {tabletInfoKeyset} from './i18n'; import {b} from './shared'; import type {TabletStorageItem} from './types'; function metricsCell( info: CellContext, formatter?: (value: string | number) => string | number, ) { const value = info.getValue(); const formattedValue = typeof formatter === 'function' ? formatter(value) : value; return
{formattedValue}
; } interface GroupIdCellProps { row: Row; name?: string; hasExpand?: boolean; } function GroupIdCell({row, name, hasExpand}: GroupIdCellProps) { const isExpandable = row.getCanExpand(); const isExpanded = row.getIsExpanded(); const toggleTitle = isExpanded ? tabletInfoKeyset('action_collapse') : tabletInfoKeyset('action_expand'); return ( {isExpandable && ( )}
{name}
); } export function getColumns(hasExpand?: boolean) { const columns: ColumnDef[] = [ { accessorKey: 'channelIndex', header: () => {tabletInfoKeyset('label_channel-index')}, size: 50, cell: metricsCell, meta: {align: 'right'}, }, { accessorKey: 'storagePoolName', header: () => {tabletInfoKeyset('label_storage-pool')}, size: 200, cell: metricsCell, }, { accessorKey: 'GroupID', header: () => ( {tabletInfoKeyset('label_group-id')} ), size: 100, cell: (info) => ( ()} hasExpand={hasExpand} /> ), }, { accessorKey: 'FromGeneration', header: () => {tabletInfoKeyset('label_generation')}, size: 100, cell: metricsCell, meta: {align: 'right'}, }, { accessorKey: 'Timestamp', header: () => {tabletInfoKeyset('label_timestamp')}, size: 200, cell: (info) => metricsCell(info, formatTimestamp), meta: {align: 'right'}, }, ]; return columns; }