Hide QA UI from users without crawler role (#1733)

Resolves https://github.com/webrecorder/browsertrix/issues/1732

- Hides QA tab and QA review page from users with viewer role
- Fixes empty menu button rendering for viewers on archived item detail
page
This commit is contained in:
sua yoo 2024-04-23 13:01:23 -07:00 committed by GitHub
parent 1f4440db64
commit 9836e750c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 14 deletions

View File

@ -249,10 +249,14 @@ export class ArchivedItemDetail extends TailwindElement {
render() { render() {
const authToken = this.authState!.headers.Authorization.split(" ")[1]; const authToken = this.authState!.headers.Authorization.split(" ")[1];
let sectionContent: string | TemplateResult = ""; let sectionContent: string | TemplateResult<1> = "";
switch (this.activeTab) { switch (this.activeTab) {
case "qa": case "qa": {
if (!this.isCrawler) {
sectionContent = "";
break;
}
sectionContent = this.renderPanel( sectionContent = this.renderPanel(
html`${this.renderTitle( html`${this.renderTitle(
html`${msg("Quality Assurance")} html`${msg("Quality Assurance")}
@ -276,6 +280,7 @@ export class ArchivedItemDetail extends TailwindElement {
`, `,
); );
break; break;
}
case "replay": case "replay":
sectionContent = this.renderPanel(msg("Replay"), this.renderReplay(), [ sectionContent = this.renderPanel(msg("Replay"), this.renderReplay(), [
tw`overflow-hidden rounded-lg border`, tw`overflow-hidden rounded-lg border`,
@ -478,7 +483,7 @@ export class ArchivedItemDetail extends TailwindElement {
label: msg("Overview"), label: msg("Overview"),
})} })}
${when( ${when(
this.itemType === "crawl", this.itemType === "crawl" && this.isCrawler,
() => html` () => html`
${renderNavItem({ ${renderNavItem({
section: "qa", section: "qa",
@ -553,11 +558,13 @@ export class ArchivedItemDetail extends TailwindElement {
</sl-button-group> </sl-button-group>
` `
: ""} : ""}
${this.crawl && this.isCrawler ${this.isCrawler
? this.renderMenu() ? this.crawl
: html`<sl-skeleton ? this.renderMenu()
class="h-8 w-24 [--border-radius:theme(borderRadius.sm)]" : html`<sl-skeleton
></sl-skeleton>`} class="h-8 w-24 [--border-radius:theme(borderRadius.sm)]"
></sl-skeleton>`
: nothing}
</div> </div>
</header> </header>
`; `;

View File

@ -99,9 +99,6 @@ export class ArchivedItemQA extends TailwindElement {
@property({ type: String }) @property({ type: String })
qaRunId?: string; qaRunId?: string;
@property({ type: Boolean })
isCrawler = false;
@property({ type: String }) @property({ type: String })
tab: QATypes.QATab = "screenshots"; tab: QATypes.QATab = "screenshots";
@ -838,7 +835,7 @@ export class ArchivedItemQA extends TailwindElement {
); );
} catch { } catch {
this.notify.toast({ this.notify.toast({
message: msg("Sorry, couldn't retrieve QA data at this time."), message: msg("Sorry, couldn't retrieve analysis runs at this time."),
variant: "danger", variant: "danger",
icon: "exclamation-octagon", icon: "exclamation-octagon",
}); });

View File

@ -527,7 +527,13 @@ export class Org extends LiteElement {
if (params.itemId) { if (params.itemId) {
if (params.qaTab) { if (params.qaTab) {
return html` <btrix-archived-item-qa if (!this.isCrawler) {
return html`<btrix-not-found
class="flex items-center justify-center"
></btrix-not-found>`;
}
return html`<btrix-archived-item-qa
class="flex-1" class="flex-1"
.authState=${this.authState!} .authState=${this.authState!}
orgId=${this.orgId} orgId=${this.orgId}
@ -535,7 +541,6 @@ export class Org extends LiteElement {
itemPageId=${ifDefined(params.itemPageId)} itemPageId=${ifDefined(params.itemPageId)}
qaRunId=${ifDefined(params.qaRunId)} qaRunId=${ifDefined(params.qaRunId)}
tab=${params.qaTab} tab=${params.qaTab}
?isCrawler=${this.isCrawler}
></btrix-archived-item-qa>`; ></btrix-archived-item-qa>`;
} }