1+ import React from 'react' ;
2+
13import {
24 CircleCheck ,
35 CircleInfo ,
@@ -15,7 +17,7 @@ import {useClusterBaseInfo} from '../../../../../store/reducers/cluster/cluster'
1517import { healthcheckApi } from '../../../../../store/reducers/healthcheckInfo/healthcheckInfo' ;
1618import { SelfCheckResult } from '../../../../../types/api/healthcheck' ;
1719import { cn } from '../../../../../utils/cn' ;
18- import { useAutoRefreshInterval } from '../../../../../utils/hooks' ;
20+ import { useAutoRefreshInterval , useTypedSelector } from '../../../../../utils/hooks' ;
1921
2022import i18n from './i18n' ;
2123
@@ -42,8 +44,11 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
4244 const { tenantName, active} = props ;
4345 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
4446
47+ const { metricsTab} = useTypedSelector ( ( state ) => state . tenant ) ;
48+
4549 const { name} = useClusterBaseInfo ( ) ;
46- const healthcheckPreviewAutorefreshDisabled = name === 'ydb_ru' ;
50+
51+ const healthcheckPreviewDisabled = name === 'ydb_ru' ;
4752
4853 const {
4954 currentData : data ,
@@ -53,23 +58,44 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
5358 { database : tenantName } ,
5459 {
5560 //FIXME https://github.com/ydb-platform/ydb-embedded-ui/issues/1889
56- pollingInterval : healthcheckPreviewAutorefreshDisabled
57- ? undefined
58- : autoRefreshInterval ,
61+ pollingInterval : healthcheckPreviewDisabled ? undefined : autoRefreshInterval ,
62+ skip : healthcheckPreviewDisabled ,
5963 } ,
6064 ) ;
6165
62- const loading = isFetching && data === undefined ;
66+ const [ getHealthcheckQuery , { currentData : manualData , isFetching : isFetchingManually } ] =
67+ healthcheckApi . useLazyGetHealthcheckInfoQuery ( ) ;
68+
69+ React . useEffect ( ( ) => {
70+ if ( metricsTab === 'healthcheck' && healthcheckPreviewDisabled ) {
71+ getHealthcheckQuery ( { database : tenantName } ) ;
72+ }
73+ } , [ metricsTab , healthcheckPreviewDisabled , tenantName , getHealthcheckQuery ] ) ;
74+
75+ React . useEffect ( ( ) => {
76+ const fetchHealthcheck = ( ) => {
77+ if ( healthcheckPreviewDisabled ) {
78+ getHealthcheckQuery ( { database : tenantName } ) ;
79+ }
80+ } ;
81+ document . addEventListener ( 'diagnosticsRefresh' , fetchHealthcheck ) ;
82+ return ( ) => {
83+ document . removeEventListener ( 'diagnosticsRefresh' , fetchHealthcheck ) ;
84+ } ;
85+ } , [ tenantName , healthcheckPreviewDisabled , getHealthcheckQuery ] ) ;
86+
87+ const loading =
88+ ( isFetching && data === undefined ) || ( isFetchingManually && manualData === undefined ) ;
6389
6490 const renderHeader = ( ) => {
6591 return (
6692 < div className = { b ( 'preview-header' ) } >
6793 < div className = { b ( 'preview-title-wrapper' ) } >
6894 < div className = { b ( 'preview-title' ) } > { i18n ( 'title.healthcheck' ) } </ div >
6995 { /* FIXME https://github.com/ydb-platform/ydb-embedded-ui/issues/1889 */ }
70- { autoRefreshInterval && healthcheckPreviewAutorefreshDisabled ? (
96+ { healthcheckPreviewDisabled ? (
7197 < Popover
72- content = { 'Autorefresh is disabled. Please update healthcheck manually.' }
98+ content = { 'Healthcheck is disabled. Please update healthcheck manually.' }
7399 placement = { [ 'top' ] }
74100 className = { b ( 'icon-wrapper' ) }
75101 >
@@ -96,7 +122,8 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
96122 return < Loader size = "m" /> ;
97123 }
98124
99- const selfCheckResult = data ?. self_check_result || SelfCheckResult . UNSPECIFIED ;
125+ const selfCheckResult =
126+ data ?. self_check_result || manualData ?. self_check_result || SelfCheckResult . UNSPECIFIED ;
100127 const modifier = selfCheckResult . toLowerCase ( ) ;
101128 return (
102129 < div className = { b ( 'preview-content' ) } >
0 commit comments