From 03c2b8cebc9dfbda1c646102535ded970660c4e8 Mon Sep 17 00:00:00 2001 From: matvii Date: Fri, 2 Oct 2020 17:59:56 +0300 Subject: [PATCH] Remove comparing a string and a number Comparing [:155] a string [:154] (from string literal "" [:154] ) and a number [:155] (from number literal 85 [:155] ) might behave differently than you expect, as implicit conversion is performed. Replace `''` with `0` because we use it to display number near the percent sign. --- client/src/components/nodesPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/nodesPanel.tsx b/client/src/components/nodesPanel.tsx index 3120f0b..67946cd 100644 --- a/client/src/components/nodesPanel.tsx +++ b/client/src/components/nodesPanel.tsx @@ -151,7 +151,7 @@ function percent(node: Node, used: number | string | null, resource: ResourceTyp const result = unparser(used); const available = getNodeResourcesAvailable(node, resource); - const displayPercent = available ? _.round(Number(used) / available * 100, 1) : ''; + const displayPercent = available ? _.round(Number(used) / available * 100, 1) : 0; const className = displayPercent >= 85 ? 'contentPanel_warn' : undefined; return (