Skip to content

Commit ca63b41

Browse files
committed
action menu:
- use downloadUrl for action menu download - don't show download menu if downloadUrl is null - don't show Archive Info if downloadUrl !== sourceUrl and in embed mode
1 parent 6493f99 commit ca63b41

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

src/item.ts

+33-21
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class Item extends LitElement {
114114
@property({ type: String })
115115
sourceUrl: string | null = null;
116116

117+
@property({ type: String })
118+
downloadUrl: string | null = null;
119+
117120
@property({ type: Object, attribute: false })
118121
loadInfo: LoadInfo | null = null;
119122

@@ -445,8 +448,16 @@ class Item extends LitElement {
445448
});
446449
}
447450

448-
if (!this.itemInfo!.title) {
449-
this.itemInfo!.title = this.itemInfo!.filename;
451+
const { title, name, filename, downloadUrl } = this.itemInfo!;
452+
453+
if (!title) {
454+
this.itemInfo!.title = name || filename;
455+
}
456+
457+
if (downloadUrl === null) {
458+
this.downloadUrl = null;
459+
} else {
460+
this.downloadUrl = downloadUrl || this.sourceUrl;
450461
}
451462

452463
if (this.embed === "replayonly" || this.embed === "replay-with-info") {
@@ -1349,11 +1360,11 @@ class Item extends LitElement {
13491360
<span>Purge Cache + Full Reload</span>
13501361
</a>`
13511362
: html``}
1352-
${(!this.editable && this.sourceUrl?.startsWith("http://")) ||
1353-
this.sourceUrl?.startsWith("https://")
1363+
${(!this.editable && this.downloadUrl?.startsWith("http://")) ||
1364+
this.downloadUrl?.startsWith("https://")
13541365
? html` <hr class="dropdown-divider" />
13551366
<a
1356-
href="${this.sourceUrl}"
1367+
href="${this.downloadUrl}"
13571368
role="button"
13581369
class="dropdown-item"
13591370
@keyup="${clickOnSpacebarPress}"
@@ -1375,24 +1386,25 @@ class Item extends LitElement {
13751386
<span class="menu-head">Capture Date</span>${dateStr}
13761387
</div>`
13771388
: ""}
1378-
${!this.editable
1389+
${!this.editable &&
1390+
(this.downloadUrl === this.sourceUrl || !this.embed)
13791391
? html` <a
1380-
href="#"
1381-
role="button"
1382-
class="dropdown-item"
1383-
@click="${this.onShowInfoDialog}"
1384-
>
1385-
<span class="icon is-small">
1386-
<fa-icon
1387-
class="has-text-grey"
1388-
aria-hidden="true"
1389-
.svg="${fasInfoIcon}"
1390-
></fa-icon>
1391-
</span>
1392-
<span>Archive Info</span>
1393-
</a>
1394-
<hr class="dropdown-divider" />`
1392+
href="#"
1393+
role="button"
1394+
class="dropdown-item"
1395+
@click="${this.onShowInfoDialog}"
1396+
>
1397+
<span class="icon is-small">
1398+
<fa-icon
1399+
class="has-text-grey"
1400+
aria-hidden="true"
1401+
.svg="${fasInfoIcon}"
1402+
></fa-icon>
1403+
</span>
1404+
<span>Archive Info</span>
1405+
</a>`
13951406
: ``}
1407+
<hr class="dropdown-divider" />
13961408
<a
13971409
href="#"
13981410
role="button"

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type ItemType = {
3333
name?: string;
3434
title?: string;
3535
loadUrl?: string;
36+
downloadUrl?: string | null;
3637
desc?: string;
3738
description?: string;
3839
resources?: { path: string; name: string }[];

0 commit comments

Comments
 (0)