Skip to content

Commit

Permalink
hide collection share buttons when collection is private
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-sg committed Feb 10, 2025
1 parent b233321 commit a2de997
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
30 changes: 2 additions & 28 deletions frontend/src/features/collections/share-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { collectionShareLink } from "./helpers/share-link";

import { BtrixElement } from "@/classes/BtrixElement";
import { ClipboardController } from "@/controllers/clipboard";
import { type EditCollectionDetail } from "@/pages/org/collection-detail";
import { AnalyticsTrackEvent } from "@/trackEvents";
import {
CollectionAccess,
Expand All @@ -18,7 +17,6 @@ import { track } from "@/utils/analytics";

/**
* @fires btrix-change
* @fires btrix-edit-collection {EditCollectionDetail}
*/
@localized()
@customElement("btrix-share-collection")
Expand Down Expand Up @@ -64,33 +62,9 @@ export class ShareCollection extends BtrixElement {
}

private renderButton() {
if (!this.collection) {
return html`
<sl-skeleton
effect="pulse"
class="h-[var(--sl-input-height-small)] w-20 [--border-radius:var(--sl-input-border-radius-small)]"
></sl-skeleton>
`;
}
if (!this.collection) return;

if (this.collection.access === CollectionAccess.Private) {
return html`
<sl-button
variant=${this.collection.crawlCount ? "primary" : "default"}
size="small"
@click=${() => {
this.dispatchEvent(
new CustomEvent<EditCollectionDetail>("btrix-edit-collection", {
detail: { tab: "sharing" },
}),
);
}}
>
<sl-icon name="box-arrow-up" slot="prefix"></sl-icon>
${msg("Share")}
</sl-button>
`;
}
if (this.collection.access === CollectionAccess.Private) return;

return html`
<div class="flex items-center gap-2">
Expand Down
11 changes: 0 additions & 11 deletions frontend/src/pages/org/collection-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ import { tw } from "@/utils/tailwind";
const ABORT_REASON_THROTTLE = "throttled";
const INITIAL_ITEMS_PAGE_SIZE = 20;

export type EditCollectionDetail = {
tab?: EditDialogTab;
};

export enum Tab {
Replay = "replay",
About = "about",
Expand Down Expand Up @@ -219,13 +215,6 @@ export class CollectionDetail extends BtrixElement {
e.stopPropagation();
void this.fetchCollection();
}}
@btrix-edit-collection=${async (
e: CustomEvent<EditCollectionDetail>,
) => {
this.editTab = e.detail.tab;
await this.updateComplete;
this.openDialogName = "edit";
}}
></btrix-share-collection>
${when(this.isCrawler, this.renderActions)}
</div>
Expand Down

0 comments on commit a2de997

Please sign in to comment.