Skip to content

Commit

Permalink
Fixed crash in simple dashboard when one disk has failed (#2314)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
  • Loading branch information
bexsoft committed Sep 15, 2022
1 parent 024ab12 commit 41671b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Expand Up @@ -236,6 +236,11 @@ const BasicDashboard = ({ usage }: IDashboardProps) => {
label={"Browse"}
icon={<ArrowRightIcon />}
variant={"regular"}
style={{
padding: 5,
height: 30,
fontSize: 14,
}}
/>
</TooltipWrapper>
</Link>
Expand Down
Expand Up @@ -52,13 +52,16 @@ const driveStatusColor = (health_status: string) => {
};

const DriveInfoItem = ({ drive }: ICardProps) => {
const freeSpace = drive.totalSpace - drive.usedSpace;
const totalSpace = drive.totalSpace || 0;
const usedSpace = drive.usedSpace || 0;

const freeSpace = totalSpace - usedSpace;

const plotValues = [
{ value: freeSpace, color: "#D6D6D6", label: "Free Space" },
{
value: drive.usedSpace,
color: capacityColors(drive.usedSpace, drive.totalSpace),
color: capacityColors(usedSpace, totalSpace),
label: "Used Space",
},
];
Expand Down Expand Up @@ -154,7 +157,7 @@ const DriveInfoItem = ({ drive }: ICardProps) => {
fontSize: 12,
}}
>
{niceBytesInt(drive.usedSpace)}
{drive.usedSpace ? niceBytesInt(drive.usedSpace) : "-"}
</span>
<div>
<PieChart width={110} height={110}>
Expand Down
2 changes: 1 addition & 1 deletion portal-ui/src/screens/Console/Dashboard/types.ts
Expand Up @@ -49,7 +49,7 @@ export interface IDriveInfo {
healing: boolean;
model: string;
totalSpace: number;
usedSpace: number;
usedSpace?: number;
availableSpace: number;
}

Expand Down

0 comments on commit 41671b4

Please sign in to comment.