Skip to content

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

Disable pause project button for projects on paid plan (#19936)

Joshen Limc69c7ac6e303
diff --git a/apps/studio/components/interfaces/Settings/General/General.tsx b/apps/studio/components/interfaces/Settings/General/General.tsx
index e42ca693bff..525eeca0fe6 100644
--- a/apps/studio/components/interfaces/Settings/General/General.tsx
+++ b/apps/studio/components/interfaces/Settings/General/General.tsx
@@ -42,6 +42,7 @@ const General = () => {
project_id: project?.id,
},
})
+
const { mutateAsync: updateProject, isLoading: isUpdating } = useProjectUpdateMutation()
const onSubmit = async (values: any, { resetForm }: any) => {
diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
index c47460ed28c..9ae8336041d 100644
--- a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
+++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx
@@ -12,7 +12,8 @@ import {
import ConfirmationModal from 'components/ui/ConfirmationModal'
import { useProjectPauseMutation } from 'data/projects/project-pause-mutation'
import { setProjectStatus } from 'data/projects/projects-query'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
+import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
import { PROJECT_STATUS } from 'lib/constants'
const PauseProjectButton = () => {
@@ -20,6 +21,7 @@ const PauseProjectButton = () => {
const router = useRouter()
const queryClient = useQueryClient()
const { project } = useProjectContext()
+ const organization = useSelectedOrganization()
const isProjectActive = useIsProjectActive()
const [isModalOpen, setIsModalOpen] = useState(false)
@@ -30,6 +32,9 @@ const PauseProjectButton = () => {
'queue_jobs.projects.pause'
)
+ const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })
+ const isFreePlan = subscription?.plan.id === 'free'
+
const { mutate: pauseProject, isLoading: isPausing } = useProjectPauseMutation({
onSuccess: (res, variables) => {
setProjectStatus(queryClient, variables.ref, PROJECT_STATUS.PAUSING)
@@ -48,6 +53,9 @@ const PauseProjectButton = () => {
pauseProject({ ref: projectRef })
}
+ const buttonDisabled =
+ !isFreePlan || project === undefined || isPaused || !canPauseProject || !isProjectActive
+
return (
<>
<Tooltip.Root delayDuration={0}>
@@ -57,12 +65,12 @@ const PauseProjectButton = () => {
icon={<IconPause />}
onClick={() => setIsModalOpen(true)}
loading={isPausing}
- disabled={project === undefined || isPaused || !canPauseProject || !isProjectActive}
+ disabled={buttonDisabled}
>
Pause Project
</Button>
</Tooltip.Trigger>
- {project !== undefined && (isPaused || !canPauseProject || !isProjectActive) ? (
+ {buttonDisabled ? (
<Tooltip.Portal>
<Tooltip.Content side="bottom">
<Tooltip.Arrow className="radix-tooltip-arrow" />
@@ -79,6 +87,8 @@ const PauseProjectButton = () => {
? 'You need additional permissions to pause this project'
: !isProjectActive
? 'Unable to pause project as project is not active'
+ : !isFreePlan
+ ? 'Projects on a paid plan will always be running'
: ''}
</span>
</div>