Skip to content

Commit 82bf170

Browse files
committed
fix: small sixes
1 parent d5905f0 commit 82bf170

File tree

4 files changed

+34
-42
lines changed

4 files changed

+34
-42
lines changed

src/containers/VDiskPage/VDiskPage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
}
3131

3232
&__tablets-content {
33-
margin-top: 16px;
33+
margin-top: var(--g-spacing-4);
3434
}
3535
}
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
.ydb-vdisk-tablets {
2-
&__error {
3-
padding: 16px;
4-
5-
text-align: center;
6-
7-
color: var(--g-color-text-danger);
8-
}
9-
}

src/containers/VDiskPage/VDiskTablets/VDiskTablets.tsx

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
import React from 'react';
22

3-
import type {Column} from '@gravity-ui/react-data-table';
43
import DataTable from '@gravity-ui/react-data-table';
54
import {skipToken} from '@reduxjs/toolkit/query';
65

6+
import {PageError} from '../../../components/Errors/PageError/PageError';
77
import {InfoViewerSkeleton} from '../../../components/InfoViewerSkeleton/InfoViewerSkeleton';
88
import {ResizeableDataTable} from '../../../components/ResizeableDataTable/ResizeableDataTable';
99
import {vDiskApi} from '../../../store/reducers/vdisk/vdisk';
1010
import type {VDiskBlobIndexItem} from '../../../types/api/vdiskBlobIndex';
11-
import {cn} from '../../../utils/cn';
11+
import {DEFAULT_TABLE_SETTINGS} from '../../../utils/constants';
1212
import {useAutoRefreshInterval} from '../../../utils/hooks';
13-
14-
import {getColumns} from './columns';
13+
import {safeParseNumber} from '../../../utils/utils';
1514
import {vDiskPageKeyset} from '../i18n';
1615

17-
import './VDiskTablets.scss';
16+
import {getColumns} from './columns';
1817

19-
const vDiskTabletsCn = cn('ydb-vdisk-tablets');
2018
const 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

2822
interface 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'),

src/containers/VDiskPage/VDiskTablets/columns.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import type {Column} from '@gravity-ui/react-data-table';
22
import DataTable from '@gravity-ui/react-data-table';
3+
import {isNil} from 'lodash';
34

45
import {InternalLink} from '../../../components/InternalLink/InternalLink';
56
import {getTabletPagePath} from '../../../routes';
67
import type {VDiskBlobIndexItem} from '../../../types/api/vdiskBlobIndex';
7-
import {formatBytes} from '../../../utils/dataFormatters/dataFormatters';
8+
import {EMPTY_DATA_PLACEHOLDER} from '../../../utils/constants';
9+
import {formatBytes, formatNumber} from '../../../utils/dataFormatters/dataFormatters';
10+
import {safeParseNumber} from '../../../utils/utils';
811
import {vDiskPageKeyset} from '../i18n';
912

1013
export function getColumns(): Column<VDiskBlobIndexItem>[] {
@@ -14,30 +17,40 @@ export function getColumns(): Column<VDiskBlobIndexItem>[] {
1417
render: ({row}) => {
1518
const tabletId = row.TabletId;
1619
if (!tabletId) {
17-
return <span>-</span>;
20+
return EMPTY_DATA_PLACEHOLDER;
1821
}
19-
return <InternalLink to={getTabletPagePath(String(tabletId))}>{tabletId}</InternalLink>;
22+
return (
23+
<InternalLink to={getTabletPagePath(String(tabletId))}>{tabletId}</InternalLink>
24+
);
2025
},
21-
width: 150,
26+
width: 220,
2227
},
2328
{
2429
name: vDiskPageKeyset('channel-id'),
2530
align: DataTable.RIGHT,
26-
render: ({row}) => row.ChannelId ?? '-',
27-
width: 100,
31+
render: ({row}) => row.ChannelId ?? EMPTY_DATA_PLACEHOLDER,
32+
width: 130,
2833
},
2934
{
3035
name: vDiskPageKeyset('count'),
3136
align: DataTable.RIGHT,
32-
render: ({row}) => row.Count ?? '-',
37+
render: ({row}) => {
38+
if (isNil(row.Count)) {
39+
return EMPTY_DATA_PLACEHOLDER;
40+
}
41+
return formatNumber(row.Count);
42+
},
3343
width: 100,
3444
},
3545
{
3646
name: vDiskPageKeyset('size'),
3747
align: DataTable.RIGHT,
3848
render: ({row}) => {
3949
const size = row.Size;
40-
const numericSize = Number(size) || 0;
50+
if (isNil(size)) {
51+
return EMPTY_DATA_PLACEHOLDER;
52+
}
53+
const numericSize = safeParseNumber(size);
4154
return formatBytes(numericSize);
4255
},
4356
width: 120,

0 commit comments

Comments
 (0)