Skip to content

Commit 55b7727

Browse files
committed
update item
1 parent 78d040a commit 55b7727

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

frontend/src/pages/org/archived-item-detail/archived-item-detail.ts

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ export class ArchivedItemDetail extends BtrixElement {
130130
return `auth_bearer=${this.authState?.headers.Authorization.split(" ")[1]}`;
131131
}
132132

133+
private get itemDownload() {
134+
let path = "";
135+
let name = "";
136+
137+
if (this.hasFiles(this.item)) {
138+
if (this.item.resources.length > 1) {
139+
path = `/api/orgs/${this.orgId}/all-crawls/${this.itemId}/download?${this.authQuery}`;
140+
name = `${this.itemId}.wacz`;
141+
} else {
142+
const file = this.item.resources[0];
143+
144+
path = file.path;
145+
name = file.name;
146+
}
147+
}
148+
149+
return { path, name };
150+
}
151+
133152
private get listUrl(): string {
134153
let path = "items";
135154
if (this.workflowId) {
@@ -618,6 +637,8 @@ export class ArchivedItemDetail extends BtrixElement {
618637
private renderMenu() {
619638
if (!this.item) return;
620639

640+
const { path, name } = this.itemDownload;
641+
621642
return html`
622643
<sl-dropdown placement="bottom-end" distance="4" hoist>
623644
<sl-button slot="trigger" size="small" caret
@@ -650,10 +671,7 @@ export class ArchivedItemDetail extends BtrixElement {
650671
</btrix-menu-item-link>
651672
`,
652673
)}
653-
<btrix-menu-item-link
654-
href=${`/api/orgs/${this.orgId}/all-crawls/${this.itemId}/download?${this.authQuery}`}
655-
download
656-
>
674+
<btrix-menu-item-link href=${path} download=${name}>
657675
<sl-icon name="cloud-download" slot="prefix"></sl-icon>
658676
${msg("Download Item")}
659677
${this.item?.fileSize
@@ -1023,33 +1041,18 @@ export class ArchivedItemDetail extends BtrixElement {
10231041
private renderDownloadFiles() {
10241042
if (!this.hasFiles(this.item)) return;
10251043

1026-
if (this.item.resources.length > 1) {
1027-
return html`<sl-tooltip content=${msg("Download Files as Multi-WACZ")}>
1028-
<sl-button
1029-
href=${`/api/orgs/${this.orgId}/all-crawls/${this.itemId}/download?${this.authQuery}`}
1030-
download=${`browsertrix-${this.itemId}.wacz`}
1031-
size="small"
1032-
variant="primary"
1033-
>
1034-
<sl-icon slot="prefix" name="cloud-download"></sl-icon>
1035-
${msg("Download Files")}
1036-
</sl-button>
1037-
</sl-tooltip>`;
1038-
}
1039-
1040-
const file = this.item.resources[0];
1044+
const singleFile = this.item.resources.length === 1;
1045+
const { path, name } = this.itemDownload;
10411046

1042-
return html`
1043-
<sl-button
1044-
href=${file.path}
1045-
download=${file.name}
1046-
size="small"
1047-
variant="primary"
1048-
>
1047+
return html`<sl-tooltip
1048+
content=${msg("Download Files as Multi-WACZ")}
1049+
?disabled=${singleFile}
1050+
>
1051+
<sl-button href=${path} download=${name} size="small" variant="primary">
10491052
<sl-icon slot="prefix" name="cloud-download"></sl-icon>
1050-
${msg("Download File")}
1053+
${singleFile ? msg("Download File") : msg("Download Files")}
10511054
</sl-button>
1052-
`;
1055+
</sl-tooltip>`;
10531056
}
10541057

10551058
private renderLogs() {

0 commit comments

Comments
 (0)