Skip to content

Commit 2d28a2a

Browse files
fix(SchemaOverview): display entity name
1 parent 2ee7889 commit 2d28a2a

File tree

3 files changed

+54
-31
lines changed

3 files changed

+54
-31
lines changed

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
PersQueueGroupInfo,
1313
} from '../../../../components/InfoViewer/schemaInfo';
1414

15-
import {EPathType, TColumnTableDescription} from '../../../../types/api/schema';
15+
import {
16+
EPathType,
17+
TEvDescribeSchemeResult,
18+
} from '../../../../types/api/schema';
1619
import {
1720
isEntityWithMergedImplementation,
1821
isColumnEntityType,
@@ -34,8 +37,9 @@ import {useAutofetcher, useTypedSelector} from '../../../../utils/hooks';
3437

3538
import './Overview.scss';
3639

37-
function prepareOlapTableGeneral(tableData: TColumnTableDescription = {}, olapStats?: any[]) {
38-
const {ColumnShardCount} = tableData;
40+
function prepareOlapTableGeneral(item?: TEvDescribeSchemeResult, olapStats?: any[]) {
41+
const tableData = item?.PathDescription?.ColumnTableDescription;
42+
3943
const Bytes = olapStats?.reduce((acc, el) => {
4044
acc += parseInt(el.Bytes) || 0;
4145
return acc;
@@ -51,8 +55,9 @@ function prepareOlapTableGeneral(tableData: TColumnTableDescription = {}, olapSt
5155

5256
return {
5357
PathDescription: {
58+
Self: item?.PathDescription?.Self,
5459
TableStats: {
55-
ColumnShardCount,
60+
ColumnShardCount: tableData?.ColumnShardCount,
5661
Bytes: Bytes?.toLocaleString('ru-RU', {useGrouping: true}) ?? 0,
5762
Rows: Rows?.toLocaleString('ru-RU', {useGrouping: true}) ?? 0,
5863
Parts: tabletIds?.size ?? 0,
@@ -130,15 +135,12 @@ function Overview({type, tenantName, className}: OverviewProps) {
130135

131136
useAutofetcher(fetchData, [fetchData], autorefresh);
132137

133-
const tableSchema =
134-
currentItem?.PathDescription?.Table || currentItem?.PathDescription?.ColumnTableDescription;
135-
136138
const schemaData = useMemo(() => {
137139
return isTableType(type) && isColumnEntityType(type)
138140
? // process data for ColumnTable
139-
prepareOlapTableGeneral(tableSchema, olapStats)
141+
prepareOlapTableGeneral(currentItem, olapStats)
140142
: currentItem;
141-
}, [type, tableSchema, olapStats, currentItem]);
143+
}, [type, olapStats, currentItem]);
142144

143145
const renderLoader = () => {
144146
return (

src/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import cn from 'bem-cn-lite';
4-
import './SchemaInfoViewer.scss';
54

65
import {formatCPU, formatBytes, formatNumber, formatBps, formatDateTime} from '../../../../utils';
76

87
import {InfoViewer, createInfoFormatter} from '../../../../components/InfoViewer';
98

9+
import {getEntityName} from '../../utils';
10+
11+
import './SchemaInfoViewer.scss';
12+
1013
const b = cn('schema-info-viewer');
1114

1215
const formatTabletMetricsItem = createInfoFormatter({
@@ -68,6 +71,8 @@ class SchemaInfoViewer extends React.Component {
6871

6972
renderContent(data) {
7073
const {PathDescription = {}} = data;
74+
const entityName = getEntityName(PathDescription);
75+
7176
const {
7277
TableStats = {},
7378
TabletMetrics = {},
@@ -99,13 +104,15 @@ class SchemaInfoViewer extends React.Component {
99104
} = TableStats;
100105
const {FollowerGroups, FollowerCount, CrossDataCenterFollowerCount} = PartitionConfig;
101106

107+
const generalTableInfo = formatTableStats({
108+
PartCount,
109+
RowCount,
110+
DataSize,
111+
IndexSize,
112+
...restTableStats,
113+
});
114+
102115
const tableStatsInfo = [
103-
formatTableStats({
104-
PartCount,
105-
RowCount,
106-
DataSize,
107-
IndexSize,
108-
}),
109116
formatTableStats({
110117
LastAccessTime,
111118
LastUpdateTime,
@@ -125,7 +132,6 @@ class SchemaInfoViewer extends React.Component {
125132
RangeReads,
126133
RangeReadRows,
127134
}),
128-
formatTableStats(restTableStats),
129135
];
130136

131137
const tabletMetricsInfo = Object.keys(TabletMetrics).map((key) =>
@@ -151,36 +157,43 @@ class SchemaInfoViewer extends React.Component {
151157
);
152158
}
153159

154-
if ([tabletMetricsInfo, partitionConfigInfo, tableStatsInfo.flat()].flat().length === 0) {
155-
return <div className={b('item')}>Empty</div>;
160+
if (
161+
[generalTableInfo, tabletMetricsInfo, partitionConfigInfo, tableStatsInfo.flat()].flat()
162+
.length === 0
163+
) {
164+
return <div className={b('title')}>{entityName}</div>;
156165
}
157166

158167
return (
159-
<div className={b('row')}>
160-
{tabletMetricsInfo.length > 0 || partitionConfigInfo.length > 0 ? (
168+
<div>
169+
<div>{this.renderItem(generalTableInfo, entityName)}</div>
170+
<div className={b('row')}>
171+
{tabletMetricsInfo.length > 0 || partitionConfigInfo.length > 0 ? (
172+
<div className={b('col')}>
173+
{this.renderItem(tabletMetricsInfo, 'Tablet Metrics')}
174+
{this.renderItem(partitionConfigInfo, 'Partition Config')}
175+
</div>
176+
) : null}
161177
<div className={b('col')}>
162-
{this.renderItem(tabletMetricsInfo, 'Tablet Metrics')}
163-
{this.renderItem(partitionConfigInfo, 'Partition Config')}
178+
{tableStatsInfo.map((info, index) => (
179+
<React.Fragment key={index}>
180+
{this.renderItem(info, index === 0 ? 'Table Stats' : undefined)}
181+
</React.Fragment>
182+
))}
164183
</div>
165-
) : null}
166-
<div className={b('col')}>
167-
{tableStatsInfo.map((info, index) => (
168-
<React.Fragment key={index}>
169-
{this.renderItem(info, index === 0 ? 'Table Stats' : undefined)}
170-
</React.Fragment>
171-
))}
172184
</div>
173185
</div>
174186
);
175187
}
176188

177189
render() {
178190
const {data} = this.props;
191+
const entityName = getEntityName(data?.PathDescription);
179192

180193
if (data) {
181194
return <div className={b()}>{this.renderContent(data)}</div>;
182195
} else {
183-
return <div className="error">no schema data</div>;
196+
return <div className="error">No {entityName} data</div>;
184197
}
185198
}
186199
}

src/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@
2626
grid-template-columns: minmax(max-content, 280px);
2727
}
2828
}
29+
30+
&__title {
31+
margin: 15px 0 10px;
32+
33+
font-size: var(--yc-text-body-2-font-size);
34+
font-weight: 600;
35+
line-height: var(--yc-text-body-2-line-height);
36+
}
2937
}

0 commit comments

Comments
 (0)