From 0880e0e1d0efbe22c9fe96a4cf3dc24a7ba3f700 Mon Sep 17 00:00:00 2001 From: angelico Date: Fri, 16 May 2025 14:16:53 +0800 Subject: [PATCH] chore: allow pausing for AWS_NEW projects regardless of pricing tier (#35493) * chore: gitignore .pnpm-store/* * chore: allow pausing for aws new projects * fix: incorrect logic * chore: clean up logic * Small refactor * chore: update conditions for useIsOrioleDbInAwsRevamped --------- Co-authored-by: Joshen Lim --- .gitignore | 2 ++ .../General/Infrastructure/PauseProjectButton.tsx | 9 ++++++--- apps/studio/hooks/misc/useSelectedProject.ts | 11 +++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e7cd51f725..761041edaa 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,5 @@ gcloud.json # CLI version file .temp/cli-latest + +.pnpm-store/* diff --git a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx index b94d15df87..c86f94cc5f 100644 --- a/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx +++ b/apps/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx @@ -14,6 +14,7 @@ import { useProjectPauseMutation } from 'data/projects/project-pause-mutation' import { setProjectStatus } from 'data/projects/projects-query' import { useCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization' +import { useIsOrioleDbInAwsRevamped } from 'hooks/misc/useSelectedProject' import { PROJECT_STATUS } from 'lib/constants' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' @@ -32,10 +33,12 @@ const PauseProjectButton = () => { 'queue_jobs.projects.pause' ) + const isOrioleDBInAwsNew = useIsOrioleDbInAwsRevamped() const isFreePlan = organization?.plan.id === 'free' + const isPaidAndNotAwsNew = !isFreePlan && !isOrioleDBInAwsNew const { mutate: pauseProject, isLoading: isPausing } = useProjectPauseMutation({ - onSuccess: (res, variables) => { + onSuccess: (_, variables) => { setProjectStatus(queryClient, variables.ref, PROJECT_STATUS.PAUSING) toast.success('Pausing project...') router.push(`/project/${projectRef}`) @@ -50,7 +53,7 @@ const PauseProjectButton = () => { } const buttonDisabled = - !isFreePlan || project === undefined || isPaused || !canPauseProject || !isProjectActive + isPaidAndNotAwsNew || project === undefined || isPaused || !canPauseProject || !isProjectActive return ( <> @@ -69,7 +72,7 @@ const PauseProjectButton = () => { ? 'You need additional permissions to pause this project' : !isProjectActive ? 'Unable to pause project as project is not active' - : !isFreePlan + : isPaidAndNotAwsNew ? 'Projects on a paid plan will always be running' : undefined, }, diff --git a/apps/studio/hooks/misc/useSelectedProject.ts b/apps/studio/hooks/misc/useSelectedProject.ts index c973f22e08..4b88355116 100644 --- a/apps/studio/hooks/misc/useSelectedProject.ts +++ b/apps/studio/hooks/misc/useSelectedProject.ts @@ -46,3 +46,14 @@ export const useIsOrioleDbInAws = () => { project?.dbVersion?.endsWith('orioledb') && project?.cloud_provider === PROVIDERS.AWS.id return isOrioleDbInAws } + +export const useIsOrioleDbInAwsRevamped = () => { + const project = useSelectedProject() + + const isOrioleDb = project?.dbVersion?.endsWith('orioledb') + const isOrioleDbInAws = + project?.dbVersion?.endsWith('orioledb') && project?.cloud_provider === PROVIDERS.AWS.id + const isOrioleDbInAwsRevamped = isOrioleDb && !isOrioleDbInAws + + return isOrioleDbInAwsRevamped +}