Skip to content

Commit 0089133

Browse files
committed
fix(HealthcheckPreview): use only one query (#2427)
1 parent 8103bb6 commit 0089133

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
@@ -186,13 +186,7 @@ function Diagnostics(props: DiagnosticsProps) {
186186
}}
187187
allowNotSelected={true}
188188
/>
189-
<AutoRefreshControl
190-
onManualRefresh={() => {
191-
//this is needed to collect healthcheck if it is disabled by default https://github.com/ydb-platform/ydb-embedded-ui/issues/1889
192-
const event = new CustomEvent('diagnosticsRefresh');
193-
document.dispatchEvent(event);
194-
}}
195-
/>
189+
<AutoRefreshControl />
196190
</div>
197191
</div>
198192
);

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)