@@ -8,12 +8,12 @@ import {TenantTabsGroups, getTenantPath} from '../../containers/Tenant/TenantPag
88import { parseQuery } from '../../routes' ;
99import { TENANT_DIAGNOSTICS_TABS_IDS } from '../../store/reducers/tenant/constants' ;
1010import { cn } from '../../utils/cn' ;
11- import type { ChartDataStatus } from '../MetricChart/types' ;
1211
1312import { QueriesActivityAlert } from './QueriesActivityAlert' ;
1413import { QueriesActivityCharts } from './QueriesActivityCharts' ;
1514import { QueriesActivitySkeleton } from './QueriesActivitySkeleton' ;
1615import i18n from './i18n' ;
16+ import { useChartAvailability } from './useChartAvailability' ;
1717import { useQueriesActivityData } from './useQueriesActivityData' ;
1818import { formatTrendValue } from './utils' ;
1919
@@ -29,25 +29,13 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
2929 const history = useHistory ( ) ;
3030 const location = useLocation ( ) ;
3131 const [ expanded , setExpanded ] = React . useState ( false ) ;
32- const [ areChartsAvailable , setAreChartsAvailable ] = React . useState < boolean | null > ( null ) ;
32+
33+ // Check chart availability without rendering hidden components
34+ const areChartsAvailable = useChartAvailability ( tenantName ) ;
3335
3436 const { runningQueriesCount, uniqueApplications, uniqueUsers, qps, latency} =
3537 useQueriesActivityData ( tenantName ) ;
3638
37- /**
38- * Activity bar should show different modes based on chart availability:
39- * 1. If charts are available: show expandable mode with charts
40- * 2. If charts are not available: show compact alert-style mode with stats only
41- * 3. While determining chart availability: show skeleton loading state
42- */
43- const handleChartDataStatusChange = React . useCallback ( ( chartStatus : ChartDataStatus ) => {
44- if ( chartStatus === 'success' ) {
45- setAreChartsAvailable ( true ) ;
46- } else if ( chartStatus === 'error' ) {
47- setAreChartsAvailable ( false ) ;
48- }
49- } , [ ] ) ;
50-
5139 const handleOpenRunningQueries = ( ) => {
5240 const queryParams = parseQuery ( location ) ;
5341 const path = getTenantPath ( {
@@ -64,19 +52,7 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
6452
6553 // Show skeleton while determining chart availability
6654 if ( areChartsAvailable === null ) {
67- return (
68- < >
69- { /* Hidden chart check to determine availability */ }
70- < div style = { { display : 'none' } } >
71- < QueriesActivityCharts
72- tenantName = { tenantName }
73- expanded = { false }
74- onChartDataStatusChange = { handleChartDataStatusChange }
75- />
76- </ div >
77- < QueriesActivitySkeleton />
78- </ >
79- ) ;
55+ return < QueriesActivitySkeleton /> ;
8056 }
8157
8258 // Render compact alert-style mode when charts are not available
@@ -180,11 +156,7 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
180156 </ div >
181157 </ div >
182158 ) }
183- < QueriesActivityCharts
184- tenantName = { tenantName }
185- expanded = { expanded }
186- onChartDataStatusChange = { handleChartDataStatusChange }
187- />
159+ < QueriesActivityCharts tenantName = { tenantName } expanded = { expanded } />
188160 </ Card >
189161 </ div >
190162 ) ;
0 commit comments