@@ -13,23 +13,14 @@ import {
1313 TrashIcon ,
1414 XIcon ,
1515} from ' @modrinth/assets'
16- import {
17- ButtonStyled ,
18- commonMessages ,
19- injectNotificationManager ,
20- OverflowMenu ,
21- ProgressBar ,
22- } from ' @modrinth/ui'
16+ import { ButtonStyled , commonMessages , OverflowMenu , ProgressBar } from ' @modrinth/ui'
2317import type { Backup } from ' @modrinth/utils'
2418import { defineMessages , useVIntl } from ' @vintl/vintl'
2519import dayjs from ' dayjs'
26- import { computed , ref } from ' vue'
27-
28- import type { ModrinthServer } from ' ~/composables/servers/modrinth-servers.ts'
20+ import { computed } from ' vue'
2921
3022const flags = useFeatureFlags ()
3123const { formatMessage } = useVIntl ()
32- const { addNotification } = injectNotificationManager ()
3324
3425const emit = defineEmits <{
3526 (e : ' download' | ' rename' | ' restore' | ' lock' | ' retry' ): void
@@ -42,13 +33,11 @@ const props = withDefaults(
4233 preview? : boolean
4334 kyrosUrl? : string
4435 jwt? : string
45- server? : ModrinthServer
4636 }>(),
4737 {
4838 preview: false ,
4939 kyrosUrl: undefined ,
5040 jwt: undefined ,
51- server: undefined ,
5241 },
5342)
5443
@@ -135,48 +124,7 @@ const messages = defineMessages({
135124 id: ' servers.backups.item.retry' ,
136125 defaultMessage: ' Retry' ,
137126 },
138- downloadingBackup: {
139- id: ' servers.backups.item.downloading-backup' ,
140- defaultMessage: ' Downloading backup...' ,
141- },
142- downloading: {
143- id: ' servers.backups.item.downloading' ,
144- defaultMessage: ' Downloading' ,
145- },
146127})
147-
148- const downloadingState = ref <{ progress: number ; state: string } | undefined >(undefined )
149-
150- const downloading = computed (() => downloadingState .value )
151-
152- const handleDownload = async () => {
153- if (! props .server ?.backups || downloading .value ) {
154- return
155- }
156-
157- downloadingState .value = { progress: 0 , state: ' ongoing' }
158-
159- try {
160- const download = props .server .backups .downloadBackup (props .backup .id , props .backup .name )
161-
162- download .onProgress ((p ) => {
163- downloadingState .value = { progress: p .progress , state: ' ongoing' }
164- })
165-
166- await download .promise
167-
168- emit (' download' )
169- } catch (error ) {
170- console .error (' Failed to download backup:' , error )
171- addNotification ({
172- type: ' error' ,
173- title: ' Download failed' ,
174- text: error instanceof Error ? error .message : ' Failed to download backup' ,
175- })
176- } finally {
177- downloadingState .value = undefined
178- }
179- }
180128 </script >
181129<template >
182130 <div
@@ -244,15 +192,6 @@ const handleDownload = async () => {
244192 class =" max-w-full"
245193 />
246194 </div >
247- <div v-else-if =" downloading" class =" col-span-2 flex flex-col gap-3 text-blue" >
248- {{ formatMessage(messages.downloadingBackup) }}
249- <ProgressBar
250- :progress =" downloading.progress >= 0 ? downloading.progress : 0"
251- color =" blue"
252- :waiting =" downloading.progress <= 0"
253- class =" max-w-full"
254- />
255- </div >
256195 <template v-else >
257196 <div class =" col-span-2" >
258197 {{ dayjs(backup.created_at).format('MMMM D, YYYY [at] h:mm A') }}
@@ -284,32 +223,34 @@ const handleDownload = async () => {
284223 </button >
285224 </ButtonStyled >
286225 <template v-else >
287- <ButtonStyled v-show =" !downloading" >
288- <button :disabled =" !server?.backups" @click =" handleDownload" >
226+ <ButtonStyled >
227+ <a
228+ :class =" {
229+ disabled: !kyrosUrl || !jwt,
230+ }"
231+ :href =" `https://${kyrosUrl}/modrinth/v0/backups/${backup.id}/download?auth=${jwt}`"
232+ @click =" () => emit('download')"
233+ >
289234 <DownloadIcon />
290235 {{ formatMessage(commonMessages.downloadButton) }}
291- </button >
236+ </a >
292237 </ButtonStyled >
293238 <ButtonStyled circular type =" transparent" >
294239 <OverflowMenu
295240 :options =" [
296- {
297- id: 'rename',
298- action: () => emit('rename'),
299- disabled: !!restoring || !!downloading,
300- },
241+ { id: 'rename', action: () => emit('rename') },
301242 {
302243 id: 'restore',
303244 action: () => emit('restore'),
304- disabled: !!restoring || !!downloading ,
245+ disabled: !!restoring,
305246 },
306- { id: 'lock', action: () => emit('lock'), disabled: !!restoring || !!downloading },
247+ { id: 'lock', action: () => emit('lock') },
307248 { divider: true },
308249 {
309250 id: 'delete',
310251 color: 'red',
311252 action: () => emit('delete'),
312- disabled: !!restoring || !!downloading ,
253+ disabled: !!restoring,
313254 },
314255 ]"
315256 >
0 commit comments