Skip to content

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

fix/various improvements to Free plan downgrade [GEN-8955] (#26670)

Thomas707f2fce4eda
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/DowngradeModal.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/DowngradeModal.tsx
index da23dd296e5..f0330e8471d 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/DowngradeModal.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/DowngradeModal.tsx
@@ -76,33 +76,33 @@ const DowngradeModal = ({
<Alert
withIcon
variant="warning"
- title="Downgrading to the free plan will lead to reductions in your organization's quota"
+ title="Downgrading to the Free plan will lead to reductions in your organization's quota"
>
<p>
- If you're already past the limits of the free plan, your projects could become
+ If you're already past the limits of the Free plan, your projects could become
unresponsive or enter read only mode.
</p>
</Alert>
- {(previousProjectAddons.length ?? 0) > 0 ||
- (hasInstancesOnMicro && downgradingToNano && (
- <Alert title={`Projects affected by the downgrade`} variant="warning" withIcon>
- <ul className="space-y-1 max-h-[100px] overflow-y-auto">
- {previousProjectAddons.map((project) => (
- <ProjectDowngradeListItem key={project.ref} projectAddon={project} />
- ))}
+ {((previousProjectAddons.length ?? 0) > 0 ||
+ (hasInstancesOnMicro && downgradingToNano)) && (
+ <Alert title={`Projects affected by the downgrade`} variant="warning" withIcon>
+ <ul className="space-y-1 max-h-[100px] overflow-y-auto">
+ {previousProjectAddons.map((project) => (
+ <ProjectDowngradeListItem key={project.ref} projectAddon={project} />
+ ))}
- {projects
- .filter((it) => it.infra_compute_size === 'micro')
- .map((project) => (
- <li className="list-disc ml-6" key={project.id}>
- {project.name}: Compute will be downgraded. Project will also{' '}
- <span className="font-bold">need to be restarted</span>.
- </li>
- ))}
- </ul>
- </Alert>
- ))}
+ {projects
+ .filter((it) => it.infra_compute_size === 'micro')
+ .map((project) => (
+ <li className="list-disc ml-6" key={project.id}>
+ {project.name}: Compute will be downgraded. Project will also{' '}
+ <span className="font-bold">need to be restarted</span>.
+ </li>
+ ))}
+ </ul>
+ </Alert>
+ )}
</div>
<ul className="mt-4 space-y-5 text-sm">
@@ -141,7 +141,7 @@ const DowngradeModal = ({
</li>
</ul>
- {subscription?.billing_via_partner === true && (
+ {subscription?.billing_via_partner === true && subscription.billing_partner === 'fly' && (
<p className="mt-4 text-sm">
Your organization will be downgraded at the end of your current billing cycle.
</p>
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/ExitSurveyModal.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/ExitSurveyModal.tsx
index 7cb44fcfe5b..3b71e425cb4 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/ExitSurveyModal.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/ExitSurveyModal.tsx
@@ -11,15 +11,17 @@ import { useFlag } from 'hooks'
import { Alert, Button, Input, Modal } from 'ui'
import { CANCELLATION_REASONS } from '../BillingSettings.constants'
import ProjectUpdateDisabledTooltip from '../ProjectUpdateDisabledTooltip'
+import type { ProjectInfo } from '../../../../../data/projects/projects-query'
export interface ExitSurveyModalProps {
visible: boolean
subscription?: OrgSubscription
+ projects: ProjectInfo[]
onClose: (success?: boolean) => void
}
// [Joshen] For context - Exit survey is only when going to free plan from a paid plan
-const ExitSurveyModal = ({ visible, subscription, onClose }: ExitSurveyModalProps) => {
+const ExitSurveyModal = ({ visible, subscription, projects, onClose }: ExitSurveyModalProps) => {
const { slug } = useParams()
const captchaRef = useRef<HCaptcha>(null)
@@ -38,11 +40,20 @@ const ExitSurveyModal = ({ visible, subscription, onClose }: ExitSurveyModalProp
})
const isSubmitting = isUpdating || isSubmittingFeedback
- const projectsWithComputeInstances =
- subscription?.project_addons.filter((project) =>
- project.addons.find((addon) => addon.type === 'compute_instance')
- ) ?? []
- const hasComputeInstance = projectsWithComputeInstances.length > 0
+ const projectsWithComputeDowngrade = projects.filter((project) => {
+ const computeSizesThatDoNotResultInComputeDowngrade = ['nano']
+
+ if (subscription?.nano_enabled === false) {
+ computeSizesThatDoNotResultInComputeDowngrade.push('micro')
+ }
+
+ return !computeSizesThatDoNotResultInComputeDowngrade.includes(project.infra_compute_size!)
+ })
+
+ const hasProjectsWithComputeDowngrade = projectsWithComputeDowngrade.length > 0
+
+ const willPlanDowngradeHappenImmediately =
+ subscription?.billing_via_partner === false || subscription?.billing_partner !== 'fly'
function reducer(state: any, action: any) {
if (includes(state, action.target.value)) {
@@ -93,10 +104,12 @@ const ExitSurveyModal = ({ visible, subscription, onClose }: ExitSurveyModalProp
}
toast.success(
- hasComputeInstance
- ? 'Your organization has been downgraded and your projects are currently restarting to update their compute instances'
- : 'Successfully downgraded organization to the free plan',
- { duration: hasComputeInstance ? 8000 : 4000 }
+ willPlanDowngradeHappenImmediately
+ ? hasProjectsWithComputeDowngrade
+ ? 'Successfully downgraded organization to the Free plan. Your projects are currently restarting to update their compute instances.'
+ : 'Successfully downgraded organization to the Free plan'
+ : 'Your organization is scheduled for the downgrade at the end of your current billing cycle',
+ { duration: hasProjectsWithComputeDowngrade ? 8000 : 4000 }
)
onClose(true)
@@ -178,25 +191,25 @@ const ExitSurveyModal = ({ visible, subscription, onClose }: ExitSurveyModalProp
/>
</div>
</div>
- {hasComputeInstance && (
+ {hasProjectsWithComputeDowngrade && (
<Alert
withIcon
variant="warning"
- title={`${projectsWithComputeInstances.length} of your project${
- projectsWithComputeInstances.length > 1 ? 's' : ''
- } will be restarted upon hitting confirm`}
+ title={`${projectsWithComputeDowngrade.length} of your projects will be restarted ${willPlanDowngradeHappenImmediately ? 'upon clicking confirm' : 'once the downgrade takes effect at the end of your current billing cycle'}`}
>
- This is due to changes in compute instances from the downgrade. Affected project(s)
- include {projectsWithComputeInstances.map((project) => project.name).join(', ')}.
+ This is due to changes in compute instances from the downgrade. Affected projects
+ include {projectsWithComputeDowngrade.map((project) => project.name).join(', ')}.
</Alert>
)}
</div>
</Modal.Content>
<div className="flex items-center justify-between border-t px-4 py-4">
- <p className="text-xs text-foreground-lighter">
- The unused amount for the remaining of your billing cycle will be refunded as credits
- </p>
+ {willPlanDowngradeHappenImmediately && (
+ <p className="text-xs text-foreground-lighter">
+ The unused amount for the remaining of your billing cycle will be refunded as credits
+ </p>
+ )}
<div className="flex items-center space-x-2">
<Button type="default" onClick={() => onClose()}>
Cancel
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx
index f5de33e2e5a..c2a843aafe6 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx
@@ -574,6 +574,7 @@ const PlanUpdateSidePanel = () => {
<ExitSurveyModal
visible={showExitSurvey}
subscription={subscription}
+ projects={orgProjects}
onClose={(success?: boolean) => {
setShowExitSurvey(false)
if (success) onClose()