Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Chore/add get restore initiated event endpoint (#43485)

Joshen Lim00ca386e241d
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
index 798d65e20dc..1b2021d128d 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
@@ -1,5 +1,4 @@
import { ICON_SIZE, ICON_STROKE_WIDTH } from 'components/interfaces/Sidebar'
-import { useGenerateSettingsMenu } from 'components/layouts/ProjectSettingsLayout/SettingsMenu.utils'
import type { Route } from 'components/ui/ui.types'
import { EditorIndexPageLink } from 'data/prefetchers/project.$ref.editor'
import type { Project } from 'data/projects/project-detail-query'
diff --git a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
index 35944239661..3538e4cb8ea 100644
--- a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
@@ -1,6 +1,3 @@
-import { CheckCircle, Download, Loader } from 'lucide-react'
-import { useEffect, useState } from 'react'
-
import { SupportCategories } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { SupportLink } from 'components/interfaces/Support/SupportLink'
@@ -9,11 +6,24 @@ import { useBackupDownloadMutation } from 'data/database/backup-download-mutatio
import { useDownloadableBackupQuery } from 'data/database/backup-query'
import { useInvalidateProjectDetailsQuery } from 'data/projects/project-detail-query'
import { useProjectStatusQuery } from 'data/projects/project-status-query'
+import dayjs from 'dayjs'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { PROJECT_STATUS } from 'lib/constants'
-import { Button } from 'ui'
+import { CheckCircle, Download, Loader } from 'lucide-react'
+import { useEffect, useState } from 'react'
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogSection,
+ DialogSectionSeparator,
+ DialogTitle,
+ DialogTrigger,
+} from 'ui'
-const RestoringState = () => {
+export const RestoringState = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
@@ -37,12 +47,8 @@ const RestoringState = () => {
}
)
- useEffect(() => {
- if (!isProjectStatusSuccess) return
- if (projectStatusData.status === PROJECT_STATUS.ACTIVE_HEALTHY) {
- setIsCompleted(true)
- }
- }, [isProjectStatusSuccess, projectStatusData, ref, invalidateProjectDetailsQuery])
+ const restoreInitiatedSinceMinutes = dayjs().diff(dayjs.utc(project?.updated_at), 'minute')
+ const showSupportCta = restoreInitiatedSinceMinutes >= 30
const { mutate: downloadBackup, isPending: isDownloading } = useBackupDownloadMutation({
onSuccess: (res) => {
@@ -70,6 +76,12 @@ const RestoringState = () => {
if (ref) await invalidateProjectDetailsQuery(ref)
}
+ useEffect(() => {
+ if (isProjectStatusSuccess && projectStatusData.status === PROJECT_STATUS.ACTIVE_HEALTHY) {
+ setIsCompleted(true)
+ }
+ }, [isProjectStatusSuccess, projectStatusData])
+
return (
<div className="flex items-center justify-center h-full">
<div className="bg-surface-100 border border-overlay rounded-md w-3/4 lg:w-1/2">
@@ -110,17 +122,43 @@ const RestoringState = () => {
</div>
</div>
<div className="border-t border-overlay flex items-center justify-end py-4 px-8 gap-x-2">
- <Button asChild type="default">
- <SupportLink
- queryParams={{
- category: SupportCategories.DATABASE_UNRESPONSIVE,
- projectRef: project?.ref,
- subject: 'Ongoing restoration for project',
- }}
- >
- Contact support
- </SupportLink>
- </Button>
+ {showSupportCta && (
+ <Dialog>
+ <DialogTrigger>
+ <Button type="text" className="text-foreground-light">
+ Taking longer than expected?
+ </Button>
+ </DialogTrigger>
+ <DialogContent aria-describedby={undefined}>
+ <DialogHeader>
+ <DialogTitle>Restoration taking longer than expected?</DialogTitle>
+ </DialogHeader>
+ <DialogSectionSeparator />
+ <DialogSection>
+ <p className="text-sm">
+ Restores may take from a minutes up to several hours depending on the size
+ of your database. However, if the restoration process is taking far longer
+ than expected for the size of your database, you may reach out to us via
+ Support for help.
+ </p>
+ </DialogSection>
+ <DialogFooter>
+ <Button asChild type="default">
+ <SupportLink
+ queryParams={{
+ category: SupportCategories.DATABASE_UNRESPONSIVE,
+ projectRef: project?.ref,
+ subject: 'Ongoing restoration for project',
+ }}
+ >
+ Contact support
+ </SupportLink>
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )}
+
<ButtonTooltip
type="default"
icon={<Download />}
@@ -144,5 +182,3 @@ const RestoringState = () => {
</div>
)
}
-
-export default RestoringState
diff --git a/apps/studio/components/layouts/ProjectLayout/index.tsx b/apps/studio/components/layouts/ProjectLayout/index.tsx
index e805fd4d9df..eff94d559a0 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.tsx
@@ -34,7 +34,7 @@ import { PausingState } from './PausingState'
import { ResizingState } from './ResizingState'
import RestartingState from './RestartingState'
import { RestoreFailedState } from './RestoreFailedState'
-import RestoringState from './RestoringState'
+import { RestoringState } from './RestoringState'
import { UpgradingState } from './UpgradingState'
import { CreateBranchModal } from '@/components/interfaces/BranchManagement/CreateBranchModal'
import { ProjectAPIDocs } from '@/components/interfaces/ProjectAPIDocs/ProjectAPIDocs'
diff --git a/apps/studio/data/projects/project-status-query.ts b/apps/studio/data/projects/project-status-query.ts
index 07beb16804d..4da0f7cc4dd 100644
--- a/apps/studio/data/projects/project-status-query.ts
+++ b/apps/studio/data/projects/project-status-query.ts
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query'
-
import { get, handleError } from 'data/fetchers'
import type { ResponseError, UseCustomQueryOptions } from 'types'
+
import { projectKeys } from './keys'
export type ProjectStatusVariables = {