@@ -130,6 +130,25 @@ export class ArchivedItemDetail extends BtrixElement {
130
130
return `auth_bearer=${ this . authState ?. headers . Authorization . split ( " " ) [ 1 ] } ` ;
131
131
}
132
132
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
+
133
152
private get listUrl ( ) : string {
134
153
let path = "items" ;
135
154
if ( this . workflowId ) {
@@ -618,6 +637,8 @@ export class ArchivedItemDetail extends BtrixElement {
618
637
private renderMenu ( ) {
619
638
if ( ! this . item ) return ;
620
639
640
+ const { path, name } = this . itemDownload ;
641
+
621
642
return html `
622
643
<sl-dropdown placement="bottom-end" distance="4" hoist>
623
644
<sl-button slot="trigger" size="small" caret
@@ -650,10 +671,7 @@ export class ArchivedItemDetail extends BtrixElement {
650
671
</btrix-menu-item-link>
651
672
` ,
652
673
) }
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 } >
657
675
<sl-icon name="cloud-download" slot="prefix"></sl-icon>
658
676
${ msg ( "Download Item" ) }
659
677
${ this . item ?. fileSize
@@ -1023,33 +1041,18 @@ export class ArchivedItemDetail extends BtrixElement {
1023
1041
private renderDownloadFiles ( ) {
1024
1042
if ( ! this . hasFiles ( this . item ) ) return ;
1025
1043
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 ;
1041
1046
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">
1049
1052
<sl-icon slot="prefix" name="cloud-download"></sl-icon>
1050
- ${ msg ( "Download File" ) }
1053
+ ${ singleFile ? msg ( "Download File" ) : msg ( "Download Files ") }
1051
1054
</sl-button>
1052
- ` ;
1055
+ </sl-tooltip> ` ;
1053
1056
}
1054
1057
1055
1058
private renderLogs ( ) {
0 commit comments