Skip to content

Commit 74ca103

Browse files
authored
fix(HealthcheckPreview): use only one query (#2427)
1 parent ce1fb66 commit 74ca103

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

src/containers/Tenant/Diagnostics/Diagnostics.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,7 @@ function Diagnostics(props: DiagnosticsProps) {
185185
}}
186186
allowNotSelected={true}
187187
/>
188-
<AutoRefreshControl
189-
onManualRefresh={() => {
190-
//this is needed to collect healthcheck if it is disabled by default https://github.com/ydb-platform/ydb-embedded-ui/issues/1889
191-
const event = new CustomEvent('diagnosticsRefresh');
192-
document.dispatchEvent(event);
193-
}}
194-
/>
188+
<AutoRefreshControl />
195189
</div>
196190
</div>
197191
);

src/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/HealthcheckPreview.tsx

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import type {AlertProps} from '@gravity-ui/uikit';
42
import {Alert, Button, Flex, Icon, Popover, Skeleton} from '@gravity-ui/uikit';
53

@@ -52,36 +50,12 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
5250
{
5351
//FIXME https://github.com/ydb-platform/ydb-embedded-ui/issues/1889
5452
pollingInterval: healthcheckPreviewDisabled ? undefined : autoRefreshInterval,
55-
skip: healthcheckPreviewDisabled,
5653
},
5754
);
5855

59-
const [getHealthcheckQuery, {currentData: manualData, isFetching: isFetchingManually}] =
60-
healthcheckApi.useLazyGetHealthcheckInfoQuery();
61-
62-
React.useEffect(() => {
63-
if (healthcheckPreviewDisabled) {
64-
getHealthcheckQuery({database: tenantName});
65-
}
66-
}, [healthcheckPreviewDisabled, tenantName, getHealthcheckQuery]);
56+
const loading = isFetching && data === undefined;
6757

68-
React.useEffect(() => {
69-
const fetchHealthcheck = () => {
70-
if (healthcheckPreviewDisabled) {
71-
getHealthcheckQuery({database: tenantName});
72-
}
73-
};
74-
document.addEventListener('diagnosticsRefresh', fetchHealthcheck);
75-
return () => {
76-
document.removeEventListener('diagnosticsRefresh', fetchHealthcheck);
77-
};
78-
}, [tenantName, healthcheckPreviewDisabled, getHealthcheckQuery]);
79-
80-
const loading =
81-
(isFetching && data === undefined) || (isFetchingManually && manualData === undefined);
82-
83-
const selfCheckResult: SelfCheckResult =
84-
data?.self_check_result || manualData?.self_check_result || SelfCheckResult.UNSPECIFIED;
58+
const selfCheckResult: SelfCheckResult = data?.self_check_result || SelfCheckResult.UNSPECIFIED;
8559

8660
const modifier = selfCheckResult.toLowerCase();
8761

0 commit comments

Comments
 (0)