Skip to content

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

Prevent request billing owner for downgrade of plan (#45823)

Joshen Lim28f5484369f0
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx
index 9babe1cb8dd..c329abba68b 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx
@@ -307,13 +307,14 @@ export const PlanUpdateSidePanel = () => {
<Button block disabled type="default">
Current plan
</Button>
- ) : !canUpdateSubscription ? (
+ ) : !canUpdateSubscription && !isDowngradeOption ? (
<RequestUpgradeToBillingOwners block plan={plan.name as 'Pro' | 'Team'} />
) : (
<ButtonTooltip
block
type={isDowngradeOption ? 'default' : 'primary'}
disabled={
+ (!canUpdateSubscription && isDowngradeOption) ||
subscription?.plan?.id === 'enterprise' ||
subscription?.plan?.id === 'platform' ||
// Downgrades to free are still allowed through the dashboard given we have much better control about showing customers the impact + any possible issues with downgrading to free
@@ -338,14 +339,17 @@ export const PlanUpdateSidePanel = () => {
side: 'bottom',
className: hasOrioleProjects ? 'w-96 text-center' : '',
text:
- subscription?.plan?.id === 'enterprise' ||
- subscription?.plan?.id === 'platform'
- ? 'Reach out to us via support to update your plan'
- : hasOrioleProjects
- ? 'Your organization has projects that are using the OrioleDB extension which is only available on the Free plan. Remove all OrioleDB projects before changing your plan.'
- : selectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE
- ? 'You cannot change the plan for an organization managed by AWS Marketplace'
- : undefined,
+ !canUpdateSubscription && isDowngradeOption
+ ? "You need additional permissions to change your organization's plan"
+ : subscription?.plan?.id === 'enterprise' ||
+ subscription?.plan?.id === 'platform'
+ ? 'Reach out to us via support to update your plan'
+ : hasOrioleProjects
+ ? 'Your organization has projects that are using the OrioleDB extension which is only available on the Free plan. Remove all OrioleDB projects before changing your plan.'
+ : selectedOrganization?.managed_by ===
+ MANAGED_BY.AWS_MARKETPLACE
+ ? 'You cannot change the plan for an organization managed by AWS Marketplace'
+ : undefined,
},
}}
>