Skip to content

Commit f7eac30

Browse files
authored
Fixed health color logic for two drive case (#1185)
* Fixed health color logic for two drive case * Removed unneeded code
1 parent 5df4e98 commit f7eac30

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

portal-ui/src/screens/Console/Dashboard/BasicDashboard/ServerInfoCard.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
1716
import React from "react";
1817
import { Theme } from "@mui/material/styles";
1918
import createStyles from "@mui/styles/createStyles";
@@ -25,18 +24,15 @@ import { Card, CardHeader } from "@mui/material";
2524
import { CircleIcon, VersionIcon } from "../../../../icons";
2625
import get from "lodash/get";
2726
import { commonDashboardInfocard } from "../../Common/FormComponents/common/styleLibrary";
28-
2927
const styles = (theme: Theme) =>
3028
createStyles({
3129
...commonDashboardInfocard,
3230
});
33-
3431
interface ICardProps {
3532
classes: any;
3633
server: ServerInfo;
3734
index: number;
3835
}
39-
4036
const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
4137
const serverStatusToClass = (health_status: string) => {
4238
switch (health_status) {
@@ -48,24 +44,19 @@ const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
4844
return classes.greyState;
4945
}
5046
};
51-
5247
const networkKeys = Object.keys(get(server, "network", {}));
53-
5448
const networkTotal = networkKeys.length;
5549
const totalDrives = server.drives ? server.drives.length : 0;
56-
5750
const activeNetwork = networkKeys.reduce((acc: number, currValue: string) => {
5851
const item = server.network[currValue];
5952
if (item === "online") {
6053
return acc + 1;
6154
}
6255
return acc;
6356
}, 0);
64-
6557
const activeDisks = server.drives
6658
? server.drives.filter((element) => element.state === "ok").length
6759
: 0;
68-
6960
return (
7061
<Card className={classes.cardContainer}>
7162
<CardHeader
@@ -89,9 +80,10 @@ const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
8980
<span
9081
className={`${classes.innerState} ${
9182
activeDisks <= totalDrives / 2 && classes.redState
92-
} ${
93-
activeDisks === totalDrives / 2 + 1 && classes.yellowState
94-
} ${activeDisks === totalDrives && classes.greenState}`}
83+
} ${
84+
totalDrives != 2 && activeDisks === totalDrives / 2 + 1 && classes.yellowState
85+
} ${
86+
activeDisks === totalDrives && classes.greenState}`}
9587
>
9688
<CircleIcon />
9789
</span>
@@ -122,5 +114,4 @@ const ServerInfoCard = ({ classes, server, index }: ICardProps) => {
122114
</Card>
123115
);
124116
};
125-
126-
export default withStyles(styles)(ServerInfoCard);
117+
export default withStyles(styles)(ServerInfoCard);

0 commit comments

Comments
 (0)