import { PermissionAction, SupportCategories } from '@supabase/shared-types/out/constants' import { Download, MoreVertical, Trash } from 'lucide-react' import { useState } from 'react' import { useParams } from 'common' import { DeleteProjectModal } from 'components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal' import { SupportLink } from 'components/interfaces/Support/SupportLink' 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' import { Button, CriticalIcon, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'ui' export const PauseFailedState = () => { const { ref } = useParams() const { data: project } = useSelectedProjectQuery() const [visible, setVisible] = useState(false) const { can: canDeleteProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', { resource: { project_id: project?.id }, }) const { data } = 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) return console.error('No available backups to download') downloadBackup({ ref, backup: backups[0] }) } return ( <>

Something went wrong while pausing your project

Your project's data is intact, but your project is inaccessible due to the failure while pausing. Database backups for this project can still be accessed{' '} here.

Please contact support for assistance.

} loading={isDownloading} disabled={backups.length === 0} tooltip={{ content: { side: 'bottom', text: data?.status === 'physical-backups-enabled' ? 'No available backups to download as project is on physical backups' : backups.length === 0 ? 'No available backups to download' : undefined, }, }} onClick={onClickDownloadBackup} > Download backup
setVisible(false)} /> ) }