11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33import cn from 'bem-cn-lite' ;
4- import './SchemaInfoViewer.scss' ;
54
65import { formatCPU , formatBytes , formatNumber , formatBps , formatDateTime } from '../../../../utils' ;
76
87import { InfoViewer , createInfoFormatter } from '../../../../components/InfoViewer' ;
98
9+ import { getEntityName } from '../../utils' ;
10+
11+ import './SchemaInfoViewer.scss' ;
12+
1013const b = cn ( 'schema-info-viewer' ) ;
1114
1215const 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}
0 commit comments