chore: format frontend files with prettier

This commit is contained in:
sua yoo 2023-03-27 11:05:19 -07:00
parent 48163db5d3
commit bca67c74e2
No known key found for this signature in database
GPG Key ID: 5AD1B4C02D4F0567
7 changed files with 50 additions and 78 deletions

View File

@ -6,7 +6,7 @@ import { allLocales } from "../__generated__/locale-codes";
import { getLocale, setLocaleFromUrl } from "../utils/localization";
import { localized } from "@lit/localize";
type LocaleCode = typeof allLocales[number];
type LocaleCode = (typeof allLocales)[number];
type LocaleNames = {
[L in LocaleCode]: string;
};

View File

@ -148,13 +148,9 @@ export class AcceptInvite extends LiteElement {
}
try {
await this.apiFetch(
`/orgs/invite-accept/${this.token}`,
this.authState,
{
method: "POST",
}
);
await this.apiFetch(`/orgs/invite-accept/${this.token}`, this.authState, {
method: "POST",
});
this.notify({
message: msg(str`You've joined ${this.inviteInfo.orgName}.`),
@ -174,9 +170,7 @@ export class AcceptInvite extends LiteElement {
private onDecline() {
this.notify({
message: msg(
str`You've declined to join ${this.inviteInfo.orgName}.`
),
message: msg(str`You've declined to join ${this.inviteInfo.orgName}.`),
variant: "info",
icon: "info-circle",
});

View File

@ -210,23 +210,20 @@ export class CrawlsList extends LiteElement {
</div>
</header>
<section>
${
this.crawls.length
? this.renderCrawlList()
: html`
${this.crawls.length
? this.renderCrawlList()
: html`
<div class="border-t border-b py-5">
<p class="text-center text-neutral-500">
${msg("No crawls yet.")}
</p>
</div>
`
}
`}
</section>
<footer class="m-2">
<span class="text-0-400 text-xs">
${
this.lastFetched
? msg(html`Last updated:
${this.lastFetched
? msg(html`Last updated:
<sl-format-date
date="${new Date(this.lastFetched).toString()}"
month="2-digit"
@ -236,8 +233,7 @@ export class CrawlsList extends LiteElement {
minute="numeric"
second="numeric"
></sl-format-date>`)
: ""
}
: ""}
</span>
</footer>
</main>
@ -330,9 +326,8 @@ export class CrawlsList extends LiteElement {
</div>
</div>
${
this.userId
? html` <div class="h-6 mt-2 flex justify-end">
${this.userId
? html` <div class="h-6 mt-2 flex justify-end">
<label>
<span class="text-neutral-500 text-xs mr-1"
>${msg("Show Only Mine")}</span
@ -344,8 +339,7 @@ export class CrawlsList extends LiteElement {
></sl-switch>
</label>
</div>`
: ""
}
: ""}
`;
}

View File

@ -62,7 +62,7 @@ const STEPS = [
"crawlMetadata",
"confirmSettings",
] as const;
type StepName = typeof STEPS[number];
type StepName = (typeof STEPS)[number];
type TabState = {
completed: boolean;
error: boolean;
@ -643,21 +643,19 @@ export class CrawlConfigEditor extends LiteElement {
private renderFooter({ isFirst = false, isLast = false }) {
return html`
<div class="px-6 py-4 border-t flex justify-between">
${
isFirst
? html`
${isFirst
? html`
<sl-button size="small" type="reset">
<sl-icon slot="prefix" name="chevron-left"></sl-icon>
${this.configId ? msg("Cancel") : msg("Start Over")}
</sl-button>
`
: html`
: html`
<sl-button size="small" @click=${this.backStep}>
<sl-icon slot="prefix" name="chevron-left"></sl-icon>
${msg("Previous Step")}
</sl-button>
`
}
`}
${when(
this.configId,
() => html`
@ -692,14 +690,12 @@ export class CrawlConfigEditor extends LiteElement {
?disabled=${this.isSubmitting || this.formHasError}
?loading=${this.isSubmitting}
>
${
this.formState.scheduleType === "now" ||
this.formState.runNow
? msg("Save & Run Crawl")
: this.formState.scheduleType === "none"
? msg("Save Workflow")
: msg("Save & Schedule Crawl")
}
${this.formState.scheduleType === "now" ||
this.formState.runNow
? msg("Save & Run Crawl")
: this.formState.scheduleType === "none"
? msg("Save Workflow")
: msg("Save & Schedule Crawl")}
</sl-button>`
: html`
<div>
@ -1058,11 +1054,9 @@ https://example.net`}
<btrix-details ?open=${exclusions.length > 0}>
<span slot="title"
>${msg("Exclusions")}
${
exclusions.length
? html`<btrix-badge>${exclusions.length}</btrix-badge>`
: ""
}</span
${exclusions.length
? html`<btrix-badge>${exclusions.length}</btrix-badge>`
: ""}</span
>
<div class="grid grid-cols-5 gap-4 py-2">
${this.renderFormCol(html`
@ -1099,11 +1093,9 @@ https://example.net`}
<btrix-details>
<span slot="title">
${msg("Additional URLs")}
${
additionalUrlList.length
? html`<btrix-badge>${additionalUrlList.length}</btrix-badge>`
: ""
}
${additionalUrlList.length
? html`<btrix-badge>${additionalUrlList.length}</btrix-badge>`
: ""}
</span>
<div class="grid grid-cols-5 gap-4 py-2">
${this.renderFormCol(html`
@ -1184,11 +1176,9 @@ https://archiveweb.page/images/${"logo.svg"}`}
>
<span slot="suffix">${msg("pages")}</span>
<div slot="help-text">
${
minPages === 1
? msg(str`Minimum ${minPages} page`)
: msg(str`Minimum ${minPages} pages`)
}
${minPages === 1
? msg(str`Minimum ${minPages} page`)
: msg(str`Minimum ${minPages} pages`)}
</div>
</sl-input>
</sl-mutation-observer>
@ -1429,11 +1419,9 @@ https://archiveweb.page/images/${"logo.svg"}`}
${msg(
html`Schedule:
<span class="text-blue-500"
>${
utcSchedule
? humanizeSchedule(utcSchedule)
: msg("Invalid date")
}</span
>${utcSchedule
? humanizeSchedule(utcSchedule)
: msg("Invalid date")}</span
>.`
)}
</p>
@ -1441,11 +1429,9 @@ https://archiveweb.page/images/${"logo.svg"}`}
${msg(
html`Next scheduled run:
<span
>${
utcSchedule
? humanizeNextDate(utcSchedule)
: msg("Invalid date")
}</span
>${utcSchedule
? humanizeNextDate(utcSchedule)
: msg("Invalid date")}</span
>.`
)}
</p>
@ -1883,12 +1869,10 @@ https://archiveweb.page/images/${"logo.svg"}`}
const renderDetail = ({ loc, msg: detailMsg }: any) => html`
<li>
${
loc.some((v: string) => v === "seeds") &&
typeof loc[loc.length - 1] === "number"
? msg(str`Seed URL ${loc[loc.length - 1] + 1}: `)
: `${loc[loc.length - 1]}: `
}
${loc.some((v: string) => v === "seeds") &&
typeof loc[loc.length - 1] === "number"
? msg(str`Seed URL ${loc[loc.length - 1] + 1}: `)
: `${loc[loc.length - 1]}: `}
${detailMsg}
</li>
`;

View File

@ -13,7 +13,7 @@ export type OrgData = {
name: string;
users?: {
[id: string]: {
role: typeof AccessCode[UserRole];
role: (typeof AccessCode)[UserRole];
name: string;
email: string;
};

View File

@ -2,7 +2,7 @@ import type { AccessCode, UserRole, OrgData } from "./org";
export type UserOrg = OrgData & {
default?: boolean;
role: typeof AccessCode[UserRole];
role: (typeof AccessCode)[UserRole];
};
export type CurrentUser = {

View File

@ -1,19 +1,19 @@
import { AccessCode, UserRole } from "../types/org";
export * from "../types/org";
export function isOwner(accessCode?: typeof AccessCode[UserRole]): boolean {
export function isOwner(accessCode?: (typeof AccessCode)[UserRole]): boolean {
if (!accessCode) return false;
return accessCode === AccessCode.owner;
}
export function isAdmin(accessCode?: typeof AccessCode[UserRole]): boolean {
export function isAdmin(accessCode?: (typeof AccessCode)[UserRole]): boolean {
if (!accessCode) return false;
return accessCode >= AccessCode.owner;
}
export function isCrawler(accessCode?: typeof AccessCode[UserRole]): boolean {
export function isCrawler(accessCode?: (typeof AccessCode)[UserRole]): boolean {
if (!accessCode) return false;
return accessCode >= AccessCode.crawler;