Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/frontend/src/pages/[type]/[id]/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<a
class="ml-auto"
:href="createDownloadUrl(version)"
:download="getPrimaryFile(version).filename"
:title="`Download ${version.name}`"
>
<DownloadIcon aria-hidden="true" />
Expand Down Expand Up @@ -231,6 +232,10 @@ watch(
{ immediate: true },
)
function getPrimaryFile(version) {
return version.files.find((x) => x.primary) || version.files[0]
}
function createDownloadUrl(version) {
return createProjectDownloadUrl(getPrimaryFile(version).url, {
reason: cdnDownloadReason.value,
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/pages/[type]/[id]/settings/versions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
color: 'primary',
hoverFilled: true,
link: createDownloadUrl(version),
download: getPrimaryFile(version).filename,
action: () => {
emit('onDownload')
},
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/src/pages/[type]/[id]/version/[version].vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<a
v-tooltip="primaryFile.filename + ' (' + formatBytes(primaryFile.size) + ')'"
:href="decoratedPrimaryFileUrl"
:download="primaryFile.filename"
@click="emit('onDownload')"
>
<DownloadIcon aria-hidden="true" />
Expand Down Expand Up @@ -307,6 +308,7 @@
:href="decorateDownloadUrl(file.url)"
class="raised-button"
:title="`Download ${file.filename}`"
:download="file.filename"
tabindex="0"
>
<DownloadIcon aria-hidden="true" />
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/src/pages/[type]/[id]/versions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<a
v-tooltip="`Download`"
:href="createDownloadUrl(version)"
:download="getPrimaryFile(version).filename"
class="hover:!bg-button-bg [&>svg]:!text-green"
aria-label="Download"
@click="emit('onDownload')"
Expand Down Expand Up @@ -101,6 +102,7 @@
color: 'primary',
hoverFilled: true,
link: createDownloadUrl(version),
download: getPrimaryFile(version).filename,
action: () => {
emit('onDownload')
},
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/src/components/base/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const props = defineProps({
type: Boolean,
default: false,
},
download: {
type: String,
default: null,
},
action: {
type: Function,
default: null,
Expand Down Expand Up @@ -106,6 +110,7 @@ const classes = computed(() => {
class="btn"
:class="classes"
:href="disabled ? undefined : link"
:download="download || undefined"
:target="external ? '_blank' : '_self'"
@click="
(event) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/base/OverflowMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
: undefined
"
:link="option.link ? option.link : undefined"
:download="option.download ? option.download : undefined"
:external="option.external ? option.external : false"
:disabled="option.disabled"
@click="
Expand Down Expand Up @@ -76,6 +77,7 @@ interface Item extends BaseOption {
icon?: Component
action?: (event?: MouseEvent) => void
link?: string
download?: string
external?: boolean
color?:
| 'primary'
Expand Down
16 changes: 13 additions & 3 deletions packages/ui/src/components/version/VersionSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
</p>
</div>
<ButtonStyled color="brand">
<a :href="downloadUrl" class="min-w-0" @click="emit('onDownload')">
<a
:href="downloadUrl"
:download="primaryFilename"
class="min-w-0"
@click="emit('onDownload')"
>
<DownloadIcon aria-hidden="true" /> Download
</a>
</ButtonStyled>
Expand Down Expand Up @@ -42,12 +47,17 @@ const props = defineProps<{
decorateDownloadUrl?: (url: string) => string
}>()

const primaryFile = computed<VersionFile>(
() => props.version.files.find((x) => x.primary) || props.version.files[0],
)

const downloadUrl = computed(() => {
const primary: VersionFile = props.version.files.find((x) => x.primary) || props.version.files[0]
const raw = primary.url
const raw = primaryFile.value.url
return props.decorateDownloadUrl ? props.decorateDownloadUrl(raw) : raw
})

const primaryFilename = computed(() => primaryFile.value.filename)

const emit = defineEmits<{
onDownload: []
onNavigate: [url: string]
Expand Down
Loading