Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SuaYoo committed Jan 7, 2025
1 parent d896faa commit 9891216
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 87 deletions.
2 changes: 1 addition & 1 deletion frontend/src/layouts/pageHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function pageHeader({
secondary?: Content;
actions?: Content;
border?: boolean;
classNames?: typeof tw;
classNames?: typeof tw | string;
}) {
return html`
<header
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/pages/account-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ export class AccountSettings extends BtrixElement {
title=${msg("Account Settings")}
></btrix-document-title>
${pageHeader(msg("Account Settings"), undefined, tw`mb-3 lg:mb-5`)}
${pageHeader({
title: msg("Account Settings"),
classNames: tw`mb-3 lg:mb-5`,
})}
<btrix-tab-list activePanel=${this.activeTab} hideIndicator>
<header slot="header" class="flex h-7 items-end justify-between">
Expand Down
43 changes: 21 additions & 22 deletions frontend/src/pages/org/archived-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,29 +264,28 @@ export class CrawlsList extends BtrixElement {
return html`
<main>
<div class="contents">
${pageHeader(
msg("Archived Items"),
when(
this.isCrawler,
() => html`
<sl-tooltip
content=${msg("Org Storage Full")}
?disabled=${!this.org?.storageQuotaReached}
>
<sl-button
size="small"
variant="primary"
@click=${() => (this.isUploadingArchive = true)}
?disabled=${isArchivingDisabled(this.org)}
${pageHeader({
title: msg("Archived Items"),
actions: this.isCrawler
? html`
<sl-tooltip
content=${msg("Org Storage Full")}
?disabled=${!this.org?.storageQuotaReached}
>
<sl-icon slot="prefix" name="upload"></sl-icon>
${msg("Upload WACZ")}
</sl-button>
</sl-tooltip>
`,
),
tw`mb-3`,
)}
<sl-button
size="small"
variant="primary"
@click=${() => (this.isUploadingArchive = true)}
?disabled=${isArchivingDisabled(this.org)}
>
<sl-icon slot="prefix" name="upload"></sl-icon>
${msg("Upload WACZ")}
</sl-button>
</sl-tooltip>
`
: nothing,
classNames: tw`mb-3`,
})}
<div class="mb-3 flex gap-2">
${listTypes.map(({ label, itemType, icon }) => {
const isSelected = itemType === this.itemType;
Expand Down
47 changes: 23 additions & 24 deletions frontend/src/pages/org/browser-profiles-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,29 @@ export class BrowserProfilesList extends BtrixElement {
}

render() {
return html`${pageHeader(
msg("Browser Profiles"),
when(
this.isCrawler,
() => html`
<sl-button
variant="primary"
size="small"
?disabled=${isArchivingDisabled(this.org)}
@click=${() => {
this.dispatchEvent(
new CustomEvent("select-new-dialog", {
detail: "browser-profile",
}) as SelectNewDialogEvent,
);
}}
>
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
${msg("New Browser Profile")}
</sl-button>
`,
),
tw`mb-3`,
)}
return html`${pageHeader({
title: msg("Browser Profiles"),
actions: this.isCrawler
? html`
<sl-button
variant="primary"
size="small"
?disabled=${isArchivingDisabled(this.org)}
@click=${() => {
this.dispatchEvent(
new CustomEvent("select-new-dialog", {
detail: "browser-profile",
}) as SelectNewDialogEvent,
);
}}
>
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
${msg("New Browser Profile")}
</sl-button>
`
: undefined,
classNames: tw`mb-3`,
})}
<div class="pb-1">${this.renderTable()}</div>`;
}

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/pages/org/collection-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import type { MarkdownEditor } from "@/components/ui/markdown-editor";
import type { PageChangeEvent } from "@/components/ui/pagination";
import { SelectCollectionAccess } from "@/features/collections/select-collection-access";
import type { ShareCollection } from "@/features/collections/share-collection";
import { pageHeader } from "@/layouts/page";
import { pageNav, type Breadcrumb } from "@/layouts/pageHeader";
import { pageHeader, pageNav, type Breadcrumb } from "@/layouts/pageHeader";
import type {
APIPaginatedList,
APIPaginationQuery,
Expand Down
19 changes: 8 additions & 11 deletions frontend/src/pages/org/collections-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,21 @@ export class CollectionsList extends BtrixElement {
render() {
return html`
<div class="contents">
${pageHeader(
msg("Collections"),
when(
this.isCrawler,
() => html`
<sl-button
${pageHeader({
title: msg("Collections"),
actions: this.isCrawler
? html` <sl-button
variant="primary"
size="small"
?disabled=${!this.org || this.org.readOnly}
@click=${() => (this.openDialogName = "create")}
>
<sl-icon slot="prefix" name="plus-lg"></sl-icon>
${msg("New Collection")}
</sl-button>
`,
),
tw`border-b-transparent`,
)}
</sl-button>`
: nothing,
classNames: tw`border-b-transparent`,
})}
</div>
<link rel="preload" as="image" href=${noCollectionsImg} />
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/pages/org/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { RouteNamespace } from "@/routes";
import type { PublicCollection } from "@/types/collection";
import type { PublicOrgCollections } from "@/types/org";
import { humanizeExecutionSeconds } from "@/utils/executionTimeFormatter";
import { tw } from "@/utils/tailwind";

type Metrics = {
storageUsedBytes: number;
Expand Down Expand Up @@ -84,9 +85,9 @@ export class Dashboard extends BtrixElement {
this.metrics.storageUsedBytes >= this.metrics.storageQuotaBytes;

return html`
${pageHeader(
this.userOrg?.name,
html`
${pageHeader({
title: this.userOrg?.name,
actions: html`
${when(
this.appState.isAdmin,
() =>
Expand Down Expand Up @@ -153,8 +154,8 @@ export class Dashboard extends BtrixElement {
</sl-dropdown>`,
)}
`,
"mb-6",
)}
classNames: tw`mb-6`,
})}
<main>
<div class="mb-10 flex flex-col gap-6 md:flex-row">
${this.renderCard(
Expand Down
34 changes: 18 additions & 16 deletions frontend/src/pages/org/settings/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { localized, msg, str } from "@lit/localize";
import type { SlInput } from "@shoelace-style/shoelace";
import { serialize } from "@shoelace-style/shoelace/dist/utilities/form.js";
import { html, unsafeCSS, type PropertyValues } from "lit";
import { html, nothing, unsafeCSS, type PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { choose } from "lit/directives/choose.js";
import { ifDefined } from "lit/directives/if-defined.js";
Expand Down Expand Up @@ -136,21 +136,23 @@ export class OrgSettings extends BtrixElement {
}

render() {
return html` ${pageHeader(
msg("Org Settings"),
when(
this.userInfo?.orgs && this.userInfo.orgs.length > 1 && this.userOrg,
(userOrg) => html`
<div class="text-neutral-400">
${msg(
html`Viewing
<strong class="font-medium">${userOrg.name}</strong>`,
)}
</div>
`,
),
tw`mb-3 lg:mb-5`,
)}
return html` ${pageHeader({
title: msg("Org Settings"),
actions:
this.userInfo?.orgs && this.userInfo.orgs.length > 1 && this.userOrg
? html`
<div class="text-neutral-400">
${msg(
html`Viewing
<strong class="font-medium"
>${this.userOrg.name}</strong
>`,
)}
</div>
`
: nothing,
classNames: tw`mb-3 lg:mb-5`,
})}
<btrix-tab-list activePanel=${this.activePanel} hideIndicator>
<header slot="header" class="flex h-7 items-end justify-between">
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/pages/org/workflows-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ export class WorkflowsList extends BtrixElement {
render() {
return html`
<div class="contents">
${pageHeader(
msg("Crawl Workflows"),
html`
${pageHeader({
title: msg("Crawl Workflows"),
actions: html`
${when(
this.appState.isAdmin,
() =>
Expand Down Expand Up @@ -293,8 +293,8 @@ export class WorkflowsList extends BtrixElement {
`,
)}
`,
tw`border-b-transparent`,
)}
classNames: tw`border-b-transparent`,
})}
<div class="sticky top-2 z-10 mb-3 rounded-lg border bg-neutral-50 p-4">
${this.renderControls()}
</div>
Expand Down

0 comments on commit 9891216

Please sign in to comment.