Less Lines = Better

Same logic, just more compact and react like
This commit is contained in:
Charles Morgan 2020-05-17 00:34:25 -04:00
parent 564933fcb1
commit 3df0febd0c
No known key found for this signature in database
GPG key ID: D71946CD723249BD
2 changed files with 4 additions and 29 deletions

View file

@ -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 (
<Link to={`/server/${server.id}`} className={`grey-row-box cursor-pointer ${className}`}>

View file

@ -81,20 +81,8 @@ export default () => {
};
}, [ instance, connected ]);
let memorylimit;
let disklimit;
if(server.limits.disk != 0 ) {
disklimit = <span className={'text-neutral-500'}> / {server.limits.memory} MB</span>;
} else {
disklimit = <span className={'text-neutral-500'}> / Unlimited</span>;
};
if(server.limits.memory != 0 ) {
memorylimit = <span className={'text-neutral-500'}> / {server.limits.memory} MB</span>;
} else {
memorylimit = <span className={'text-neutral-500'}> / Unlimited</span>;
};
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 (
<PageContentBlock className={'flex'}>