11import React from 'react' ;
22
3+ import { Tab , TabList , TabProvider } from '@gravity-ui/uikit' ;
4+
35import { InfoViewer } from '../../../../../components/InfoViewer/InfoViewer' ;
46import { LabelWithPopover } from '../../../../../components/LabelWithPopover' ;
57import { ProgressViewer } from '../../../../../components/ProgressViewer/ProgressViewer' ;
8+ import { TENANT_STORAGE_TABS_IDS } from '../../../../../store/reducers/tenant/constants' ;
9+ import { cn } from '../../../../../utils/cn' ;
610import { formatStorageValues } from '../../../../../utils/dataFormatters/dataFormatters' ;
711import { TenantDashboard } from '../TenantDashboard/TenantDashboard' ;
812import i18n from '../i18n' ;
9- import { b } from '../utils' ;
1013
1114import { TopGroups } from './TopGroups' ;
1215import { TopTables } from './TopTables' ;
1316import { storageDashboardConfig } from './storageDashboardConfig' ;
17+ import { useTenantStorageQueryParams } from './useTenantStorageQueryParams' ;
18+
19+ import './TenantStorage.scss' ;
1420
15- import '../TenantOverview.scss' ;
21+ const tenantStorageCn = cn ( 'tenant-storage' ) ;
22+
23+ const storageTabs = [
24+ { id : TENANT_STORAGE_TABS_IDS . tables , title : i18n ( 'title_top-tables-by-size' ) } ,
25+ { id : TENANT_STORAGE_TABS_IDS . groups , title : i18n ( 'title_top-groups-by-usage' ) } ,
26+ ] ;
1627
1728export interface TenantStorageMetrics {
1829 blobStorageUsed ?: number ;
@@ -27,8 +38,21 @@ interface TenantStorageProps {
2738}
2839
2940export function TenantStorage ( { tenantName, metrics} : TenantStorageProps ) {
41+ const { storageTab, handleStorageTabChange} = useTenantStorageQueryParams ( ) ;
42+
3043 const { blobStorageUsed, tabletStorageUsed, blobStorageLimit, tabletStorageLimit} = metrics ;
3144
45+ const renderTabContent = ( ) => {
46+ switch ( storageTab ) {
47+ case TENANT_STORAGE_TABS_IDS . tables :
48+ return < TopTables database = { tenantName } /> ;
49+ case TENANT_STORAGE_TABS_IDS . groups :
50+ return < TopGroups tenant = { tenantName } /> ;
51+ default :
52+ return null ;
53+ }
54+ } ;
55+
3256 const info = [
3357 {
3458 label : (
@@ -43,6 +67,7 @@ export function TenantStorage({tenantName, metrics}: TenantStorageProps) {
4367 capacity = { tabletStorageLimit }
4468 formatValues = { formatStorageValues }
4569 colorizeProgress = { true }
70+ size = "storage"
4671 />
4772 ) ,
4873 } ,
@@ -59,6 +84,7 @@ export function TenantStorage({tenantName, metrics}: TenantStorageProps) {
5984 capacity = { blobStorageLimit }
6085 formatValues = { formatStorageValues }
6186 colorizeProgress = { true }
87+ size = "storage"
6288 />
6389 ) ,
6490 } ,
@@ -67,9 +93,27 @@ export function TenantStorage({tenantName, metrics}: TenantStorageProps) {
6793 return (
6894 < React . Fragment >
6995 < TenantDashboard database = { tenantName } charts = { storageDashboardConfig } />
70- < InfoViewer className = { b ( 'storage-info' ) } title = "Storage details" info = { info } />
71- < TopTables database = { tenantName } />
72- < TopGroups tenant = { tenantName } />
96+ < InfoViewer
97+ variant = "storage"
98+ title = { i18n ( 'storage.storage-details-title' ) }
99+ info = { info }
100+ />
101+
102+ < div className = { tenantStorageCn ( 'tabs-container' ) } >
103+ < TabProvider value = { storageTab } >
104+ < TabList size = "m" >
105+ { storageTabs . map ( ( { id, title} ) => {
106+ return (
107+ < Tab key = { id } value = { id } onClick = { ( ) => handleStorageTabChange ( id ) } >
108+ { title }
109+ </ Tab >
110+ ) ;
111+ } ) }
112+ </ TabList >
113+ </ TabProvider >
114+
115+ < div className = { tenantStorageCn ( 'tab-content' ) } > { renderTabContent ( ) } </ div >
116+ </ div >
73117 </ React . Fragment >
74118 ) ;
75119}
0 commit comments