The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): full-screen pricing panel variants (#49640)
kemal.earth839c7a9cbbb5
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/EnterpriseCard.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/EnterpriseCard.tsxindex c31c236f730..b75d324bc0d 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/EnterpriseCard.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/EnterpriseCard.tsx@@ -1,3 +1,4 @@+import { motion, type Variants } from 'framer-motion'import { Check } from 'lucide-react'import { PricingInformation } from 'shared-data'import { Button, cn } from 'ui'@@ -8,9 +9,10 @@ import { useTrack } from '@/lib/telemetry/track'export interface EnterpriseCardProps {plan: PricingInformationisCurrentPlan: boolean+ variants?: Variants}-export const EnterpriseCard = ({ plan, isCurrentPlan }: EnterpriseCardProps) => {+export const EnterpriseCard = ({ plan, isCurrentPlan, variants }: EnterpriseCardProps) => {const { data: selectedOrganization } = useSelectedOrganizationQuery()const features = plan.features@@ -19,8 +21,9 @@ export const EnterpriseCard = ({ plan, isCurrentPlan }: EnterpriseCardProps) =>const track = useTrack()return (- <div+ <motion.divkey={plan.id}+ variants={variants}className={cn('grid grid-cols-1 md:grid-cols-3 border rounded-md bg-studio','py-4 col-span-12 justify-between gap-x-8'@@ -95,6 +98,6 @@ export const EnterpriseCard = ({ plan, isCurrentPlan }: EnterpriseCardProps) =></a></Button></div>- </div>+ </motion.div>)}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsxindex 406e58cbd54..d6a7fee8455 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCard.tsx@@ -1,3 +1,4 @@+import { motion, type Variants } from 'framer-motion'import { isArray } from 'lodash'import { Check, X } from 'lucide-react'import type { PricingInformation } from 'shared-data'@@ -5,7 +6,12 @@ import { Button, cn } from 'ui'import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'import type { GapFeature, PlanPresentationVariant } from './plan-presentation'-import { FREE_PLAN_GAPS, PRO_PLAN_GAPS } from './plan-presentation'+import {+ FREE_PLAN_GAPS,+ hasPlanGaps,+ isParityPresentation,+ PRO_PLAN_GAPS,+} from './plan-presentation'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import { RequestUpgradeToBillingOwners } from '@/components/ui/RequestUpgradeToBillingOwners'import { MANAGED_BY } from '@/lib/constants/infrastructure'@@ -29,6 +35,7 @@ export interface PlanCardProps {managedBy: string | undefinedshouldHighlight: booleanvariant: PlanPresentationVariant+ variants?: VariantsonSelectTier: () => voidonTrackCtaClick: () => void}@@ -46,14 +53,15 @@ export function PlanCard({managedBy,shouldHighlight,variant,+ variants,onSelectTier,onTrackCtaClick,}: PlanCardProps) {- const isParity = variant === 'parity' || variant === 'gaps'+ const isParity = isParityPresentation(variant)const features = plan.featuresconst footer = plan.footer- const gaps: GapFeature[] = variant === 'gaps' ? (GAPS_BY_PLAN_ID[plan.id] ?? []) : []+ const gaps: GapFeature[] = hasPlanGaps(variant) ? (GAPS_BY_PLAN_ID[plan.id] ?? []) : []const ctaButton = isCurrentPlan ? (<Button block disabled variant="default">@@ -112,6 +120,7 @@ export function PlanCard({features={features}footer={footer}ctaButton={ctaButton}+ variants={variants}/>)}@@ -127,6 +136,7 @@ export function PlanCard({footer={footer}gaps={gaps}ctaButton={ctaButton}+ variants={variants}/>)}@@ -140,6 +150,7 @@ function ControlCard({features,footer,ctaButton,+ variants,}: {plan: PricingInformationprice: number@@ -149,9 +160,11 @@ function ControlCard({features: (string | string[])[]footer: string | undefinedctaButton: React.ReactNode+ variants?: Variants}) {return (- <div+ <motion.div+ variants={variants}className={cn('px-4 py-4 flex flex-col items-start justify-between','border rounded-md col-span-12 md:col-span-4 bg-surface-200',@@ -217,7 +230,7 @@ function ControlCard({<p className="text-foreground-light text-xs">{footer}</p></div>)}- </div>+ </motion.div>)}@@ -231,6 +244,7 @@ function ParityCard({footer,gaps,ctaButton,+ variants,}: {plan: PricingInformationprice: number@@ -241,9 +255,11 @@ function ParityCard({footer: string | undefinedgaps: GapFeature[]ctaButton: React.ReactNode+ variants?: Variants}) {return (- <div+ <motion.div+ variants={variants}className={cn('flex flex-col items-start justify-between','border rounded-md col-span-12 md:col-span-4 bg-surface-200',@@ -372,6 +388,6 @@ function ParityCard({</div>)}</div>- </div>+ </motion.div>)}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsxindex 2ff1fa49304..558cd7abe31 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.tsx@@ -1,9 +1,11 @@+import { motion } from 'framer-motion'import { useRouter } from 'next/router'import { plans as subscriptionsPlans } from 'shared-data/plans'import { EnterpriseCard } from './EnterpriseCard'-import { isPlanChangeEligible, usePlanPresentationExperiment } from './plan-presentation'+import type { PlanPresentationVariant } from './plan-presentation'import { PlanCard } from './PlanCard'+import { getPlanCardsEntryAnimation } from './PlanCards.utils'import { getPlanChangeType } from '@/components/interfaces/Billing/Subscription/Subscription.utils'import type { OrgPlan, PlanId } from '@/data/subscriptions/types'import { useTrack } from '@/lib/telemetry/track'@@ -18,6 +20,9 @@ export interface PlanCardsProps {isPartnerBilledOrganization: booleanhasOrioleProjects: booleanselectedOrganization: Organization | undefined+ variant: PlanPresentationVariant+ /** Seconds to wait before the cards stagger in. Omit to render them without an entry animation. */+ entryDelay?: numberonSelectTier: (tier: 'tier_free' | 'tier_pro' | 'tier_team') => void}@@ -30,22 +35,17 @@ export function PlanCards({isPartnerBilledOrganization,hasOrioleProjects,selectedOrganization,+ variant,+ entryDelay,onSelectTier,}: PlanCardsProps) {const router = useRouter()const track = useTrack()- const eligible = isPlanChangeEligible({- managedBy: selectedOrganization?.managed_by,- billingPartner: selectedOrganization?.billing_partner,- currentPlanId: currentSubscriptionPlanId,- canUpdateSubscription,- })-- const variant = usePlanPresentationExperiment({ eligible })+ const entryAnimation = getPlanCardsEntryAnimation(entryDelay)return (- <div className="py-6 grid grid-cols-12 gap-3">+ <motion.div className="py-6 grid grid-cols-12 gap-3" {...entryAnimation.container}>{subscriptionsPlans.map((plan) => {const planMeta = availablePlans.find((p) => p.id === plan.id.split('tier_')[1])const price = planMeta?.price ?? 0@@ -59,7 +59,14 @@ export function PlanCards({const shouldHighlight = source === 'log-drains-empty-state' && plan.id === 'tier_pro'if (plan.id === 'tier_enterprise') {- return <EnterpriseCard key={plan.id} plan={plan} isCurrentPlan={isCurrentPlan} />+ return (+ <EnterpriseCard+ key={plan.id}+ plan={plan}+ isCurrentPlan={isCurrentPlan}+ variants={entryAnimation.card}+ />+ )}return (@@ -77,6 +84,7 @@ export function PlanCards({managedBy={selectedOrganization?.managed_by}shouldHighlight={shouldHighlight}variant={variant}+ variants={entryAnimation.card}onSelectTier={() => onSelectTier(plan.id as 'tier_free' | 'tier_pro' | 'tier_team')}onTrackCtaClick={() =>track('studio_pricing_plan_cta_clicked', {@@ -87,6 +95,6 @@ export function PlanCards({/>)})}- </div>+ </motion.div>)}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.utils.test.ts b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.utils.test.tsnew file mode 100644index 00000000000..82fc30ac4f8--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.utils.test.ts@@ -0,0 +1,31 @@+import { describe, expect, it } from 'vitest'++import { getPlanCardsEntryAnimation } from './PlanCards.utils'++describe('getPlanCardsEntryAnimation', () => {+ it('returns no animation props when no entry delay is given', () => {+ const animation = getPlanCardsEntryAnimation(undefined)++ expect(animation.container).toEqual({})+ expect(animation.card).toBeUndefined()+ })++ it('staggers the cards after the container delay', () => {+ const animation = getPlanCardsEntryAnimation(0.4)++ expect(animation.container.initial).toBe('hidden')+ expect(animation.container.animate).toBe('visible')+ expect(animation.card).toBeDefined()++ const visible = animation.container.variants?.visible as { transition: Record<string, number> }+ expect(visible.transition.delayChildren).toBeCloseTo(0.6)+ expect(visible.transition.staggerChildren).toBe(0.08)+ })++ it('treats a zero delay as an animation, not as absent', () => {+ const animation = getPlanCardsEntryAnimation(0)++ expect(animation.container.initial).toBe('hidden')+ expect(animation.card).toBeDefined()+ })+})diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.utils.ts b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.utils.tsnew file mode 100644index 00000000000..e735cf7a4ea--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanCards.utils.ts@@ -0,0 +1,37 @@+import type { Variants } from 'framer-motion'++const CARD_VARIANTS: Variants = {+ hidden: { opacity: 0, y: 8 },+ visible: { opacity: 1, y: 0, transition: { duration: 0.3, ease: 'easeOut' } },+}++const STAGGER_AFTER_CONTAINER = 0.2+const STAGGER_BETWEEN_CARDS = 0.08++export interface PlanCardsEntryAnimation {+ container: { variants?: Variants; initial?: string; animate?: string }+ card: Variants | undefined+}++export function getPlanCardsEntryAnimation(+ entryDelay: number | undefined+): PlanCardsEntryAnimation {+ if (entryDelay === undefined) return { container: {}, card: undefined }++ return {+ container: {+ variants: {+ hidden: {},+ visible: {+ transition: {+ delayChildren: entryDelay + STAGGER_AFTER_CONTAINER,+ staggerChildren: STAGGER_BETWEEN_CARDS,+ },+ },+ },+ initial: 'hidden',+ animate: 'visible',+ },+ card: CARD_VARIANTS,+ }+}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdatePanelShell.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdatePanelShell.tsxnew file mode 100644index 00000000000..a7324843807--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdatePanelShell.tsx@@ -0,0 +1,96 @@+import { motion } from 'framer-motion'+import { ArrowLeft, ExternalLink } from 'lucide-react'+import type { ReactNode } from 'react'+import { Button, SidePanel } from 'ui'++export interface PlanUpdatePanelShellProps {+ organizationName: string | undefined+ /** Rendered above the plan cards, outside the scrollable card grid. */+ notice: ReactNode+ onClose: () => void+ children: ReactNode+}++export function PlanUpdateSheetShell({+ visible,+ organizationName,+ notice,+ onClose,+ children,+}: PlanUpdatePanelShellProps & { visible: boolean }) {+ return (+ <SidePanel+ hideFooter+ size="xxlarge"+ visible={visible}+ onCancel={onClose}+ header={+ <div className="flex items-center justify-between w-full">+ <h4>Change subscription plan for {organizationName}</h4>+ <Button asChild variant="default" icon={<ExternalLink />}>+ <a href="https://supabase.com/pricing" target="_blank" rel="noreferrer">+ Pricing+ </a>+ </Button>+ </div>+ }+ >+ {notice}+ <SidePanel.Content>{children}</SidePanel.Content>+ </SidePanel>+ )+}++export function PlanUpdateFullScreenShell({+ organizationName,+ notice,+ skipOverlayFade,+ contentDelay,+ onClose,+ children,+}: PlanUpdatePanelShellProps & { skipOverlayFade: boolean; contentDelay: number }) {+ return (+ <motion.div+ className="fixed inset-0 z-50 overflow-y-auto overscroll-contain bg-studio"+ initial={skipOverlayFade ? false : { opacity: 0 }}+ animate={{ opacity: 1 }}+ transition={{ duration: 0.2, ease: 'easeOut' }}+ >+ <Button+ variant="text"+ icon={<ArrowLeft />}+ onClick={onClose}+ className="fixed top-4 left-4 z-10"+ >+ Go back to Studio+ </Button>+ <div className="fixed top-4 right-4 z-10 flex items-center gap-2">+ <Button+ asChild+ variant="text"+ iconRight={<ExternalLink />}+ className="hidden sm:inline-flex"+ >+ <a href="https://supabase.com/pricing#faq" target="_blank" rel="noreferrer">+ Pricing FAQ+ </a>+ </Button>+ <Button asChild variant="default" iconRight={<ExternalLink />}>+ <a href="https://supabase.com/pricing#compare-plans" target="_blank" rel="noreferrer">+ Compare plans+ </a>+ </Button>+ </div>+ <motion.div+ className="mx-auto flex w-full max-w-6xl flex-col gap-4 px-6 py-16"+ initial={{ opacity: 0, y: 8 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{ delay: contentDelay, duration: 0.3, ease: 'easeOut' }}+ >+ <h1 className="text-2xl text-center">Change subscription plan for {organizationName}</h1>+ {notice}+ {children}+ </motion.div>+ </motion.div>+ )+}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsxindex 30334872ecd..3607d413e60 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx@@ -9,12 +9,18 @@ const mockSelectedOrganization = vi.hoisted(() => vi.fn())const mockPush = vi.hoisted(() => vi.fn())const mockPartnerManagedResource = vi.hoisted(() => vi.fn())const mockUsePHFlag = vi.hoisted(() => vi.fn())+const mockFeatureFlags = vi.hoisted(() => vi.fn())+const mockIsPlatform = vi.hoisted(() => ({ value: true }))vi.mock('common', async (importOriginal) => {const original = (await importOriginal()) as typeof import('common')return {...original,useParams: () => ({ slug: 'stripe-org' }),+ useFeatureFlags: mockFeatureFlags,+ get IS_PLATFORM() {+ return mockIsPlatform.value+ },}})@@ -147,6 +153,8 @@ vi.mock('@/hooks/misc/useTrackExperimentExposure', () => ({describe('PlanUpdateSidePanel', () => {beforeEach(() => {vi.clearAllMocks()+ mockIsPlatform.value = true+ mockFeatureFlags.mockReturnValue({ posthog: {}, configcat: {}, hasLoaded: true })mockUsePHFlag.mockReturnValue('control')mockSelectedOrganization.mockReturnValue(createMockOrganization({@@ -261,6 +269,109 @@ describe('PlanUpdateSidePanel', () => {})})+ describe.each(['fullscreen', 'fullscreen-gaps'])('%s variant', (flag) => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue(flag)+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('renders the full-screen shell instead of the sheet', () => {+ render(<PlanUpdateSidePanel />)++ expect(screen.getByRole('button', { name: /Go back to Studio/ })).toBeInTheDocument()+ expect(screen.getByRole('link', { name: /Compare plans/ })).toBeInTheDocument()+ expect(screen.queryByRole('link', { name: 'Pricing' })).not.toBeInTheDocument()+ })++ it('renders parity cards', () => {+ render(<PlanUpdateSidePanel />)++ expect(+ screen.getByText('Perfect for passion projects & simple websites.')+ ).toBeInTheDocument()+ expect(screen.getByText('Everything in the Free Plan, plus:')).toBeInTheDocument()+ })+ })++ describe('fullscreen variant', () => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue('fullscreen')+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('does not render gap rows', () => {+ render(<PlanUpdateSidePanel />)++ expect(screen.queryByText('Not included')).not.toBeInTheDocument()+ expect(screen.queryByText('Plan limits')).not.toBeInTheDocument()+ })+ })++ describe('fullscreen-gaps variant', () => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue('fullscreen-gaps')+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('renders gap rows inside the full-screen shell', () => {+ render(<PlanUpdateSidePanel />)++ expect(screen.getByRole('button', { name: /Go back to Studio/ })).toBeInTheDocument()+ expect(screen.getByText('Daily backups')).toBeInTheDocument()+ expect(screen.getByText('1-day log retention')).toBeInTheDocument()+ // Free has a `lesser` item → "Plan limits"; Pro has only `missing` items → "Not included"+ expect(screen.getByText('Plan limits')).toBeInTheDocument()+ expect(screen.getByText('Not included')).toBeInTheDocument()+ })+ })++ describe('while feature flags are still loading', () => {+ beforeEach(() => {+ mockFeatureFlags.mockReturnValue({ posthog: {}, configcat: {}, hasLoaded: false })+ mockUsePHFlag.mockReturnValue(undefined)+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('opens neither shell, so the fullscreen variant cannot flash the sheet', () => {+ render(<PlanUpdateSidePanel />)++ expect(screen.queryByRole('button', { name: /Go back to Studio/ })).not.toBeInTheDocument()+ expect(screen.queryByRole('button', { name: 'Upgrade to Pro' })).not.toBeInTheDocument()+ })++ it('does not gate the panel when self-hosted, where flags never load', () => {+ mockIsPlatform.value = false++ render(<PlanUpdateSidePanel />)++ expect(screen.getByRole('button', { name: 'Upgrade to Pro' })).toBeInTheDocument()+ })+ })++ describe.each(['control', 'parity', 'gaps'])('%s variant keeps the sheet shell', (flag) => {+ beforeEach(() => {+ mockUsePHFlag.mockReturnValue(flag)+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({ slug: 'test-org', billing_partner: null })+ )+ })++ it('renders the sheet header and no full-screen chrome', () => {+ render(<PlanUpdateSidePanel />)++ expect(screen.getByRole('link', { name: 'Pricing' })).toBeInTheDocument()+ expect(screen.queryByRole('button', { name: /Go back to Studio/ })).not.toBeInTheDocument()+ })+ })+describe('control variant', () => {beforeEach(() => {mockUsePHFlag.mockReturnValue('control')diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsxindex 677c59cdd60..6bd719154d1 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx@@ -2,14 +2,18 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { useDebounce } from '@uidotdev/usehooks'import { useParams } from 'common'import { StudioPricingSidePanelOpenedEvent } from 'common/telemetry-constants'-import { ExternalLink } from 'lucide-react'import { useRouter } from 'next/router'import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from 'react'import { plans as subscriptionsPlans } from 'shared-data/plans'-import { Button, SidePanel } from 'ui'import { CancellationFlow } from './CancellationFlow'+import {+ isFullScreenPresentation,+ isPlanChangeEligible,+ usePlanPresentationExperiment,+} from './plan-presentation'import { PlanCards } from './PlanCards'+import { PlanUpdateFullScreenShell, PlanUpdateSheetShell } from './PlanUpdatePanelShell'import { SubscriptionPlanUpdateDialog } from './SubscriptionPlanUpdateDialog'import UpgradeSurveyModal from './UpgradeModal'import { STRIPE_PROJECTS_DOCS_URL } from '@/components/interfaces/Billing/Payment/PaymentMethods/StripePaymentConnection'@@ -44,6 +48,52 @@ const getPartnerManagedResourceCta = (selectedOrganization: Organization) => {}}+const PartnerManagedPlanNotice = ({+ organization,+ isStripeManaged,+ isPartnerBilled,+ stripeProjectsUpgradeCommand,+}: {+ organization: Organization | undefined+ isStripeManaged: boolean+ isPartnerBilled: boolean+ stripeProjectsUpgradeCommand: string+}) => {+ if (!organization) return null++ if (isStripeManaged) {+ return (+ <PartnerManagedResource+ managedBy={MANAGED_BY.STRIPE_PROJECTS}+ resource="Organization plans"+ title="Organization plans are managed through Stripe."+ details={+ <>+ Run <code className="text-code-inline">{stripeProjectsUpgradeCommand}</code> in your+ project directory.+ </>+ }+ cta={{+ overrideUrl: `${STRIPE_PROJECTS_DOCS_URL}#upgrade-a-service-tier`,+ message: 'Stripe Projects docs',+ }}+ />+ )+ }++ if (isPartnerBilled) {+ return (+ <PartnerManagedResource+ managedBy={organization.managed_by}+ resource="Organization plans"+ cta={getPartnerManagedResourceCta(organization)}+ />+ )+ }++ return null+}+const getStripeProjectsUpgradeCommand = (planId: string | null | undefined) => {const currentTier = planId ?? 'free'const action = currentTier === 'team' ? 'downgrade' : 'upgrade'@@ -92,7 +142,10 @@ export const PlanUpdateSidePanel = () => {)const snap = useOrgSettingsPageStateSnapshot()- const visible = snap.panelKey === 'subscriptionPlan'+ const isOpenedViaUrl = router.query.panel === 'subscriptionPlan'+ const visible = snap.panelKey === 'subscriptionPlan' || isOpenedViaUrl++ const contentDelay = isOpenedViaUrl ? 0.4 : 0.15const { data: orgProjectsData } = useOrgProjectsInfiniteQuery({ slug }, { enabled: visible })const orgProjects =@@ -129,6 +182,23 @@ export const PlanUpdateSidePanel = () => {const availablePlans: OrgPlan[] = plans?.plans ?? []+ // Only orgs that can actually act on the panel enter the experiment, and only once it is open+ const isPlanPresentationEligible =+ visible &&+ isPlanChangeEligible({+ managedBy: selectedOrganization?.managed_by,+ billingPartner: selectedOrganization?.billing_partner,+ currentPlanId: subscription?.plan?.id,+ canUpdateSubscription,+ })++ const { variant: presentation, isResolved: isPresentationResolved } =+ usePlanPresentationExperiment({ eligible: isPlanPresentationEligible })+ const isFullScreen = isFullScreenPresentation(presentation)++ // The fullscreen variant swaps the shell, so hold the panel closed until the variant is known+ const isPanelOpen = visible && isPresentationResolved+const onPanelOpened = useEffectEvent((properties: StudioPricingSidePanelOpenedEvent['properties']) => {track('studio_pricing_side_panel_opened', properties)@@ -176,62 +246,55 @@ export const PlanUpdateSidePanel = () => {selectedOrganization?.plan?.id ?? subscription?.plan?.id)+ const notice = (+ <PartnerManagedPlanNotice+ organization={selectedOrganization}+ isStripeManaged={isStripeManagedOrganization}+ isPartnerBilled={isPartnerBilledOrganization}+ stripeProjectsUpgradeCommand={stripeProjectsUpgradeCommand}+ />+ )++ const planCards = (+ <PlanCards+ availablePlans={availablePlans}+ isLoadingPlans={isLoadingPlans}+ currentSubscriptionPlanId={subscription?.plan?.id}+ currentSubscriptionPlanName={subscription?.plan?.name}+ canUpdateSubscription={canUpdateSubscription}+ isPartnerBilledOrganization={isPartnerBilledOrganization}+ hasOrioleProjects={hasOrioleProjects}+ selectedOrganization={selectedOrganization}+ variant={presentation}+ entryDelay={isFullScreen ? contentDelay : undefined}+ onSelectTier={setSelectedTier}+ />+ )+return (<>- <SidePanel- hideFooter- size="xxlarge"- visible={visible}- onCancel={() => onClose()}- header={- <div className="flex items-center justify-between w-full">- <h4>Change subscription plan for {selectedOrganization?.name}</h4>- <Button asChild variant="default" icon={<ExternalLink />}>- <a href="https://supabase.com/pricing" target="_blank" rel="noreferrer">- Pricing- </a>- </Button>- </div>- }- >- {selectedOrganization &&- (isStripeManagedOrganization ? (- <PartnerManagedResource- managedBy={MANAGED_BY.STRIPE_PROJECTS}- resource="Organization plans"- title="Organization plans are managed through Stripe."- details={- <>- Run <code className="text-code-inline">{stripeProjectsUpgradeCommand}</code> in- your project directory.- </>- }- cta={{- overrideUrl: `${STRIPE_PROJECTS_DOCS_URL}#upgrade-a-service-tier`,- message: 'Stripe Projects docs',- }}- />- ) : isPartnerBilledOrganization ? (- <PartnerManagedResource- managedBy={selectedOrganization.managed_by}- resource="Organization plans"- cta={getPartnerManagedResourceCta(selectedOrganization)}- />- ) : null)}- <SidePanel.Content>- <PlanCards- availablePlans={availablePlans}- isLoadingPlans={isLoadingPlans}- currentSubscriptionPlanId={subscription?.plan?.id}- currentSubscriptionPlanName={subscription?.plan?.name}- canUpdateSubscription={canUpdateSubscription}- isPartnerBilledOrganization={isPartnerBilledOrganization}- hasOrioleProjects={hasOrioleProjects}- selectedOrganization={selectedOrganization}- onSelectTier={setSelectedTier}- />- </SidePanel.Content>- </SidePanel>+ {isFullScreen && isPanelOpen && (+ <PlanUpdateFullScreenShell+ organizationName={selectedOrganization?.name}+ notice={notice}+ skipOverlayFade={isOpenedViaUrl}+ contentDelay={contentDelay}+ onClose={onClose}+ >+ {planCards}+ </PlanUpdateFullScreenShell>+ )}++ {!isFullScreen && (+ <PlanUpdateSheetShell+ visible={isPanelOpen}+ organizationName={selectedOrganization?.name}+ notice={notice}+ onClose={onClose}+ >+ {planCards}+ </PlanUpdateSheetShell>+ )}<CancellationFlowvisible={selectedTier === 'tier_free'}@@ -242,6 +305,7 @@ export const PlanUpdateSidePanel = () => {<SubscriptionPlanUpdateDialogselectedTier={selectedTier}onClose={() => setSelectedTier(undefined)}+ onSuccess={isFullScreen ? onClose : undefined}planMeta={planMeta}subscriptionPreviewQueryResult={subscriptionPreviewData}projects={orgProjects}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsxindex 2c9c14826fe..484da2f54e7 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/SubscriptionPlanUpdateDialog.tsx@@ -64,6 +64,8 @@ type BreakdownItem =interface Props {selectedTier: 'tier_free' | 'tier_pro' | 'tier_team' | undefinedonClose: () => void+ /** Called after the subscription update succeeds, in addition to onClose. */+ onSuccess?: () => voidplanMeta?: OrgPlan | nullcurrentPlanMeta?: Partial<OrgPlan> & { features: (string | string[])[] }subscriptionPreviewQueryResult: OrganizationBillingSubscriptionPreviewQueryResult@@ -77,6 +79,7 @@ interface Props {export const SubscriptionPlanUpdateDialog = ({selectedTier,onClose,+ onSuccess,planMeta,subscriptionPreviewQueryResult,currentPlanMeta,@@ -132,6 +135,7 @@ export const SubscriptionPlanUpdateDialog = ({`Successfully ${changeType === 'downgrade' ? 'downgraded' : 'upgraded'} subscription to ${subscriptionPlanMeta?.name}!`)onClose()+ onSuccess?.()window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })}diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.ts b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.tsindex 55140e9c581..9a5fbed383e 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.ts+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.test.ts@@ -1,6 +1,15 @@import { describe, expect, it } from 'vitest'-import { FREE_PLAN_GAPS, isPlanChangeEligible, PRO_PLAN_GAPS } from './plan-presentation'+import {+ FREE_PLAN_GAPS,+ hasPlanGaps,+ isFullScreenPresentation,+ isParityPresentation,+ isPlanChangeEligible,+ parsePlanPresentationVariant,+ PLAN_PRESENTATION_VARIANTS,+ PRO_PLAN_GAPS,+} from './plan-presentation'import { MANAGED_BY } from '@/lib/constants/infrastructure'describe('isPlanChangeEligible', () => {@@ -44,6 +53,38 @@ describe('isPlanChangeEligible', () => {})})+describe('parsePlanPresentationVariant', () => {+ it.each(PLAN_PRESENTATION_VARIANTS)('accepts %s', (variant) => {+ expect(parsePlanPresentationVariant(variant)).toBe(variant)+ })++ it.each([undefined, false, '', 'Fullscreen', 'full-screen', 'fullscreen_gaps'])(+ 'rejects %o as not in the experiment',+ (flag) => {+ expect(parsePlanPresentationVariant(flag)).toBeUndefined()+ }+ )+})++describe('presentation matrix', () => {+ // cards, shell, gaps — the three things a variant decides+ it.each([+ { variant: 'control', isParity: false, isFullScreen: false, showsGaps: false },+ { variant: 'parity', isParity: true, isFullScreen: false, showsGaps: false },+ { variant: 'gaps', isParity: true, isFullScreen: false, showsGaps: true },+ { variant: 'fullscreen', isParity: true, isFullScreen: true, showsGaps: false },+ { variant: 'fullscreen-gaps', isParity: true, isFullScreen: true, showsGaps: true },+ ] as const)('$variant', ({ variant, isParity, isFullScreen, showsGaps }) => {+ expect(isParityPresentation(variant)).toBe(isParity)+ expect(isFullScreenPresentation(variant)).toBe(isFullScreen)+ expect(hasPlanGaps(variant)).toBe(showsGaps)+ })++ it('covers every variant in the experiment', () => {+ expect(PLAN_PRESENTATION_VARIANTS).toHaveLength(5)+ })+})+describe('gap lists', () => {it('FREE_PLAN_GAPS includes backups and email support as missing', () => {const missing = FREE_PLAN_GAPS.filter((g) => g.type === 'missing')diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.ts b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.tsindex e17fb7bc77b..e7512346010 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.ts+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/plan-presentation.ts@@ -1,3 +1,4 @@+import { IS_PLATFORM, useFeatureFlags } from 'common'import { useMemo } from 'react'import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'@@ -6,11 +7,54 @@ import { usePHFlag } from '@/hooks/ui/useFlag'import { MANAGED_BY } from '@/lib/constants/infrastructure'import type { ManagedBy } from '@/lib/constants/infrastructure'-export type PlanPresentationVariant = 'control' | 'parity' | 'gaps'+export const PLAN_PRESENTATION_VARIANTS = [+ 'control',+ 'parity',+ 'gaps',+ 'fullscreen',+ 'fullscreen-gaps',+] as const++export type PlanPresentationVariant = (typeof PLAN_PRESENTATION_VARIANTS)[number]const FLAG_KEY = 'pricingPanelPlanPresentation'const EXPERIMENT_ID = 'pricing_panel_plan_presentation'+interface PlanPresentation {+ /** `control` is the original compact card; `parity` is the richer card. */+ cards: 'control' | 'parity'+ /** `sheet` is the SidePanel; `fullscreen` is a full-screen overlay. */+ shell: 'sheet' | 'fullscreen'+ /** Whether cards list what the plan is missing ("Not included" / "Plan limits"). */+ showsGaps: boolean+}++const PLAN_PRESENTATIONS: Record<PlanPresentationVariant, PlanPresentation> = {+ control: { cards: 'control', shell: 'sheet', showsGaps: false },+ parity: { cards: 'parity', shell: 'sheet', showsGaps: false },+ gaps: { cards: 'parity', shell: 'sheet', showsGaps: true },+ fullscreen: { cards: 'parity', shell: 'fullscreen', showsGaps: false },+ 'fullscreen-gaps': { cards: 'parity', shell: 'fullscreen', showsGaps: true },+}++export function parsePlanPresentationVariant(+ flag: string | boolean | undefined+): PlanPresentationVariant | undefined {+ return PLAN_PRESENTATION_VARIANTS.find((variant) => variant === flag)+}++export function isParityPresentation(variant: PlanPresentationVariant): boolean {+ return PLAN_PRESENTATIONS[variant].cards === 'parity'+}++export function isFullScreenPresentation(variant: PlanPresentationVariant): boolean {+ return PLAN_PRESENTATIONS[variant].shell === 'fullscreen'+}++export function hasPlanGaps(variant: PlanPresentationVariant): boolean {+ return PLAN_PRESENTATIONS[variant].showsGaps+}+export function isPlanChangeEligible({managedBy,billingPartner,@@ -30,24 +74,32 @@ export function isPlanChangeEligible({return true}+export interface PlanPresentationExperiment {+ variant: PlanPresentationVariant+ /**+ * False while PostHog flags are still in flight. The `fullscreen` variant swaps the whole panel+ * shell, so callers must wait rather than open the control sheet and swap it out mid-animation.+ */+ isResolved: boolean+}+export function usePlanPresentationExperiment({eligible,}: {eligible: boolean-}): PlanPresentationVariant {- const flag = usePHFlag<'control' | 'parity' | 'gaps'>(FLAG_KEY)-- const isInExperiment = flag === 'control' || flag === 'parity' || flag === 'gaps'+}): PlanPresentationExperiment {+ const { hasLoaded } = useFeatureFlags()+ const flag = usePHFlag<PlanPresentationVariant>(FLAG_KEY)- const variant: PlanPresentationVariant = useMemo(() => {- if (!eligible || !isInExperiment) return 'control'- return flag as PlanPresentationVariant- }, [eligible, isInExperiment, flag])+ const assignedVariant = useMemo(() => parsePlanPresentationVariant(flag), [flag])- const liveVariant = eligible && isInExperiment ? variant : undefined+ const liveVariant = eligible ? assignedVariant : undefineduseTrackExperimentExposure(EXPERIMENT_ID, liveVariant)- return variant+ return {+ variant: liveVariant ?? 'control',+ isResolved: !IS_PLATFORM || !!hasLoaded,+ }}export interface GapFeature {