Skip to content

Commit 2728a3b

Browse files
committed
refactor(Healthcheck): api call response type coverage
1 parent 5d14e80 commit 2728a3b

File tree

5 files changed

+103
-3
lines changed

5 files changed

+103
-3
lines changed

src/containers/Tenant/Diagnostics/Healthcheck/IssuesList/IssuesList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import cn from 'bem-cn-lite';
22

33
import {Button} from '@gravity-ui/uikit';
44

5+
import type {IHealthCheck} from '../../../../../types/store/healthcheck';
6+
57
import IssuesViewer from '../IssuesViewer/IssuesViewer';
68

79
import i18n from '../i18n';
810

911
const b = cn('healthcheck');
1012

1113
interface IssuesListProps {
12-
data?: any;
14+
data?: IHealthCheck;
1315
loading?: boolean;
1416
onUpdate: VoidFunction;
1517
}

src/containers/Tenant/Diagnostics/Healthcheck/Preview/Preview.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import cn from 'bem-cn-lite';
22

33
import {Button} from '@gravity-ui/uikit';
44

5+
import {SelfCheckResult} from '../../../../../types/api/healthcheck';
6+
import type {IHealthCheck} from '../../../../../types/store/healthcheck';
7+
58
import i18n from '../i18n';
69

710
const b = cn('healthcheck');
811

912
interface PreviewProps {
10-
data?: any;
13+
data?: IHealthCheck;
1114
loading?: boolean;
1215
onShowMore?: VoidFunction;
1316
onUpdate: VoidFunction;
@@ -28,7 +31,7 @@ export const Preview = (props: PreviewProps) => {
2831
const {self_check_result: selfCheckResult} = data;
2932
const modifier = selfCheckResult.toLowerCase();
3033

31-
const statusOk = selfCheckResult === 'GOOD';
34+
const statusOk = selfCheckResult === SelfCheckResult.GOOD;
3235
const text = statusOk
3336
? i18n('status_message.ok')
3437
: i18n('status_message.error');

src/services/api.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface Window {
3838
query: string,
3939
database: string,
4040
) => Promise<import('../types/api/query').QueryAPIExplainResponse<'explain-ast'>>;
41+
getHealthcheckInfo: (database: string) => Promise<import('../types/api/healthcheck').HealthCheckAPIResponse>,
4142
[method: string]: Function;
4243
};
4344
}

src/types/api/healthcheck.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
export enum SelfCheckResult {
2+
UNSPECIFIED = 'UNSPECIFIED',
3+
GOOD = 'GOOD',
4+
DEGRADED = 'DEGRADED',
5+
MAINTENANCE_REQUIRED = 'MAINTENANCE_REQUIRED',
6+
EMERGENCY = 'EMERGENCY',
7+
}
8+
9+
enum StatusFlag {
10+
UNSPECIFIED = 'UNSPECIFIED',
11+
GREY = 'GREY',
12+
GREEN = 'GREEN',
13+
BLUE = 'BLUE',
14+
YELLOW = 'YELLOW',
15+
ORANGE = 'ORANGE',
16+
RED = 'RED',
17+
}
18+
19+
interface LocationNode {
20+
id: number;
21+
host: string;
22+
port: number;
23+
}
24+
25+
interface LocationStoragePDisk {
26+
id: string;
27+
path: string;
28+
}
29+
30+
interface LocationStorageVDisk {
31+
id: string;
32+
pdisk: LocationStoragePDisk;
33+
}
34+
35+
interface LocationStorageGroup {
36+
id: string;
37+
vdisk: LocationStorageVDisk;
38+
}
39+
40+
interface LocationStoragePool {
41+
name: string;
42+
group: LocationStorageGroup;
43+
}
44+
45+
interface LocationStorage {
46+
node: LocationNode;
47+
pool: LocationStoragePool;
48+
}
49+
50+
interface LocationComputePool {
51+
name: string;
52+
}
53+
54+
interface LocationComputeTablet {
55+
type: string;
56+
id?: string[];
57+
count: number;
58+
}
59+
60+
interface LocationCompute {
61+
node: LocationNode;
62+
pool: LocationComputePool;
63+
tablet: LocationComputeTablet;
64+
}
65+
66+
interface LocationDatabase {
67+
name: string;
68+
}
69+
70+
interface Location {
71+
storage: LocationStorage;
72+
compute: LocationCompute;
73+
database: LocationDatabase;
74+
}
75+
76+
interface IssueLog {
77+
id: string;
78+
status: StatusFlag;
79+
message: string;
80+
location: Location;
81+
reason?: string[];
82+
type: string;
83+
level: number;
84+
}
85+
86+
export interface HealthCheckAPIResponse {
87+
// eslint-disable-next-line camelcase
88+
self_check_result: SelfCheckResult;
89+
// eslint-disable-next-line camelcase
90+
issue_log?: IssueLog[];
91+
}

src/types/store/healthcheck.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type {HealthCheckAPIResponse} from "../api/healthcheck";
2+
3+
export type IHealthCheck = HealthCheckAPIResponse;

0 commit comments

Comments
 (0)