From 22fbf92ed6a31408fe527107aa5ec398f19da703 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Fri, 13 Oct 2023 14:31:33 -0700 Subject: [PATCH] Show storage values for each item type when no quota (#1260) Hides chart and shows size values for each Storage line when org has no quota. No changes to orgs with quota. (Follow-up to #1188) --- frontend/src/pages/org/dashboard.ts | 164 ++++++++++++++++------------ 1 file changed, 97 insertions(+), 67 deletions(-) diff --git a/frontend/src/pages/org/dashboard.ts b/frontend/src/pages/org/dashboard.ts index 3400c271..2908358f 100644 --- a/frontend/src/pages/org/dashboard.ts +++ b/frontend/src/pages/org/dashboard.ts @@ -57,6 +57,7 @@ export class Dashboard extends LiteElement { } render() { + const hasQuota = Boolean(this.metrics?.storageQuotaBytes); const quotaReached = this.metrics && this.metrics.storageQuotaBytes > 0 && @@ -120,6 +121,11 @@ export class Dashboard extends LiteElement {
${this.renderStat({ value: metrics.crawlCount, + secondaryValue: hasQuota + ? "" + : html``, singleLabel: msg("Crawl"), pluralLabel: msg("Crawls"), iconProps: { @@ -129,12 +135,22 @@ export class Dashboard extends LiteElement { })} ${this.renderStat({ value: metrics.uploadCount, + secondaryValue: hasQuota + ? "" + : html``, singleLabel: msg("Upload"), pluralLabel: msg("Uploads"), iconProps: { name: "upload", color: this.colors.uploads }, })} ${this.renderStat({ value: metrics.profileCount, + secondaryValue: hasQuota + ? "" + : html``, singleLabel: msg("Browser Profile"), pluralLabel: msg("Browser Profiles"), iconProps: { @@ -147,6 +163,11 @@ export class Dashboard extends LiteElement { > ${this.renderStat({ value: metrics.archivedItemCount, + secondaryValue: hasQuota + ? "" + : html``, singleLabel: msg("Archived Item"), pluralLabel: msg("Archived Items"), iconProps: { name: "file-zip-fill" }, @@ -246,58 +267,54 @@ export class Dashboard extends LiteElement { > ${msg("Available")} ` - : html` - - ${msg("of Data Stored")} - ` + : "" )} -
- - ${when(metrics.storageUsedCrawls, () => - renderBar( - metrics.storageUsedCrawls, - msg("Crawls"), - this.colors.crawls - ) - )} - ${when(metrics.storageUsedUploads, () => - renderBar( - metrics.storageUsedUploads, - msg("Uploads"), - this.colors.uploads - ) - )} - ${when(metrics.storageUsedProfiles, () => - renderBar( - metrics.storageUsedProfiles, - msg("Profiles"), - this.colors.browserProfiles - ) - )} -
- -
-
${msg("Available")}
-
- ${this.renderPercentage( - (metrics.storageQuotaBytes - metrics.storageUsedBytes) / - metrics.storageQuotaBytes - )} -
+ ${when( + hasQuota, + () => html` +
+ + ${when(metrics.storageUsedCrawls, () => + renderBar( + metrics.storageUsedCrawls, + msg("Crawls"), + this.colors.crawls + ) + )} + ${when(metrics.storageUsedUploads, () => + renderBar( + metrics.storageUsedUploads, + msg("Uploads"), + this.colors.uploads + ) + )} + ${when(metrics.storageUsedProfiles, () => + renderBar( + metrics.storageUsedProfiles, + msg("Profiles"), + this.colors.browserProfiles + ) + )} +
+ +
+
${msg("Available")}
+
+ ${this.renderPercentage( + (metrics.storageQuotaBytes - metrics.storageUsedBytes) / + metrics.storageQuotaBytes + )} +
+
+
+
-
- -
- ${when( - hasQuota, - () => html`` - )} - -
+ > + +
+ ` + )} `; } @@ -340,26 +358,38 @@ export class Dashboard extends LiteElement { private renderStat(stat: { value: number | string | TemplateResult; + secondaryValue?: number | string | TemplateResult; singleLabel: string; pluralLabel: string; iconProps: { name: string; library?: string; color?: string }; }) { const { value, iconProps } = stat; return html` -
- -
- ${value === 1 ? stat.singleLabel : stat.pluralLabel} -
-
- ${typeof value === "number" ? value.toLocaleString() : value} -
+
+
+ +
+ ${value === 1 ? stat.singleLabel : stat.pluralLabel} +
+
+ ${typeof value === "number" ? value.toLocaleString() : value} +
+
+ ${when( + stat.secondaryValue, + () => + html` +
+ ${stat.secondaryValue} +
+ ` + )}
`; }