Disable collection share button actions for viewer users (#1282)

Closes #1273 
- Viewers can see the share button and the dialogue's sharing info if the collection is sharable
- Viewers can't see or change the share toggle
- Viewers can't see the share button if the collection is not sharable
This commit is contained in:
Henry Wilkinson 2023-10-16 13:50:33 -04:00 committed by GitHub
parent a295f5d05d
commit 6d6fa03ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,14 +111,19 @@ export class CollectionDetail extends LiteElement {
html`<sl-skeleton class="w-96"></sl-skeleton>`} html`<sl-skeleton class="w-96"></sl-skeleton>`}
</h1> </h1>
</div> </div>
<sl-button ${when(
variant="primary" this.isCrawler || (!this.isCrawler && this.collection?.isPublic),
size="small" () => html`
@click=${() => (this.showShareInfo = true)} <sl-button
> variant="primary"
<sl-icon name="box-arrow-up" slot="prefix"></sl-icon> size="small"
Share @click=${() => (this.showShareInfo = true)}
</sl-button> >
<sl-icon name="box-arrow-up" slot="prefix"></sl-icon>
Share
</sl-button>
`
)}
${when(this.isCrawler, this.renderActions)} ${when(this.isCrawler, this.renderActions)}
</header> </header>
<div class="border rounded-lg py-2 px-4 mb-3"> <div class="border rounded-lg py-2 px-4 mb-3">
@ -180,20 +185,29 @@ export class CollectionDetail extends LiteElement {
@sl-request-close=${() => (this.showShareInfo = false)} @sl-request-close=${() => (this.showShareInfo = false)}
style="--width: 32rem;" style="--width: 32rem;"
> >
${this.collection?.isPublic ${
? "" this.collection?.isPublic
: html`<p class="mb-3"> ? ""
${msg( : html`<p class="mb-3">
"Make this collection shareable to enable a public viewing link." ${msg(
)} "Make this collection shareable to enable a public viewing link."
</p>`} )}
<div class="mb-5"> </p>`
<sl-switch }
?checked=${this.collection?.isPublic} ${when(
@sl-change=${(e: CustomEvent) => this.isCrawler,
this.onTogglePublic((e.target as SlCheckbox).checked)} () =>
>${msg("Collection is Shareable")}</sl-switch html`
> <div class="mb-5">
<sl-switch
?checked=${this.collection?.isPublic}
@sl-change=${(e: CustomEvent) =>
this.onTogglePublic((e.target as SlCheckbox).checked)}
>${msg("Collection is Shareable")}</sl-switch
>
</div>
`
)}
</div> </div>
${when(this.collection?.isPublic, this.renderShareInfo)} ${when(this.collection?.isPublic, this.renderShareInfo)}
<div slot="footer" class="flex justify-end"> <div slot="footer" class="flex justify-end">