11import React from 'react' ;
22
3- import type { Column } from '@gravity-ui/react-data-table' ;
43import DataTable from '@gravity-ui/react-data-table' ;
54import { skipToken } from '@reduxjs/toolkit/query' ;
65
6+ import { PageError } from '../../../components/Errors/PageError/PageError' ;
77import { InfoViewerSkeleton } from '../../../components/InfoViewerSkeleton/InfoViewerSkeleton' ;
88import { ResizeableDataTable } from '../../../components/ResizeableDataTable/ResizeableDataTable' ;
99import { vDiskApi } from '../../../store/reducers/vdisk/vdisk' ;
1010import type { VDiskBlobIndexItem } from '../../../types/api/vdiskBlobIndex' ;
11- import { cn } from '../../../utils/cn ' ;
11+ import { DEFAULT_TABLE_SETTINGS } from '../../../utils/constants ' ;
1212import { useAutoRefreshInterval } from '../../../utils/hooks' ;
13-
14- import { getColumns } from './columns' ;
13+ import { safeParseNumber } from '../../../utils/utils' ;
1514import { vDiskPageKeyset } from '../i18n' ;
1615
17- import './VDiskTablets.scss ' ;
16+ import { getColumns } from './columns ' ;
1817
19- const vDiskTabletsCn = cn ( 'ydb-vdisk-tablets' ) ;
2018const VDISK_TABLETS_COLUMNS_WIDTH_LS_KEY = 'vdiskTabletsColumnsWidth' ;
2119
22- const TABLE_SETTINGS = {
23- displayIndices : false ,
24- highlightRows : true ,
25- stickyHead : DataTable . MOVING ,
26- } ;
20+ const columns = getColumns ( ) ;
2721
2822interface VDiskTabletsProps {
2923 nodeId ?: string | number ;
@@ -57,20 +51,20 @@ export function VDiskTablets({nodeId, pDiskId, vDiskSlotId, className}: VDiskTab
5751 // Transform the nested structure into flat table rows
5852 const flatData : VDiskBlobIndexItem [ ] = [ ] ;
5953
60- stat . tablets . forEach ( ( tablet : any ) => {
54+ stat . tablets . forEach ( ( tablet ) => {
6155 const tabletId = tablet . tablet_id ;
6256 if ( ! tabletId || ! Array . isArray ( tablet . channels ) ) {
6357 return ; // Skip tablets without ID or channels
6458 }
6559
66- tablet . channels . forEach ( ( channel : any , channelIndex : number ) => {
60+ tablet . channels . forEach ( ( channel , channelIndex ) => {
6761 // Only include channels that have count and data_size
6862 if ( channel . count && channel . data_size ) {
6963 flatData . push ( {
7064 TabletId : tabletId ,
7165 ChannelId : channelIndex ,
72- Count : parseInt ( channel . count , 10 ) || 0 ,
73- Size : parseInt ( channel . data_size , 10 ) || 0 ,
66+ Count : safeParseNumber ( channel . count ) ,
67+ Size : safeParseNumber ( channel . data_size ) ,
7468 } ) ;
7569 }
7670 } ) ;
@@ -79,27 +73,21 @@ export function VDiskTablets({nodeId, pDiskId, vDiskSlotId, className}: VDiskTab
7973 return flatData ;
8074 } , [ currentData ] ) ;
8175
82- const columns = React . useMemo ( ( ) => getColumns ( ) , [ ] ) ;
83-
8476 if ( error ) {
85- return (
86- < div className = { vDiskTabletsCn ( 'error' , className ) } >
87- Error loading tablet statistics
88- </ div >
89- ) ;
77+ return < PageError error = { error } position = "left" size = "s" /> ;
9078 }
9179
9280 if ( loading ) {
9381 return < InfoViewerSkeleton rows = { 5 } /> ;
9482 }
9583
9684 return (
97- < div className = { vDiskTabletsCn ( null , className ) } >
85+ < div className = { className } >
9886 < ResizeableDataTable
9987 columnsWidthLSKey = { VDISK_TABLETS_COLUMNS_WIDTH_LS_KEY }
10088 data = { tableData }
10189 columns = { columns }
102- settings = { TABLE_SETTINGS }
90+ settings = { DEFAULT_TABLE_SETTINGS }
10391 loading = { loading }
10492 initialSortOrder = { {
10593 columnId : vDiskPageKeyset ( 'size' ) ,
0 commit comments