-
Notifications
You must be signed in to change notification settings - Fork 594
/
VSphereStatus.tsx
70 lines (62 loc) · 2.12 KB
/
VSphereStatus.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as React from 'react';
import { StackItem, Stack } from '@patternfly/react-core';
import { useTranslation } from 'react-i18next';
import { HealthState } from '@console/dynamic-plugin-sdk';
import {
PrometheusHealthPopupProps,
PrometheusHealthHandler,
} from '@console/dynamic-plugin-sdk/dist/core/lib/lib-core';
import { ConfigMap } from '../../resources';
import { getVSphereHealth } from '../getVSphereHealth';
import { VSphereConnection } from '../VSphereConnection';
import { VSphereOperatorStatuses } from '../VSphereOperatorStatuses';
import './VSphereStatus.css';
// https://issues.redhat.com/browse/MGMT-9085
// https://access.redhat.com/solutions/6677901
const VSphereStatus: React.FC<PrometheusHealthPopupProps> = ({ hide, responses, k8sResult }) => {
const { t } = useTranslation();
const health = getVSphereHealth(t, responses, k8sResult);
if (
[HealthState.OK, HealthState.WARNING, HealthState.PROGRESS].includes(health.state) &&
k8sResult?.data
) {
const cloudProviderConfig = k8sResult.data as ConfigMap;
return (
<VSphereConnection hide={hide} cloudProviderConfig={cloudProviderConfig} health={health} />
);
}
if (health.state === HealthState.LOADING) {
return (
<Stack hasGutter>
<StackItem>{t('vsphere-plugin~Loading vSphere connection status')}</StackItem>
</Stack>
);
}
return (
<div>
<Stack hasGutter>
<StackItem>{t('vsphere-plugin~The vSphere Connection check is failing.')}</StackItem>
<StackItem>
<VSphereOperatorStatuses />
</StackItem>
</Stack>
</div>
);
};
export const healthHandler: PrometheusHealthHandler = (responses, t, additionalResource) => {
const health = getVSphereHealth(t, responses, additionalResource);
const { state } = health;
let message: string | undefined;
switch (state) {
case HealthState.WARNING:
message = health.message;
break;
case HealthState.OK:
message = t('vsphere-plugin~No errors are reported. Click the link for details.');
break;
default:
break;
}
return { state, message };
};
export default VSphereStatus;