Skip to content

Commit 6caea3d

Browse files
authored
fix: add loader for healthcheck (#563)
1 parent 0d4ccf2 commit 6caea3d

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cn from 'bem-cn-lite';
33
import type {IResponseError} from '../../../../../types/api/error';
44
import type {IIssuesTree} from '../../../../../types/store/healthcheck';
55
import {ResponseError} from '../../../../../components/Errors/ResponseError';
6+
import {Loader} from '../../../../../components/Loader';
67

78
import IssueTree from './IssuesViewer/IssueTree';
89

@@ -13,17 +14,23 @@ const b = cn('healthcheck');
1314

1415
interface HealthcheckDetailsProps {
1516
issueTrees?: IIssuesTree[];
17+
loading?: boolean;
18+
wasLoaded?: boolean;
1619
error?: IResponseError;
1720
}
1821

1922
export function HealthcheckDetails(props: HealthcheckDetailsProps) {
20-
const {issueTrees, error} = props;
23+
const {issueTrees, loading, wasLoaded, error} = props;
2124

2225
const renderContent = () => {
2326
if (error) {
2427
return <ResponseError error={error} defaultMessage={i18n('no-data')} />;
2528
}
2629

30+
if (loading && !wasLoaded) {
31+
return <Loader size="m" />;
32+
}
33+
2734
if (!issueTrees || !issueTrees.length) {
2835
return i18n('status_message.ok');
2936
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {IResponseError} from '../../../../../types/api/error';
99
import {DiagnosticCard} from '../../../../../components/DiagnosticCard/DiagnosticCard';
1010
import EntityStatus from '../../../../../components/EntityStatus/EntityStatus';
1111
import {ResponseError} from '../../../../../components/Errors/ResponseError';
12+
import {Loader} from '../../../../../components/Loader';
1213

1314
import i18n from './i18n';
1415
import './Healthcheck.scss';
@@ -19,17 +20,22 @@ interface HealthcheckPreviewProps {
1920
selfCheckResult: SelfCheckResult;
2021
issuesStatistics?: [StatusFlag, number][];
2122
loading?: boolean;
23+
wasLoaded?: boolean;
2224
onUpdate: VoidFunction;
2325
error?: IResponseError;
2426
active?: boolean;
2527
}
2628

2729
export function HealthcheckPreview(props: HealthcheckPreviewProps) {
28-
const {selfCheckResult, issuesStatistics, loading, onUpdate, error, active} = props;
30+
const {selfCheckResult, issuesStatistics, loading, wasLoaded, onUpdate, error, active} = props;
2931

3032
const renderHeader = () => {
3133
const modifier = selfCheckResult.toLowerCase();
3234

35+
if (loading && !wasLoaded) {
36+
return null;
37+
}
38+
3339
return (
3440
<div className={b('preview-header')}>
3541
<div className={b('preview-title-wrapper')}>
@@ -50,6 +56,10 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
5056
return <ResponseError error={error} defaultMessage={i18n('no-data')} />;
5157
}
5258

59+
if (loading && !wasLoaded) {
60+
return <Loader size="m" />;
61+
}
62+
5363
return (
5464
<div className={b('preview-content')}>
5565
{!issuesStatistics || !issuesStatistics.length ? (

src/containers/Tenant/Diagnostics/TenantOverview/MetricsCards/MetricsCards.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface MetricsCardsProps {
3838
selfCheckResult: SelfCheckResult;
3939
fetchHealthcheck: VoidFunction;
4040
healthcheckLoading?: boolean;
41+
healthCheckWasLoaded?: boolean;
4142
healthcheckError?: IResponseError;
4243
}
4344

@@ -47,6 +48,7 @@ export function MetricsCards({
4748
selfCheckResult,
4849
fetchHealthcheck,
4950
healthcheckLoading,
51+
healthCheckWasLoaded,
5052
healthcheckError,
5153
}: MetricsCardsProps) {
5254
const location = useLocation();
@@ -124,6 +126,7 @@ export function MetricsCards({
124126
issuesStatistics={issuesStatistics}
125127
onUpdate={fetchHealthcheck}
126128
loading={healthcheckLoading}
129+
wasLoaded={healthCheckWasLoaded}
127130
error={healthcheckError}
128131
active={metricsTab === TENANT_METRICS_TABS_IDS.healthcheck}
129132
/>

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,22 @@ export function TenantOverview({
130130
return <TenantMemory path={tenantName} />;
131131
}
132132
case TENANT_METRICS_TABS_IDS.healthcheck: {
133-
return <HealthcheckDetails issueTrees={issueTrees} error={healthcheckError} />;
133+
return (
134+
<HealthcheckDetails
135+
issueTrees={issueTrees}
136+
loading={healthcheckLoading}
137+
wasLoaded={healthCheckWasLoaded}
138+
error={healthcheckError}
139+
/>
140+
);
134141
}
135142
default: {
136143
return undefined;
137144
}
138145
}
139146
};
140147

141-
if ((tenantLoading && !tenantWasLoaded) || (healthcheckLoading && !healthCheckWasLoaded)) {
148+
if (tenantLoading && !tenantWasLoaded) {
142149
return (
143150
<div className={b('loader')}>
144151
<Loader size="m" />
@@ -160,6 +167,7 @@ export function TenantOverview({
160167
selfCheckResult={selfCheckResult}
161168
fetchHealthcheck={fetchHealthcheck}
162169
healthcheckLoading={healthcheckLoading}
170+
healthCheckWasLoaded={healthCheckWasLoaded}
163171
healthcheckError={healthcheckError}
164172
/>
165173
</div>

0 commit comments

Comments
 (0)