11import React from 'react' ;
22
3- import { useTable } from '@gravity-ui/table' ;
3+ import type { Column } from '@gravity-ui/react-data-table' ;
4+ import DataTable from '@gravity-ui/react-data-table' ;
45import { skipToken } from '@reduxjs/toolkit/query' ;
5- import type { SortingState } from '@tanstack/react-table' ;
66
77import { InfoViewerSkeleton } from '../../../components/InfoViewerSkeleton/InfoViewerSkeleton' ;
8- import { Table } from '../../../components/Table/Table ' ;
8+ import { ResizeableDataTable } from '../../../components/ResizeableDataTable/ResizeableDataTable ' ;
99import { vDiskApi } from '../../../store/reducers/vdisk/vdisk' ;
1010import type { VDiskBlobIndexItem } from '../../../types/api/vdiskBlobIndex' ;
1111import { cn } from '../../../utils/cn' ;
1212import { useAutoRefreshInterval } from '../../../utils/hooks' ;
1313
1414import { getColumns } from './columns' ;
15+ import { vDiskPageKeyset } from '../i18n' ;
1516
1617import './VDiskTablets.scss' ;
1718
1819const vDiskTabletsCn = cn ( 'ydb-vdisk-tablets' ) ;
20+ const VDISK_TABLETS_COLUMNS_WIDTH_LS_KEY = 'vdiskTabletsColumnsWidth' ;
21+
22+ const TABLE_SETTINGS = {
23+ displayIndices : false ,
24+ highlightRows : true ,
25+ stickyHead : DataTable . MOVING ,
26+ } ;
1927
2028interface VDiskTabletsProps {
2129 nodeId ?: string | number ;
@@ -26,9 +34,6 @@ interface VDiskTabletsProps {
2634
2735export function VDiskTablets ( { nodeId, pDiskId, vDiskSlotId, className} : VDiskTabletsProps ) {
2836 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
29- const [ sorting , setSorting ] = React . useState < SortingState > ( [
30- { id : 'Size' , desc : true } , // Default sort by size descending
31- ] ) ;
3237
3338 const params = nodeId && pDiskId && vDiskSlotId ? { nodeId, pDiskId, vDiskSlotId} : skipToken ;
3439
@@ -38,19 +43,14 @@ export function VDiskTablets({nodeId, pDiskId, vDiskSlotId, className}: VDiskTab
3843
3944 const loading = isFetching && currentData === undefined ;
4045
41- // Remove the manual sorting since we'll let the table handle it with enableSorting
4246 const tableData : VDiskBlobIndexItem [ ] = React . useMemo ( ( ) => {
4347 if ( ! currentData ) {
4448 return [ ] ;
4549 }
4650
47- // Debug: Log the actual response structure
48- console . info ( 'VDisk BlobIndexStat Response:' , currentData ) ;
49-
5051 // Check if we have the expected structure: {stat: {tablets: [...]}}
5152 const stat = currentData . stat ;
5253 if ( ! stat || ! Array . isArray ( stat . tablets ) ) {
53- console . info ( 'No stat.tablets array found in response' ) ;
5454 return [ ] ;
5555 }
5656
@@ -76,24 +76,11 @@ export function VDiskTablets({nodeId, pDiskId, vDiskSlotId, className}: VDiskTab
7676 } ) ;
7777 } ) ;
7878
79- console . info ( 'Transformed data:' , flatData ) ;
8079 return flatData ;
8180 } , [ currentData ] ) ;
8281
8382 const columns = React . useMemo ( ( ) => getColumns ( ) , [ ] ) ;
8483
85- const table = useTable ( {
86- columns,
87- data : tableData ,
88- enableSorting : true ,
89- enableColumnResizing : true ,
90- columnResizeMode : 'onChange' ,
91- onSortingChange : setSorting ,
92- state : {
93- sorting,
94- } ,
95- } ) ;
96-
9784 if ( error ) {
9885 return (
9986 < div className = { vDiskTabletsCn ( 'error' , className ) } >
@@ -108,7 +95,17 @@ export function VDiskTablets({nodeId, pDiskId, vDiskSlotId, className}: VDiskTab
10895
10996 return (
11097 < div className = { vDiskTabletsCn ( null , className ) } >
111- < Table table = { table } stickyHeader width = "max" />
98+ < ResizeableDataTable
99+ columnsWidthLSKey = { VDISK_TABLETS_COLUMNS_WIDTH_LS_KEY }
100+ data = { tableData }
101+ columns = { columns }
102+ settings = { TABLE_SETTINGS }
103+ loading = { loading }
104+ initialSortOrder = { {
105+ columnId : vDiskPageKeyset ( 'size' ) ,
106+ order : DataTable . DESCENDING ,
107+ } }
108+ />
112109 </ div >
113110 ) ;
114111}
0 commit comments