From bbf806de3040e698e64030f7365345a18c5e0f80 Mon Sep 17 00:00:00 2001
From: Jordi Enric <37541088+jordienr@users.noreply.github.com>
Date: Thu, 19 Dec 2024 13:35:21 +0100
Subject: [PATCH] R2NP: add 403 permissions or physical backups disabled
handler (#31197)
* add 403 err handler
* validate error
* rm retry logic in fvor of enabling the query only if pitr or pb are enabled
* disable queries instead of checking error code
---
.../backups/restore-to-new-project.tsx | 35 ++++++++++---------
1 file changed, 18 insertions(+), 17 deletions(-)
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 (
+
+ )
+ }
+
if (isOrioleDb) {
return (
{
)
}
- if (isLoading) {
- return
- }
-
if (!canReadPhysicalBackups) {
return
}
@@ -243,14 +250,8 @@ const RestoreToNewProject = () => {
)
}
- if (plan === 'free') {
- return (
-
- )
+ if (isLoading) {
+ return
}
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 (
<>
{
) : null}
- {hasPITREnabled ? (
+ {PITR_ENABLED ? (
<>