From 93573d0bfe626b9a62dc7198092005b0f3389937 Mon Sep 17 00:00:00 2001 From: Tessa Walsh Date: Tue, 5 Sep 2023 21:35:20 -0400 Subject: [PATCH] Use base10 for sizes in frontend (#1133) * Use base10 for sizes in frontend * Simplify renderSize --- frontend/src/components/config-details.ts | 34 ++++------------------- frontend/src/pages/org/workflow-editor.ts | 2 +- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/config-details.ts b/frontend/src/components/config-details.ts index d12b7ce9..e893eddb 100644 --- a/frontend/src/components/config-details.ts +++ b/frontend/src/components/config-details.ts @@ -95,35 +95,13 @@ export class ConfigDetails extends LiteElement { >`; } }; - - const renderSize = (valueBytes?: number | null, fallbackValue?: number) => { - const bytesPerGB = 1073741824; - + const renderSize = (valueBytes?: number | null) => { // Eventually we will want to set this to the selected locale - const formatter = new Intl.NumberFormat(undefined, { - style: "unit", - unit: "gigabyte", - unitDisplay: "narrow", - }); - if (valueBytes) { - const sizeGB = Math.floor(valueBytes / bytesPerGB); - return formatter.format(sizeGB); - } - - if (typeof fallbackValue === "number") { - let value = ""; - if (fallbackValue === Infinity) { - value = msg("Unlimited"); - } else if (fallbackValue === 0) { - value = formatter.format(0); - } else { - const sizeGB = Math.floor(fallbackValue / bytesPerGB); - value = formatter.format(sizeGB); - } - return html`${value} ${msg("(default)")}`; + return html``; } return html` diff --git a/frontend/src/pages/org/workflow-editor.ts b/frontend/src/pages/org/workflow-editor.ts index 30453a39..23cd0273 100644 --- a/frontend/src/pages/org/workflow-editor.ts +++ b/frontend/src/pages/org/workflow-editor.ts @@ -215,7 +215,7 @@ const DEFAULT_BEHAVIORS = [ "autofetch", "siteSpecific", ]; -const BYTES_PER_GB = 1073741824; +const BYTES_PER_GB = 1e9; @localized() export class CrawlConfigEditor extends LiteElement {