).path;
- }
-
- if (!path) {
- console.debug("no path for thumbnail:", thumbnail);
- return;
- }
-
- const isSelected = path === selectedImgSrc;
-
- return html`
-
-
-
- `;
- };
-
- return html`
-
- ${when(this.collection?.thumbnail, (t) => thumbnail(t))}
- ${thumbnail(Thumbnail.Cyan)} ${thumbnail(Thumbnail.Green)}
- ${thumbnail(Thumbnail.Yellow)} ${thumbnail(Thumbnail.Orange)}
-
- `;
- }
-
private readonly renderShareLink = () => {
return html`
@@ -499,142 +239,4 @@ export class ShareCollection extends BtrixElement {
`;
};
-
- private async updateVisibility(access: CollectionAccess) {
- const prevValue = this.collection?.access;
-
- // Optimistic update
- if (this.collection) {
- this.collection = { ...this.collection, access };
- }
-
- try {
- await this.api.fetch<{ updated: boolean }>(
- `/orgs/${this.orgId}/collections/${this.collectionId}`,
- {
- method: "PATCH",
- body: JSON.stringify({ access }),
- },
- );
-
- this.dispatchEvent(new CustomEvent("btrix-change"));
-
- this.notify.toast({
- id: "collection-visibility-update-status",
- message: msg("Collection visibility updated."),
- variant: "success",
- icon: "check2-circle",
- });
- } catch (err) {
- console.debug(err);
-
- // Revert optimistic update
- if (this.collection && prevValue !== undefined) {
- this.collection = { ...this.collection, access: prevValue };
- }
-
- this.notify.toast({
- id: "collection-visibility-update-status",
- message: msg("Sorry, couldn't update visibility at this time."),
- variant: "danger",
- icon: "exclamation-octagon",
- });
- }
- }
-
- async updateThumbnail({
- defaultThumbnailName,
- }: {
- defaultThumbnailName: Thumbnail | null;
- }) {
- const prevValue = this.collection?.defaultThumbnailName;
-
- // Optimistic update
- if (this.collection) {
- this.collection = { ...this.collection, defaultThumbnailName };
- }
-
- try {
- await this.api.fetch<{ updated: boolean }>(
- `/orgs/${this.orgId}/collections/${this.collectionId}`,
- {
- method: "PATCH",
- body: JSON.stringify({ defaultThumbnailName }),
- },
- );
-
- this.dispatchEvent(new CustomEvent("btrix-change"));
-
- this.notify.toast({
- id: "collection-thumbnail-update-status",
- message: msg("Thumbnail updated."),
- variant: "success",
- icon: "check2-circle",
- });
- } catch (err) {
- console.debug(err);
-
- // Revert optimistic update
- if (this.collection && prevValue !== undefined) {
- this.collection = {
- ...this.collection,
- defaultThumbnailName: prevValue,
- };
- }
-
- this.notify.toast({
- id: "collection-thumbnail-update-status",
- message: msg("Sorry, couldn't update thumbnail at this time."),
- variant: "danger",
- icon: "exclamation-octagon",
- });
- }
- }
-
- async updateAllowDownload(allowPublicDownload: boolean) {
- const prevValue = this.collection?.allowPublicDownload;
-
- // Optimistic update
- if (this.collection) {
- this.collection = { ...this.collection, allowPublicDownload };
- }
-
- try {
- await this.api.fetch<{ updated: boolean }>(
- `/orgs/${this.orgId}/collections/${this.collectionId}`,
- {
- method: "PATCH",
- body: JSON.stringify({ allowPublicDownload }),
- },
- );
-
- this.dispatchEvent(new CustomEvent("btrix-change"));
-
- this.notify.toast({
- id: "collection-allow-public-download-update-status",
- message: allowPublicDownload
- ? msg("Download button enabled.")
- : msg("Download button hidden."),
- variant: "success",
- icon: "check2-circle",
- });
- } catch (err) {
- console.debug(err);
-
- // Revert optimistic update
- if (this.collection && prevValue !== undefined) {
- this.collection = {
- ...this.collection,
- allowPublicDownload: prevValue,
- };
- }
-
- this.notify.toast({
- id: "collection-allow-public-download-update-status",
- message: msg("Sorry, couldn't update download button at this time."),
- variant: "danger",
- icon: "exclamation-octagon",
- });
- }
- }
}
diff --git a/frontend/src/index.ts b/frontend/src/index.ts
index de489f9cab..dfc1693359 100644
--- a/frontend/src/index.ts
+++ b/frontend/src/index.ts
@@ -1,5 +1,6 @@
import "./utils/polyfills";
+import { provide } from "@lit/context";
import { localized, msg, str } from "@lit/localize";
import type {
SlDialog,
@@ -22,6 +23,7 @@ import "./assets/fonts/Inter/inter.css";
import "./assets/fonts/Recursive/recursive.css";
import "./styles.css";
+import { viewStateContext } from "./context/view-state";
import { OrgTab, RouteNamespace, ROUTES } from "./routes";
import type { UserInfo, UserOrg } from "./types/user";
import { pageView, type AnalyticsTrackProps } from "./utils/analytics";
@@ -98,6 +100,7 @@ export class App extends BtrixElement {
@state()
private translationReady = false;
+ @provide({ context: viewStateContext })
@state()
private viewState!: ViewState;
diff --git a/frontend/src/layouts/pageHeader.ts b/frontend/src/layouts/pageHeader.ts
index 028f92c684..ae47dd1979 100644
--- a/frontend/src/layouts/pageHeader.ts
+++ b/frontend/src/layouts/pageHeader.ts
@@ -86,11 +86,17 @@ export function pageBack({ href, content }: Breadcrumb) {
});
}
-export function pageTitle(title?: string | TemplateResult | typeof nothing) {
+export function pageTitle(
+ title?: string | TemplateResult | typeof nothing,
+ skeletonClass?: string,
+) {
return html`
${title ||
- html``}
+ html``}
`;
}
@@ -136,7 +142,7 @@ export function pageHeader({
${actions
- ? html`
+ ? html`
${actions}
`
: nothing}
diff --git a/frontend/src/layouts/pageSectionsWithNav.ts b/frontend/src/layouts/pageSectionsWithNav.ts
index 44c7db903f..577464ae6b 100644
--- a/frontend/src/layouts/pageSectionsWithNav.ts
+++ b/frontend/src/layouts/pageSectionsWithNav.ts
@@ -27,10 +27,11 @@ export function pageSectionsWithNav({
sticky && tw`lg:sticky lg:top-2 lg:self-start`,
placement === "start" ? tw`lg:max-w-[16.5rem]` : tw`lg:flex-row`,
)}
+ part="tabs"
>
${nav}
- ${main}
+ ${main}