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,6 +111,9 @@ 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>
${when(
this.isCrawler || (!this.isCrawler && this.collection?.isPublic),
() => html`
<sl-button <sl-button
variant="primary" variant="primary"
size="small" size="small"
@ -119,6 +122,8 @@ export class CollectionDetail extends LiteElement {
<sl-icon name="box-arrow-up" slot="prefix"></sl-icon> <sl-icon name="box-arrow-up" slot="prefix"></sl-icon>
Share Share
</sl-button> </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,13 +185,19 @@ 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"> : html`<p class="mb-3">
${msg( ${msg(
"Make this collection shareable to enable a public viewing link." "Make this collection shareable to enable a public viewing link."
)} )}
</p>`} </p>`
}
${when(
this.isCrawler,
() =>
html`
<div class="mb-5"> <div class="mb-5">
<sl-switch <sl-switch
?checked=${this.collection?.isPublic} ?checked=${this.collection?.isPublic}
@ -195,6 +206,9 @@ export class CollectionDetail extends LiteElement {
>${msg("Collection is Shareable")}</sl-switch >${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">
<sl-button size="small" @click=${() => (this.showShareInfo = false)} <sl-button size="small" @click=${() => (this.showShareInfo = false)}