@@ -8,14 +8,15 @@ import {InfoViewer} from '../../../../components/InfoViewer';
8
8
import { PoolUsage } from '../../../../components/PoolUsage/PoolUsage' ;
9
9
import { Tablet } from '../../../../components/Tablet' ;
10
10
import EntityStatus from '../../../../components/EntityStatus/EntityStatus' ;
11
- import type { TTenant } from '../../../../types/api/tenant' ;
12
11
import { formatCPU } from '../../../../utils' ;
13
12
import { TABLET_STATES , TENANT_DEFAULT_TITLE } from '../../../../utils/constants' ;
14
13
import { bytesToGB } from '../../../../utils/utils' ;
15
14
import { mapDatabaseTypeToDBName } from '../../utils/schema' ;
16
15
import { useAutofetcher , useTypedSelector } from '../../../../utils/hooks' ;
16
+ import { ETabletVolatileState } from '../../../../types/api/tenant' ;
17
17
import { getTenantInfo , setDataWasNotLoaded } from '../../../../store/reducers/tenant/tenant' ;
18
18
19
+ import i18n from './i18n' ;
19
20
import './TenantOverview.scss' ;
20
21
21
22
const b = cn ( 'tenant-overview' ) ;
@@ -39,20 +40,15 @@ export function TenantOverview({tenantName, additionalTenantInfo}: TenantOvervie
39
40
[ dispatch , tenantName ] ,
40
41
) ;
41
42
42
- useAutofetcher (
43
- ( isBackground ) => {
44
- fetchTenant ( isBackground ) ;
45
- } ,
46
- [ fetchTenant ] ,
47
- autorefresh ,
48
- ) ;
43
+ useAutofetcher ( fetchTenant , [ fetchTenant ] , autorefresh ) ;
49
44
50
45
const {
51
46
Metrics = { } ,
52
47
PoolStats,
53
48
StateStats = [ ] ,
54
49
MemoryUsed,
55
50
Name,
51
+ State,
56
52
CoresUsed,
57
53
StorageGroups,
58
54
StorageAllocatedSize,
@@ -63,14 +59,15 @@ export function TenantOverview({tenantName, additionalTenantInfo}: TenantOvervie
63
59
const tenantType = mapDatabaseTypeToDBName ( Type ) ;
64
60
const memoryRaw = MemoryUsed ?? Metrics . Memory ;
65
61
66
- const memory = ( memoryRaw && bytesToGB ( memoryRaw ) ) || 'no data' ;
67
- const storage = ( Metrics . Storage && bytesToGB ( Metrics . Storage ) ) || 'no data' ;
68
- const storageGroups = StorageGroups ?? 'no data' ;
69
- const blobStorage = ( StorageAllocatedSize && bytesToGB ( StorageAllocatedSize ) ) || 'no data' ;
62
+ const memory = ( memoryRaw && bytesToGB ( memoryRaw ) ) || i18n ( 'no-data' ) ;
63
+ const storage = ( Metrics . Storage && bytesToGB ( Metrics . Storage ) ) || i18n ( 'no-data' ) ;
64
+ const storageGroups = StorageGroups ?? i18n ( 'no-data' ) ;
65
+ const blobStorage =
66
+ ( StorageAllocatedSize && bytesToGB ( StorageAllocatedSize ) ) || i18n ( 'no-data' ) ;
70
67
const storageEfficiency =
71
68
Metrics . Storage && StorageAllocatedSize
72
69
? `${ ( ( parseInt ( Metrics . Storage ) * 100 ) / parseInt ( StorageAllocatedSize ) ) . toFixed ( 2 ) } %`
73
- : 'no data' ;
70
+ : i18n ( 'no- data' ) ;
74
71
75
72
const cpuRaw = CoresUsed !== undefined ? Number ( CoresUsed ) * 1_000_000 : Metrics . CPU ;
76
73
@@ -86,21 +83,22 @@ export function TenantOverview({tenantName, additionalTenantInfo}: TenantOvervie
86
83
{ label : 'Storage efficiency' , value : storageEfficiency } ,
87
84
] ;
88
85
89
- const tabletsInfo = StateStats . map ( ( info ) => {
90
- if ( info . VolatileState )
91
- return { label : TABLET_STATES [ info . VolatileState ] , value : info . Count } ;
92
- return { } ;
86
+ const tabletsInfo = StateStats . filter (
87
+ ( item ) : item is { VolatileState : ETabletVolatileState ; Count : number } => {
88
+ return item . VolatileState !== undefined && item . Count !== undefined ;
89
+ } ,
90
+ ) . map ( ( info ) => {
91
+ return { label : TABLET_STATES [ info . VolatileState ] , value : info . Count } ;
93
92
} ) ;
94
93
95
- const renderName = ( tenant ?: TTenant ) => {
96
- const { Name = TENANT_DEFAULT_TITLE , State} = tenant || { } ;
94
+ const renderName = ( ) => {
97
95
return (
98
96
< div className = { b ( 'tenant-name-wrapper' ) } >
99
97
< EntityStatus
100
98
status = { State }
101
- name = { Name }
99
+ name = { Name || TENANT_DEFAULT_TITLE }
102
100
withLeftTrim
103
- hasClipboardButton = { tenant }
101
+ hasClipboardButton = { ! ! tenant }
104
102
clipboardButtonAlwaysVisible
105
103
/>
106
104
</ div >
@@ -119,7 +117,7 @@ export function TenantOverview({tenantName, additionalTenantInfo}: TenantOvervie
119
117
< div className = { b ( ) } >
120
118
< div className = { b ( 'top-label' ) } > { tenantType } </ div >
121
119
< div className = { b ( 'top' ) } >
122
- { renderName ( tenant ) }
120
+ { renderName ( ) }
123
121
{ tenant && additionalTenantInfo && additionalTenantInfo ( tenant . Name , tenant . Type ) }
124
122
</ div >
125
123
< div className = { b ( 'system-tablets' ) } >
@@ -130,19 +128,19 @@ export function TenantOverview({tenantName, additionalTenantInfo}: TenantOvervie
130
128
</ div >
131
129
< div className = { b ( 'common-info' ) } >
132
130
< div >
133
- < div className = { b ( 'section-title' ) } > Pools </ div >
131
+ < div className = { b ( 'section-title' ) } > { i18n ( 'title.pools' ) } </ div >
134
132
{ PoolStats ? (
135
133
< div className = { b ( 'section' , { pools : true } ) } >
136
134
{ PoolStats . map ( ( pool , poolIndex ) => (
137
135
< PoolUsage key = { poolIndex } data = { pool } />
138
136
) ) }
139
137
</ div >
140
138
) : (
141
- < div className = "error" > no pools data</ div >
139
+ < div className = "error" > { i18n ( 'no- pools- data' ) } </ div >
142
140
) }
143
141
</ div >
144
142
< InfoViewer
145
- title = "Metrics"
143
+ title = { i18n ( 'title.metrics' ) }
146
144
className = { b ( 'section' , { metrics : true } ) }
147
145
info = { metricsInfo }
148
146
/>
0 commit comments