Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Health Change (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAmbastha authored and rawagner committed Apr 16, 2019
1 parent 618a095 commit 55596c4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 34 deletions.
29 changes: 6 additions & 23 deletions src/components/Dashboard/Health/HealthItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,15 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Icon } from 'patternfly-react';

import { InlineLoading } from '../../Loading';

export const HealthItem = ({ icon, classname, message, isLoading, LoadingComponent }) => {
const description = isLoading ? <LoadingComponent /> : message;
return (
<div className="kubevirt-dashboard-health__icon">
<Icon
type="fa"
size="2x"
name={icon}
className={`kubevirt-health__icon kubevirt-dashboard-health__icon--${classname}`}
/>
<span className="kubevirt-health__text">{description}</span>
</div>
);
};

HealthItem.defaultProps = {
LoadingComponent: InlineLoading,
isLoading: false,
};
export const HealthItem = ({ icon, classname, message }) => (
<div className="kubevirt-health__body">
<Icon type="fa" size="2x" name={icon} className={`kubevirt-health__icon kubevirt-health__icon--${classname}`} />
<span className="kubevirt-health__text">{message}</span>
</div>
);

HealthItem.propTypes = {
message: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired,
classname: PropTypes.string.isRequired,
LoadingComponent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
isLoading: PropTypes.bool,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ exports[`<HealthBody /> renders correctly 1`] = `
className="kubevirt-health__body"
>
<HealthItem
LoadingComponent={[Function]}
classname="ok"
icon="check-circle"
isLoading={false}
message="OCS is Healthy"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`<HealthItem /> renders correctly 1`] = `
<div
className="kubevirt-dashboard-health__icon"
className="kubevirt-health__body"
>
<Icon
className="kubevirt-health__icon kubevirt-dashboard-health__icon--ok"
className="kubevirt-health__icon kubevirt-health__icon--ok"
name="check-circle"
size="2x"
type="fa"
Expand Down
6 changes: 2 additions & 4 deletions src/components/StorageOverview/OCSHealth/Health.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ const OCSHealthStatus = {
};

export const OCSHealth = ({ data, loaded }) => {
const value = get(data, 'healthy');
const value = get(data, 'healthy.data.result[0].value[1]');
const status = OCSHealthStatus[value] || OCSHealthStatus[3];
return (
<DashboardCard>
<DashboardCardHeader>
<DashboardCardTitle>Health</DashboardCardTitle>
</DashboardCardHeader>
<DashboardCardBody>
<DashboardCardBody isLoading={!loaded} LoadingComponent={InlineLoading}>
<HealthBody>
<HealthItem
message={data ? status.message : null}
icon={data ? status.iconname : null}
classname={data ? status.classname : null}
isLoading={!loaded}
LoadingComponent={InlineLoading}
/>
</HealthBody>
</DashboardCardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ exports[`<Health /> renders correctly 1`] = `
class="kubevirt-health__body"
>
<div
class="kubevirt-dashboard-health__icon"
class="kubevirt-health__body"
>
<span
aria-hidden="true"
class="fa fa-check-circle fa-2x kubevirt-health__icon kubevirt-dashboard-health__icon--ok"
class="fa fa-exclamation-triangle fa-2x kubevirt-health__icon kubevirt-health__icon--error"
/>
<span
class="kubevirt-health__text"
>
OCS is Healthy
Not available
</span>
</div>
</div>
Expand Down

0 comments on commit 55596c4

Please sign in to comment.