@@ -13,6 +13,7 @@ import {cn} from '../../utils/cn';
13
13
import { useAutoRefreshInterval } from '../../utils/hooks' ;
14
14
import type { TimeFrame } from '../../utils/timeframes' ;
15
15
import { chartApi } from '../MetricChart/reducer' ;
16
+ import type { ChartDataStatus } from '../MetricChart/types' ;
16
17
17
18
import { QueriesActivityCharts } from './QueriesActivityCharts' ;
18
19
import i18n from './i18n' ;
@@ -33,14 +34,33 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
33
34
const [ expanded , setExpanded ] = React . useState ( false ) ;
34
35
const [ queriesTimeFrame ] = React . useState < TimeFrame > ( '1h' ) ;
35
36
const [ latenciesTimeFrame ] = React . useState < TimeFrame > ( '1h' ) ;
37
+ const [ isActivityBarHidden , setIsActivityBarHidden ] = React . useState < boolean > ( true ) ;
38
+
39
+ // Refetch data only if activity bar successfully loaded
40
+ const shouldRefresh = isActivityBarHidden ? 0 : autoRefreshInterval ;
41
+
42
+ /**
43
+ * Activity bar should be hidden, if charts are not enabled:
44
+ * 1. GraphShard is not enabled
45
+ * 2. ydb version does not have /viewer/json/render endpoint (400, 404, CORS error, etc.)
46
+ *
47
+ * If at least one chart successfully loaded, activity bar should be shown
48
+ * @link https://github.com/ydb-platform/ydb-embedded-ui/issues/659
49
+ * @todo disable only for specific errors ('GraphShard is not enabled') after ydb-stable-24 is generally used
50
+ */
51
+ const handleChartDataStatusChange = React . useCallback ( ( chartStatus : ChartDataStatus ) => {
52
+ if ( chartStatus === 'success' ) {
53
+ setIsActivityBarHidden ( false ) ;
54
+ }
55
+ } , [ ] ) ;
36
56
37
57
// Fetch running queries
38
58
const { data : runningQueriesData } = topQueriesApi . useGetRunningQueriesQuery (
39
59
{
40
60
database : tenantName ,
41
61
filters : { } ,
42
62
} ,
43
- { pollingInterval : autoRefreshInterval } ,
63
+ { pollingInterval : shouldRefresh } ,
44
64
) ;
45
65
46
66
// Fetch queries per second data for header metrics
@@ -51,7 +71,7 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
51
71
timeFrame : queriesTimeFrame ,
52
72
maxDataPoints : 30 ,
53
73
} ,
54
- { pollingInterval : autoRefreshInterval } ,
74
+ { pollingInterval : shouldRefresh } ,
55
75
) ;
56
76
57
77
// Fetch latency data for header metrics
@@ -62,7 +82,7 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
62
82
timeFrame : latenciesTimeFrame ,
63
83
maxDataPoints : 30 ,
64
84
} ,
65
- { pollingInterval : autoRefreshInterval } ,
85
+ { pollingInterval : shouldRefresh } ,
66
86
) ;
67
87
68
88
const runningQueriesCount = runningQueriesData ?. resultSets ?. [ 0 ] ?. result ?. length || 0 ;
@@ -109,7 +129,7 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
109
129
} ;
110
130
111
131
return (
112
- < div className = { b ( { expanded} ) } >
132
+ < div className = { b ( { expanded} ) } style = { { display : isActivityBarHidden ? 'none' : undefined } } >
113
133
< Disclosure expanded = { expanded } onUpdate = { setExpanded } className = { b ( 'disclosure' ) } >
114
134
< Disclosure . Summary >
115
135
{ ( props ) => (
@@ -204,7 +224,11 @@ export function QueriesActivityBar({tenantName}: QueriesActivityBarProps) {
204
224
</ div >
205
225
) : null }
206
226
</ Disclosure >
207
- < QueriesActivityCharts tenantName = { tenantName } expanded = { expanded } />
227
+ < QueriesActivityCharts
228
+ tenantName = { tenantName }
229
+ expanded = { expanded }
230
+ onChartDataStatusChange = { handleChartDataStatusChange }
231
+ />
208
232
</ div >
209
233
) ;
210
234
}
0 commit comments