Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ watch(

function download() {
const url = ProjectApi.constructDownloadProjectVersionUrl(
project.value?.namespace,
project.value?.name,
project.value?.id,
versionId.value
)
window.location.href = url
projectStore.downloadArchive({ url, versionId: versionId.value })
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ import { useProjectStore } from '@/modules/project/store'
export default defineComponent({
name: 'DownloadProgress',
computed: {
...mapState(useProjectStore, ['project', 'projectDownloading'])
...mapState(useProjectStore, [
'project',
'projectDownloading',
'projectDownloadingVersion'
])
},
methods: {
...mapActions(useProjectStore, ['cancelDownloadArchive']),
open() {
this.$toast.add({
group: 'download-progress',
severity: 'info',
summary: `Preparing archive`,
detail: `Your project ${this.project?.name} is being prepared for download.`,
summary: `Preparing to download your project ${
this.projectDownloadingVersion
? `(version ${this.projectDownloadingVersion})`
: ''
}`,
detail: `Your download will begin automatically once it's ready. Please keep this window open.`,
life: undefined
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ const downloadClick = (item: ProjectVersionsTableItem) => {
url: ProjectApi.constructDownloadProjectVersionUrl(
project.value.id,
item.name
)
),
versionId: item.name
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ export default defineComponent({
},
computed: {
...mapState(useProjectStore, ['project', 'versions']),
downloadUrl() {
return ProjectApi.constructDownloadProjectVersionUrl(
this.project.namespace,
this.project.name,
this.queryId
)
},
queryId(): string {
return this.$route.query.version_id as string
},
Expand Down Expand Up @@ -120,6 +113,7 @@ export default defineComponent({
},
methods: {
...mapActions(useNotificationStore, ['error']),
...mapActions(useProjectStore, ['downloadArchive']),
async getVersion() {
try {
const response = await ProjectApi.getProjectVersion(
Expand All @@ -134,7 +128,11 @@ export default defineComponent({
}
},
downloadVersion() {
window.location.href = this.downloadUrl
const url = ProjectApi.constructDownloadProjectVersionUrl(
this.project.id,
this.queryId
)
this.downloadArchive({ url, versionId: this.queryId })
}
}
})
Expand Down
13 changes: 9 additions & 4 deletions web-app/packages/lib/src/modules/project/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import keyBy from 'lodash/keyBy'
import omit from 'lodash/omit'
import { defineStore, getActivePinia } from 'pinia'

import { DropdownOption, errorUtils, permissionUtils } from '@/common'
import { DropdownOption, permissionUtils } from '@/common'
import { getErrorMessage } from '@/common/error_utils'
import { waitCursor } from '@/common/html_utils'
import { filesDiff } from '@/common/mergin_utils'
Expand Down Expand Up @@ -80,6 +80,7 @@ export interface ProjectState {
versionsChangesetLoading: boolean
collaborators: ProjectCollaborator[]
projectDownloading: boolean
projectDownloadingVersion: string
}

export const useProjectStore = defineStore('projectModule', {
Expand All @@ -106,7 +107,8 @@ export const useProjectStore = defineStore('projectModule', {
availableRoles: permissionUtils.getProjectRoleNameValues(),
versionsChangesetLoading: false,
collaborators: [],
projectDownloading: false
projectDownloading: false,
projectDownloadingVersion: null
}),

getters: {
Expand Down Expand Up @@ -708,12 +710,14 @@ export const useProjectStore = defineStore('projectModule', {
const notificationStore = useNotificationStore()
this.cancelDownloadArchive()
this.projectDownloading = true
if (payload.versionId) {
this.projectDownloadingVersion = payload.versionId
}

const errorMessage =
'Failed to download project archive. Please try again later.'
const exceedMessage =
'It seems like preparing your ZIP file is taking longer than expected. Please try again in a little while to download your file.'
const fileTooLargeMessage =
'The requested archive is too large to download. Please use direct download with python client or plugin instead.'

const delays = [...Array(3).fill(1000), ...Array(3).fill(3000), 5000]
let retryCount = 0
Expand Down Expand Up @@ -767,6 +771,7 @@ export const useProjectStore = defineStore('projectModule', {
downloadArchiveTimeout = null
}
this.projectDownloading = false
this.projectDownloadingVersion = null
},

constructDownloadProjectUrl(payload: { projectId: string }) {
Expand Down
1 change: 1 addition & 0 deletions web-app/packages/lib/src/modules/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export interface UpdatePublicFlagParams {

export interface DownloadPayload {
url: string
versionId?: string
}

export interface FetchProjectVersionsPayload {
Expand Down
Loading