Skip to content

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

fix: allow branch to be paused and restarted (#40884)

Han Qiaod02926a68f68
diff --git a/apps/studio/components/interfaces/Settings/General/General.tsx b/apps/studio/components/interfaces/Settings/General/General.tsx
index cffe5298a86..f1900b6662a 100644
--- a/apps/studio/components/interfaces/Settings/General/General.tsx
+++ b/apps/studio/components/interfaces/Settings/General/General.tsx
@@ -34,8 +34,7 @@ export const General = () => {
// [Joshen] Need to refactor to use RHF so we don't need manual error handlers like this
const [nameError, setNameError] = useState<string>()
- const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })
- const isBranch = parentProject !== undefined
+ const isBranch = Boolean(project?.parent_project_ref)
const { projectSettingsRestartProject } = useIsFeatureEnabled([
'project_settings:restart_project',
@@ -81,7 +80,10 @@ export const General = () => {
<AlertDescription_Shadcn_>
Certain settings are not available while you're on a preview branch. To adjust your
project settings, you may return to your{' '}
- <Link href={`/project/${parentProject.ref}/settings/general`} className="text-brand">
+ <Link
+ href={`/project/${project?.parent_project_ref}/settings/general`}
+ className="text-brand"
+ >
main branch
</Link>
.
@@ -135,66 +137,64 @@ export const General = () => {
}}
</Form>
)}
+ <div className="mt-6" id="restart-project">
+ <FormPanel>
+ <div className="flex flex-col px-8 py-4">
+ <div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
+ <div>
+ <p className="text-sm">
+ {projectSettingsRestartProject ? 'Restart project' : 'Restart database'}
+ </p>
+ <div className="max-w-[420px]">
+ <p className="text-sm text-foreground-light">
+ Your project will not be available for a few minutes.
+ </p>
+ </div>
+ </div>
+ <RestartServerButton />
+ </div>
+ </div>
+ <div
+ className="flex w-full flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4 px-8 py-4"
+ id="pause-project"
+ >
+ <div>
+ <p className="text-sm">Pause project</p>
+ <div className="max-w-[420px]">
+ <p className="text-sm text-foreground-light">
+ Your project will not be accessible while it is paused.
+ </p>
+ </div>
+ </div>
+ <PauseProjectButton />
+ </div>
+ </FormPanel>
+ </div>
{!isBranch && (
- <>
- <div className="mt-6" id="restart-project">
- <FormPanel>
- <div className="flex flex-col px-8 py-4">
- <div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
+ <div className="mt-6">
+ <Panel>
+ <Panel.Content>
+ <div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
+ <div className="flex space-x-4">
+ <BarChart2 strokeWidth={2} />
<div>
- <p className="text-sm">
- {projectSettingsRestartProject ? 'Restart project' : 'Restart database'}
+ <p className="text-sm">Project usage statistics have been moved</p>
+ <p className="text-foreground-light text-sm">
+ You may view your project's usage under your organization's settings
</p>
- <div className="max-w-[420px]">
- <p className="text-sm text-foreground-light">
- Your project will not be available for a few minutes.
- </p>
- </div>
</div>
- <RestartServerButton />
</div>
- </div>
- <div
- className="flex w-full flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4 px-8 py-4"
- id="pause-project"
- >
<div>
- <p className="text-sm">Pause project</p>
- <div className="max-w-[420px]">
- <p className="text-sm text-foreground-light">
- Your project will not be accessible while it is paused.
- </p>
- </div>
+ <Button asChild type="default">
+ <Link href={`/org/${organization?.slug}/usage?projectRef=${project?.ref}`}>
+ View project usage
+ </Link>
+ </Button>
</div>
- <PauseProjectButton />
</div>
- </FormPanel>
- </div>
- <div className="mt-6">
- <Panel>
- <Panel.Content>
- <div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
- <div className="flex space-x-4">
- <BarChart2 strokeWidth={2} />
- <div>
- <p className="text-sm">Project usage statistics have been moved</p>
- <p className="text-foreground-light text-sm">
- You may view your project's usage under your organization's settings
- </p>
- </div>
- </div>
- <div>
- <Button asChild type="default">
- <Link href={`/org/${organization?.slug}/usage?projectRef=${project?.ref}`}>
- View project usage
- </Link>
- </Button>
- </div>
- </div>
- </Panel.Content>
- </Panel>
- </div>
- </>
+ </Panel.Content>
+ </Panel>
+ </div>
)}
</div>
)
diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
index 03de40e464e..010cd814c07 100644
--- a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
+++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
@@ -32,7 +32,8 @@ const PauseProjectButton = () => {
const isAwsK8s = useIsAwsK8sCloudProvider()
const isFreePlan = organization?.plan.id === 'free'
- const isPaidAndNotAwsK8s = !isFreePlan && !isAwsK8s
+ const isBranch = Boolean(project?.parent_project_ref)
+ const isPaidAndNotAwsK8s = !isBranch && !isFreePlan && !isAwsK8s
const { mutate: pauseProject, isPending: isPausing } = useProjectPauseMutation({
onSuccess: (_, variables) => {