From 3df0febd0cd7e69605d0f44d2a4d668fe5623862 Mon Sep 17 00:00:00 2001 From: Charles Morgan Date: Sun, 17 May 2020 00:34:25 -0400 Subject: [PATCH] Less Lines = Better Same logic, just more compact and react like --- .../scripts/components/dashboard/ServerRow.tsx | 17 ++--------------- .../scripts/components/server/ServerConsole.tsx | 16 ++-------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/resources/scripts/components/dashboard/ServerRow.tsx b/resources/scripts/components/dashboard/ServerRow.tsx index d6d501b1d..a212bce0c 100644 --- a/resources/scripts/components/dashboard/ServerRow.tsx +++ b/resources/scripts/components/dashboard/ServerRow.tsx @@ -52,21 +52,8 @@ export default ({ server, className }: { server: Server; className: string | und alarms.memory = isAlarmState(stats.memoryUsageInBytes, server.limits.memory); alarms.disk = server.limits.disk === 0 ? false : isAlarmState(stats.diskUsageInBytes, server.limits.disk); } - - let disklimit; - let memorylimit; - - if(server.limits.disk != 0) { - disklimit = bytesToHuman(server.limits.disk * 1000 * 1000); - } else { - disklimit = "Unlimited"; - }; - - if(server.limits.memory != 0) { - memorylimit = bytesToHuman(server.limits.memory * 1000 * 1000); - } else { - memorylimit = "Unlimited"; - }; + const disklimit = server.limits.disk != 0 ? bytesToHuman(server.limits.disk * 1000 * 1000) : "Unlimited"; + const memorylimit = server.limits.memory != 0 ? bytesToHuman(server.limits.memory * 1000 * 1000) : "Unlimited"; return ( diff --git a/resources/scripts/components/server/ServerConsole.tsx b/resources/scripts/components/server/ServerConsole.tsx index 827cf6c3b..9d2e99efd 100644 --- a/resources/scripts/components/server/ServerConsole.tsx +++ b/resources/scripts/components/server/ServerConsole.tsx @@ -81,20 +81,8 @@ export default () => { }; }, [ instance, connected ]); - - let memorylimit; - let disklimit; - - if(server.limits.disk != 0 ) { - disklimit = / {server.limits.memory} MB; - } else { - disklimit = / Unlimited; - }; - if(server.limits.memory != 0 ) { - memorylimit = / {server.limits.memory} MB; - } else { - memorylimit = / Unlimited; - }; + const disklimit = server.limits.disk != 0 ? bytesToHuman(server.limits.disk * 1000 * 1000) : "Unlimited"; + const memorylimit = server.limits.memory != 0 ? bytesToHuman(server.limits.memory * 1000 * 1000) : "Unlimited"; return (