fix dialog

This commit is contained in:
sua yoo 2024-05-07 14:30:54 -07:00
parent e1ef894275
commit ebb9dc826a
No known key found for this signature in database
GPG Key ID: 5AD1B4C02D4F0567

View File

@ -2,6 +2,7 @@ import { localized, msg, str } from "@lit/localize";
import type { SlInput } from "@shoelace-style/shoelace"; import type { SlInput } from "@shoelace-style/shoelace";
import { type TemplateResult } from "lit"; import { type TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js"; import { customElement, property } from "lit/decorators.js";
import { when } from "lit/directives/when.js";
import type { CurrentUser, UserOrg } from "@/types/user"; import type { CurrentUser, UserOrg } from "@/types/user";
import LiteElement, { html } from "@/utils/LiteElement"; import LiteElement, { html } from "@/utils/LiteElement";
@ -38,49 +39,47 @@ export class OrgsList extends LiteElement {
} }
private renderOrgQuotas() { private renderOrgQuotas() {
if (!this.currOrg) {
return html``;
}
return html` return html`
<btrix-dialog <btrix-dialog
.label=${msg(str`Quotas for: ${this.currOrg.name}`)} .label=${msg(str`Quotas for: ${this.currOrg?.name || ""}`)}
.open=${!!this.currOrg} .open=${!!this.currOrg}
@sl-request-close=${() => (this.currOrg = null)} @sl-request-close=${() => (this.currOrg = null)}
> >
${Object.entries(this.currOrg.quotas!).map(([key, value]) => { ${when(this.currOrg?.quotas, (quotas) =>
let label; Object.entries(quotas).map(([key, value]) => {
switch (key) { let label;
case "maxConcurrentCrawls": switch (key) {
label = msg("Max Concurrent Crawls"); case "maxConcurrentCrawls":
break; label = msg("Max Concurrent Crawls");
case "maxPagesPerCrawl": break;
label = msg("Max Pages Per Crawl"); case "maxPagesPerCrawl":
break; label = msg("Max Pages Per Crawl");
case "storageQuota": break;
label = msg("Org Storage Quota (GB)"); case "storageQuota":
value = Math.floor(value / 1e9); label = msg("Org Storage Quota (GB)");
break; value = Math.floor(value / 1e9);
case "maxExecMinutesPerMonth": break;
label = msg("Max Execution Minutes Per Month"); case "maxExecMinutesPerMonth":
break; label = msg("Max Execution Minutes Per Month");
case "extraExecMinutes": break;
label = msg("Extra Execution Minutes"); case "extraExecMinutes":
break; label = msg("Extra Execution Minutes");
case "giftedExecMinutes": break;
label = msg("Gifted Execution Minutes"); case "giftedExecMinutes":
break; label = msg("Gifted Execution Minutes");
default: break;
label = msg("Unlabeled"); default:
} label = msg("Unlabeled");
return html` <sl-input }
name=${key} return html` <sl-input
label=${label} name=${key}
value=${value} label=${label}
type="number" value=${value}
@sl-input="${this.onUpdateQuota}" type="number"
></sl-input>`; @sl-input="${this.onUpdateQuota}"
})} ></sl-input>`;
}),
)}
<div slot="footer" class="flex justify-end"> <div slot="footer" class="flex justify-end">
<sl-button <sl-button
size="small" size="small"