mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 15:19:08 +03:00
chore: update scheduled backups
This commit is contained in:
1 parent
c235affcf8
commit
915fdbfc23
2 files changed
+4
-30
No files matched your search
@@ -5,7 +5,6 @@ import { useRouter } from 'next/router'
|
||||
import { Badge, Button, IconDownload } from 'ui'
|
||||
|
||||
import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'
|
||||
import { useBackupDownloadMutation } from 'data/database/backup-download-mutation'
|
||||
import { useBackupRestoreMutation } from 'data/database/backup-restore-mutation'
|
||||
import { setProjectStatus } from 'data/projects/projects-query'
|
||||
import { useCheckPermissions, useStore } from 'hooks'
|
||||
@@ -42,19 +41,6 @@ const BackupItem = ({ projectRef, backup, index }: BackupItemProps) => {
|
||||
},
|
||||
})
|
||||
|
||||
const { mutate: downloadBackup, isLoading: isDownloading } = useBackupDownloadMutation({
|
||||
onSuccess: (res) => {
|
||||
const { fileUrl } = res
|
||||
|
||||
// Trigger browser download by create,trigger and remove tempLink
|
||||
const tempLink = document.createElement('a')
|
||||
tempLink.href = fileUrl
|
||||
document.body.appendChild(tempLink)
|
||||
tempLink.click()
|
||||
document.body.removeChild(tempLink)
|
||||
},
|
||||
})
|
||||
|
||||
const onRestoreClick = () => {
|
||||
confirmAlert({
|
||||
title: 'Confirm to restore',
|
||||
@@ -69,24 +55,12 @@ const BackupItem = ({ projectRef, backup, index }: BackupItemProps) => {
|
||||
if (backup.status === 'COMPLETED')
|
||||
return (
|
||||
<div className="flex space-x-4">
|
||||
{backup.data.canRestore && (
|
||||
<Button
|
||||
type="default"
|
||||
disabled={!canTriggerScheduledBackups || isRestoring || isDownloading}
|
||||
onClick={onRestoreClick}
|
||||
>
|
||||
Restore
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type="default"
|
||||
disabled={!canTriggerScheduledBackups || isRestoring || isDownloading}
|
||||
onClick={() => downloadBackup({ ref: projectRef, backup })}
|
||||
loading={isDownloading}
|
||||
icon={<IconDownload />}
|
||||
disabled={!canTriggerScheduledBackups || isRestoring}
|
||||
onClick={onRestoreClick}
|
||||
>
|
||||
Download
|
||||
Restore
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ export type Backup = components['schemas']['Backup']
|
||||
export async function restoreFromBackup({ ref, backup }: BackupRestoreVariables) {
|
||||
const { data, error } = await post('/platform/database/{ref}/backups/restore', {
|
||||
params: { path: { ref } },
|
||||
body: { ...backup, status: backup.status as unknown as string },
|
||||
body: { id: backup.id, isPhysicalBackup: backup.isPhysicalBackup },
|
||||
})
|
||||
if (error) throw error
|
||||
return data
|
||||
|
||||
Reference in new issue
Block a user