Skip to content

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

R2NP: add 403 permissions or physical backups disabled handler (#31197)

Jordi Enricbbf806de3040
diff --git a/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx b/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx
index a4ffed86e90..7f685eb6989 100644
--- a/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx
+++ b/apps/studio/pages/project/[ref]/database/backups/restore-to-new-project.tsx
@@ -82,7 +82,7 @@ const RestoreToNewProject = () => {
PermissionAction.INFRA_EXECUTE,
'queue_job.restore.prepare'
)
- const hasPITREnabled = cloneBackups?.pitr_enabled
+ const PITR_ENABLED = cloneBackups?.pitr_enabled
const dbVersion = getDatabaseMajorVersion(project?.dbVersion ?? '')
const IS_PG15_OR_ABOVE = dbVersion >= 15
@@ -100,9 +100,10 @@ const RestoreToNewProject = () => {
refetchInterval,
refetchOnWindowFocus: false,
onSuccess: (data) => {
- const hasTransientState = data.clones.some((c) => c.status === 'IN_PROGRESS')
+ const hasTransientState = data?.clones.some((c) => c.status === 'IN_PROGRESS')
if (!hasTransientState) setRefetchInterval(false)
},
+ enabled: PHYSICAL_BACKUPS_ENABLED || PITR_ENABLED,
}
)
const IS_CLONED_PROJECT = (cloneStatus?.cloned_from?.source_project as any)?.ref ? true : false
@@ -179,6 +180,16 @@ const RestoreToNewProject = () => {
}
}
+ if (isFreePlan) {
+ return (
+ <UpgradeToPro
+ buttonText="Upgrade"
+ primaryText="Restore to a new project requires a pro plan or above."
+ secondaryText="To restore to a new project, you need to upgrade to a Pro plan and have physical backups enabled."
+ />
+ )
+ }
+
if (isOrioleDb) {
return (
<Admonition
@@ -191,10 +202,6 @@ const RestoreToNewProject = () => {
)
}
- if (isLoading) {
- return <GenericSkeletonLoader />
- }
-
if (!canReadPhysicalBackups) {
return <NoPermission resourceText="view backups" />
}
@@ -243,14 +250,8 @@ const RestoreToNewProject = () => {
)
}
- if (plan === 'free') {
- return (
- <UpgradeToPro
- buttonText="Upgrade"
- primaryText="Restore to a new project requires a pro plan or above."
- secondaryText="To restore to a new project, you need to upgrade to a Pro plan and have physical backups enabled."
- />
- )
+ if (isLoading) {
+ return <GenericSkeletonLoader />
}
if (IS_CLONED_PROJECT) {
@@ -286,7 +287,7 @@ const RestoreToNewProject = () => {
if (
!isLoading &&
- hasPITREnabled &&
+ PITR_ENABLED &&
!cloneBackups?.physicalBackupData.earliestPhysicalBackupDateUnix
) {
return (
@@ -298,7 +299,7 @@ const RestoreToNewProject = () => {
)
}
- if (!isLoading && !hasPITREnabled && cloneBackups?.backups.length === 0) {
+ if (!isLoading && !PITR_ENABLED && cloneBackups?.backups.length === 0) {
return (
<>
<Admonition
@@ -354,7 +355,7 @@ const RestoreToNewProject = () => {
</Panel>
</div>
) : null}
- {hasPITREnabled ? (
+ {PITR_ENABLED ? (
<>
<PITRForm
disabled={isRestoring}