Skip to content

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

Downgrade modal show which projects will be affected in terms of addons

Joshen Lim0054d1ed741c
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/DowngradeModal.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/DowngradeModal.tsx
index dc4969b90bd..1e0a6dad94a 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/DowngradeModal.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/DowngradeModal.tsx
@@ -1,22 +1,31 @@
+import InformationBox from 'components/ui/InformationBox'
+import { OrgSubscription } from 'data/subscriptions/org-subscription-query'
import { PricingInformation } from 'shared-data'
import { Alert, IconAlertOctagon, IconMinusCircle, IconPauseCircle, Modal } from 'ui'
export interface DowngradeModalProps {
visible: boolean
- selectedTier?: PricingInformation
+ selectedPlan?: PricingInformation
+ subscription?: OrgSubscription
onClose: () => void
onConfirm: () => void
}
-const DowngradeModal = ({ visible, selectedTier, onClose, onConfirm }: DowngradeModalProps) => {
+const DowngradeModal = ({
+ visible,
+ selectedPlan,
+ subscription,
+ onClose,
+ onConfirm,
+}: DowngradeModalProps) => {
return (
<Modal
- size="medium"
+ size="large"
alignFooter="right"
visible={visible}
onCancel={onClose}
onConfirm={onConfirm}
- header={`Confirm to downgrade to ${selectedTier?.name} plan`}
+ header={`Confirm to downgrade to ${selectedPlan?.name} plan`}
>
<Modal.Content>
<div className="py-6">
@@ -31,36 +40,67 @@ const DowngradeModal = ({ visible, selectedTier, onClose, onConfirm }: Downgrade
</p>
</Alert>
- {/* [Joshen] Improvement area: Show which projects might be most affected by the downgrade? */}
- {/* [Joshen] Improvement area: Show which projects addons will be removed */}
-
<ul className="mt-4 space-y-5 text-sm">
- <li className="flex gap-3">
- <IconMinusCircle />
- <span>Add ons from all projects under this organization will be removed.</span>
- </li>
-
<li className="flex gap-3">
<div>
<IconPauseCircle />
</div>
- <span>
- Your projects will be paused if it exceeds the free plan quotas, or after a week of
- inactivity
- </span>
+ <span>Projects will be paused after a week of inactivity</span>
+ </li>
+
+ <li>
+ <div className="flex gap-3 mb-2">
+ <div>
+ <IconMinusCircle />
+ </div>
+ <span>Add ons from all projects under this organization will be removed.</span>
+ </div>
+ {(subscription?.project_addons.length ?? 0) > 0 && (
+ <InformationBox
+ title={`Warning: A total of ${subscription?.project_addons.length} project(s) will be affected from the downgrade`}
+ description={
+ <ul className="space-y-1 max-h-[100px] overflow-y-auto">
+ {subscription?.project_addons.map((project) => {
+ const needsRestart = project.addons.find(
+ (addon) => addon.type === 'compute_instance'
+ )
+ const addons = project.addons.map((addon) => {
+ if (addon.type === 'compute_instance')
+ return `${addon.variant.name} Compute Instance`
+ return addon.variant.name
+ })
+ return (
+ <li key={project.ref} className="list-disc ml-6">
+ {project.name}: {addons.join(', ')} will be removed.
+ {needsRestart ? (
+ <>
+ {' '}
+ Project will also{' '}
+ <span className="text-amber-900">need to be restarted</span> due to
+ change in compute instance
+ </>
+ ) : (
+ ''
+ )}
+ </li>
+ )
+ })}
+ </ul>
+ }
+ />
+ )}
</li>
<li className="flex gap-3">
<IconAlertOctagon w={14} className="flex-shrink-0" />
<div>
- <strong>Before you downgrading to the {selectedTier?.name} plan, consider:</strong>
+ <strong>Before you downgrading to the {selectedPlan?.name} plan, consider:</strong>
<ul className="space-y-2 mt-2">
<li className="list-disc ml-4">
Your projects no longer require their respective add ons.
</li>
<li className="list-disc ml-4">
- Your projects are currently consuming resources that are well within the{' '}
- {selectedTier?.name} plan's quota.
+ Your resource consumption are well within the {selectedPlan?.name} plan's quota.
</li>
<li className="list-disc ml-4">
Alternatively, you may also transfer projects across organizations.
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx
index d4c513ea052..067feef5320 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx
@@ -52,7 +52,7 @@ const PlanUpdateSidePanel = () => {
const availablePlans = plans ?? []
const hasMembersExceedingFreeTierLimit = (membersExceededLimit || []).length > 0
- const selectedTierMeta = subscriptionsPlans.find((tier) => tier.id === selectedTier)
+ const subscriptionPlanMeta = subscriptionsPlans.find((tier) => tier.id === selectedTier)
const selectedPlanMeta = availablePlans.find(
(plan) => plan.id === selectedTier?.split('tier_')[1]
)
@@ -100,7 +100,7 @@ const PlanUpdateSidePanel = () => {
})
ui.setNotification({
category: 'success',
- message: `Successfully updated subscription to ${selectedTierMeta?.name}!`,
+ message: `Successfully updated subscription to ${subscriptionPlanMeta?.name}!`,
})
setSelectedTier(undefined)
onClose()
@@ -279,7 +279,8 @@ const PlanUpdateSidePanel = () => {
<DowngradeModal
visible={selectedTier === 'tier_free'}
- selectedTier={selectedTierMeta}
+ selectedPlan={subscriptionPlanMeta}
+ subscription={subscription}
onClose={() => setSelectedTier(undefined)}
onConfirm={onConfirmDowngrade}
/>
@@ -292,7 +293,7 @@ const PlanUpdateSidePanel = () => {
onCancel={() => setSelectedTier(undefined)}
onConfirm={onUpdateSubscription}
overlayClassName="pointer-events-none"
- header={`Confirm to upgrade to ${selectedTierMeta?.name}`}
+ header={`Confirm to upgrade to ${subscriptionPlanMeta?.name}`}
>
<Modal.Content>
<div className="py-6 space-y-2">
diff --git a/studio/data/subscriptions/org-subscription-query.ts b/studio/data/subscriptions/org-subscription-query.ts
index 1705bff47f5..27cd1319339 100644
--- a/studio/data/subscriptions/org-subscription-query.ts
+++ b/studio/data/subscriptions/org-subscription-query.ts
@@ -45,6 +45,21 @@ export type OrgSubscription = {
expiry_month: number
expiry_year: number
}
+ project_addons: {
+ addons: {
+ type: 'custom_domain' | 'compute_instance' | 'pitr'
+ variant: {
+ identifier: string
+ name: string
+ price: number
+ price_description: string
+ price_interval: string
+ price_type: string
+ }
+ }[]
+ name: string
+ ref: string
+ }[]
}
export async function getOrgSubscription(