Skip to content

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

Add flag for restarting project (#39153)

Joshen Lim933329b30c93
diff --git a/apps/studio/components/interfaces/Settings/General/General.tsx b/apps/studio/components/interfaces/Settings/General/General.tsx
index b58a5ff7162..46d19f4d588 100644
--- a/apps/studio/components/interfaces/Settings/General/General.tsx
+++ b/apps/studio/components/interfaces/Settings/General/General.tsx
@@ -10,6 +10,7 @@ import Panel from 'components/ui/Panel'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useProjectUpdateMutation } from 'data/projects/project-update-mutation'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useProjectByRefQuery, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import {
@@ -31,6 +32,10 @@ const General = () => {
const { data: parentProject } = useProjectByRefQuery(project?.parent_project_ref)
const isBranch = parentProject !== undefined
+ const { projectSettingsRestartProject } = useIsFeatureEnabled([
+ 'project_settings:restart_project',
+ ])
+
const formId = 'project-general-settings'
const initialValues = { name: project?.name ?? '', ref: project?.ref ?? '' }
const { can: canUpdateProject } = useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', {
@@ -122,7 +127,9 @@ const General = () => {
<div className="flex flex-col px-8 py-4">
<div className="flex justify-between items-center">
<div>
- <p className="text-sm">Restart project</p>
+ <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.
diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
index 55c0f44e7f3..ac120c3008c 100644
--- a/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
+++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
@@ -12,6 +12,7 @@ import { useProjectRestartMutation } from 'data/projects/project-restart-mutatio
import { useProjectRestartServicesMutation } from 'data/projects/project-restart-services-mutation'
import { setProjectStatus } from 'data/projects/projects-query'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useIsAwsK8sCloudProvider, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import {
Button,
@@ -31,6 +32,10 @@ const RestartServerButton = () => {
const isAwsK8s = useIsAwsK8sCloudProvider()
const [serviceToRestart, setServiceToRestart] = useState<'project' | 'database'>()
+ const { projectSettingsRestartProject } = useIsFeatureEnabled([
+ 'project_settings:restart_project',
+ ])
+
const projectRef = project?.ref ?? ''
const projectRegion = project?.region ?? ''
@@ -88,68 +93,80 @@ const RestartServerButton = () => {
return (
<>
- <div className="flex">
- <ButtonTooltip
- type="default"
- className={cn(
- 'px-3 hover:z-10',
- canRestartProject && isProjectActive ? 'rounded-r-none' : ''
+ {projectSettingsRestartProject ? (
+ <div className="flex">
+ <ButtonTooltip
+ type="default"
+ className={cn(
+ 'px-3 hover:z-10',
+ canRestartProject && isProjectActive ? 'rounded-r-none' : ''
+ )}
+ disabled={
+ project === undefined ||
+ !canRestartProject ||
+ !isProjectActive ||
+ projectRestartDisabled ||
+ isAwsK8s
+ }
+ onClick={() => setServiceToRestart('project')}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: projectRestartDisabled
+ ? 'Project restart is currently disabled'
+ : !canRestartProject
+ ? 'You need additional permissions to restart this project'
+ : !isProjectActive
+ ? 'Unable to restart project as project is not active'
+ : isAwsK8s
+ ? 'Project restart is not supported for AWS (Revamped) projects'
+ : undefined,
+ },
+ }}
+ >
+ Restart project
+ </ButtonTooltip>
+ {canRestartProject && isProjectActive && !projectRestartDisabled && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="default"
+ className="rounded-l-none px-[4px] py-[5px] -ml-[1px]"
+ icon={<ChevronDown />}
+ disabled={!canRestartProject}
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" side="bottom">
+ <DropdownMenuItem
+ key="database"
+ disabled={isLoading}
+ onClick={() => {
+ setServiceToRestart('database')
+ }}
+ >
+ <div className="space-y-1">
+ <p className="block text-foreground">Fast database reboot</p>
+ <p className="block text-foreground-light">
+ Restarts only the database - faster but may not be able to recover from all
+ failure modes
+ </p>
+ </div>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
)}
- disabled={
- project === undefined ||
- !canRestartProject ||
- !isProjectActive ||
- projectRestartDisabled ||
- isAwsK8s
- }
- onClick={() => setServiceToRestart('project')}
- tooltip={{
- content: {
- side: 'bottom',
- text: projectRestartDisabled
- ? 'Project restart is currently disabled'
- : !canRestartProject
- ? 'You need additional permissions to restart this project'
- : !isProjectActive
- ? 'Unable to restart project as project is not active'
- : isAwsK8s
- ? 'Project restart is not supported for AWS (Revamped) projects'
- : undefined,
- },
+ </div>
+ ) : (
+ <Button
+ type="default"
+ disabled={isLoading}
+ onClick={() => {
+ setServiceToRestart('database')
}}
>
- Restart project
- </ButtonTooltip>
- {canRestartProject && isProjectActive && !projectRestartDisabled && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- type="default"
- className="rounded-l-none px-[4px] py-[5px] -ml-[1px]"
- icon={<ChevronDown />}
- disabled={!canRestartProject}
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" side="bottom">
- <DropdownMenuItem
- key="database"
- disabled={isLoading}
- onClick={() => {
- setServiceToRestart('database')
- }}
- >
- <div className="space-y-1">
- <p className="block text-foreground">Fast database reboot</p>
- <p className="block text-foreground-light">
- Restarts only the database - faster but may not be able to recover from all
- failure modes
- </p>
- </div>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </div>
+ Restart database
+ </Button>
+ )}
<ConfirmModal
danger
diff --git a/packages/common/enabled-features/enabled-features.json b/packages/common/enabled-features/enabled-features.json
index efd49862407..b5da63241e5 100644
--- a/packages/common/enabled-features/enabled-features.json
+++ b/packages/common/enabled-features/enabled-features.json
@@ -97,6 +97,7 @@
"project_settings:legacy_jwt_keys": true,
"project_settings:log_drains": true,
"project_settings:database_upgrades": true,
+ "project_settings:restart_project": true,
"quickstarts:hide_nimbus": true,
diff --git a/packages/common/enabled-features/enabled-features.schema.json b/packages/common/enabled-features/enabled-features.schema.json
index 780b533fd19..e491f749764 100644
--- a/packages/common/enabled-features/enabled-features.schema.json
+++ b/packages/common/enabled-features/enabled-features.schema.json
@@ -336,6 +336,10 @@
"type": "boolean",
"description": "Enable the log drains page in project settings"
},
+ "project_settings:restart_project": {
+ "type": "boolean",
+ "description": "Show the option to restart project in project settings (If off, only fast database reboot will be shown)"
+ },
"project_settings:database_upgrades": {
"type": "boolean",
"description": "Show database upgrade callouts in the project settings infrastructure page"
@@ -456,6 +460,7 @@
"project_settings:show_disable_legacy_api_keys",
"project_settings:legacy_jwt_keys",
"project_settings:log_drains",
+ "project_settings:restart_project",
"project_settings:database_upgrades",
"project_connection:javascript_example",
"project_connection:dart_example",