import { PermissionAction, SupportCategories } from '@supabase/shared-types/out/constants' import { useParams } from 'common' import { Download, MoreVertical, Trash } from 'lucide-react' import { useState } from 'react' import { Button, CriticalIcon, Dialog, DialogContent, DialogHeader, DialogSection, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, } from 'ui' import { DeleteProjectModal } from '@/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal' import { SupportLink } from '@/components/interfaces/Support/SupportLink' import { LogicalBackupCliInstructions } from '@/components/layouts/ProjectLayout/LogicalBackupCliInstructions' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import { DropdownMenuItemTooltip } from '@/components/ui/DropdownMenuItemTooltip' import { InlineLink } from '@/components/ui/InlineLink' import { useBackupDownloadMutation } from '@/data/database/backup-download-mutation' import { useDownloadableBackupQuery } from '@/data/database/backup-query' import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' export const RestoreFailedState = () => { const { ref } = useParams() const { data: project } = useSelectedProjectQuery() const [visible, setVisible] = useState(false) const [showCliBackup, setShowCliBackup] = useState(false) const { can: canDeleteProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { resource: { project_id: project?.id }, }) const { data, isPending: isLoadingBackups } = useDownloadableBackupQuery({ projectRef: ref }) const backups = data?.backups ?? [] const { mutate: downloadBackup, isPending: 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 onClickDownloadBackup = () => { if (!ref) return console.error('Project ref is required') if (backups.length === 0 || data?.status === 'physical-backups-enabled') return setShowCliBackup(true) downloadBackup({ ref, backup: backups[0] }) } const downloadBackupTooltipText = isLoadingBackups ? undefined : data?.status === 'physical-backups-enabled' ? 'Project uses physical backups — click to see CLI backup instructions' : backups.length === 0 ? 'No downloadable backup available — click to see CLI backup instructions' : undefined return ( <>
Something went wrong while restoring your project
Your project's data is intact, but your project is inaccessible due to a
restoration failure. Database backups for this project can still be accessed{' '}
Please contact support for assistance.
Delete project
Project cannot be restored once it is deleted