@@ -2,6 +2,11 @@ import {Flex} from '@gravity-ui/uikit';
22import { Link , useLocation } from 'react-router-dom' ;
33
44import { parseQuery } from '../../../../../routes' ;
5+ import {
6+ useCapabilitiesLoaded ,
7+ useStorageGroupsHandlerAvailable ,
8+ } from '../../../../../store/reducers/capabilities/hooks' ;
9+ import { storageApi } from '../../../../../store/reducers/storage/storage' ;
510import { TENANT_METRICS_TABS_IDS } from '../../../../../store/reducers/tenant/constants' ;
611import type { TenantMetricsTab } from '../../../../../store/reducers/tenant/types' ;
712import type {
@@ -11,7 +16,7 @@ import type {
1116} from '../../../../../store/reducers/tenants/utils' ;
1217import { cn } from '../../../../../utils/cn' ;
1318import { SHOW_NETWORK_UTILIZATION } from '../../../../../utils/constants' ;
14- import { useSetting , useTypedSelector } from '../../../../../utils/hooks' ;
19+ import { useAutoRefreshInterval , useSetting , useTypedSelector } from '../../../../../utils/hooks' ;
1520import { calculateMetricAggregates } from '../../../../../utils/metrics' ;
1621import {
1722 formatCoresLegend ,
@@ -27,6 +32,7 @@ import './MetricsTabs.scss';
2732const b = cn ( 'tenant-metrics-tabs' ) ;
2833
2934interface MetricsTabsProps {
35+ tenantName : string ;
3036 poolsCpuStats ?: TenantPoolsStats [ ] ;
3137 memoryStats ?: TenantMetricStats [ ] ;
3238 blobStorageStats ?: TenantStorageStats [ ] ;
@@ -35,6 +41,7 @@ interface MetricsTabsProps {
3541}
3642
3743export function MetricsTabs ( {
44+ tenantName,
3845 poolsCpuStats,
3946 memoryStats,
4047 blobStorageStats,
@@ -45,6 +52,25 @@ export function MetricsTabs({
4552 const { metricsTab} = useTypedSelector ( ( state ) => state . tenant ) ;
4653 const queryParams = parseQuery ( location ) ;
4754
55+ // Fetch storage groups data to get correct count (only if groups handler available)
56+ const capabilitiesLoaded = useCapabilitiesLoaded ( ) ;
57+ const groupsHandlerAvailable = useStorageGroupsHandlerAvailable ( ) ;
58+ const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
59+
60+ const { currentData : storageGroupsData } = storageApi . useGetStorageGroupsInfoQuery (
61+ {
62+ tenant : tenantName ,
63+ shouldUseGroupsHandler : groupsHandlerAvailable ,
64+ with : 'all' ,
65+ limit : 0 ,
66+ fieldsRequired : [ ] ,
67+ } ,
68+ {
69+ pollingInterval : autoRefreshInterval ,
70+ skip : ! capabilitiesLoaded || ! groupsHandlerAvailable ,
71+ } ,
72+ ) ;
73+
4874 const tabLinks : Record < TenantMetricsTab , string > = {
4975 [ TENANT_METRICS_TABS_IDS . cpu ] : getTenantPath ( {
5076 ...queryParams ,
@@ -73,7 +99,9 @@ export function MetricsTabs({
7399 // Calculate storage metrics using utility
74100 const storageStats = tabletStorageStats || blobStorageStats || [ ] ;
75101 const storageMetrics = calculateMetricAggregates ( storageStats ) ;
76- const storageGroupCount = storageStats . length ;
102+
103+ // Get correct storage groups count from API (only if groups handler available)
104+ const storageGroupCount = groupsHandlerAvailable ? ( storageGroupsData ?. total ?? 0 ) : undefined ;
77105
78106 // Calculate memory metrics using utility
79107 const memoryMetrics = calculateMetricAggregates ( memoryStats ) ;
@@ -91,8 +119,7 @@ export function MetricsTabs({
91119 >
92120 < Link to = { tabLinks . cpu } className = { b ( 'link' ) } >
93121 < TabCard
94- label = { i18n ( 'cards.cpu-label' ) }
95- sublabel = { i18n ( 'context_cpu-load' ) }
122+ text = { i18n ( 'context_cpu-load' ) }
96123 value = { cpuMetrics . totalUsed }
97124 limit = { cpuMetrics . totalLimit }
98125 legendFormatter = { formatCoresLegend }
@@ -108,8 +135,11 @@ export function MetricsTabs({
108135 >
109136 < Link to = { tabLinks . storage } className = { b ( 'link' ) } >
110137 < TabCard
111- label = { i18n ( 'cards.storage-label' ) }
112- sublabel = { i18n ( 'context_storage-groups' , { count : storageGroupCount } ) }
138+ text = {
139+ storageGroupCount === undefined
140+ ? i18n ( 'cards.storage-label' )
141+ : i18n ( 'context_storage-groups' , { count : storageGroupCount } )
142+ }
113143 value = { storageMetrics . totalUsed }
114144 limit = { storageMetrics . totalLimit }
115145 legendFormatter = { formatStorageLegend }
@@ -125,8 +155,7 @@ export function MetricsTabs({
125155 >
126156 < Link to = { tabLinks . memory } className = { b ( 'link' ) } >
127157 < TabCard
128- label = { i18n ( 'cards.memory-label' ) }
129- sublabel = { i18n ( 'context_memory-used' ) }
158+ text = { i18n ( 'context_memory-used' ) }
130159 value = { memoryMetrics . totalUsed }
131160 limit = { memoryMetrics . totalLimit }
132161 legendFormatter = { formatStorageLegend }
@@ -143,8 +172,7 @@ export function MetricsTabs({
143172 >
144173 < Link to = { tabLinks . network } className = { b ( 'link' ) } >
145174 < TabCard
146- label = { i18n ( 'cards.network-label' ) }
147- sublabel = { i18n ( 'context_network-usage' ) }
175+ text = { i18n ( 'context_network-usage' ) }
148176 value = { networkMetrics . totalUsed }
149177 limit = { networkMetrics . totalLimit }
150178 legendFormatter = { formatSpeedLegend }
0 commit comments