Skip to content

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

chore: improve org-billing infos

Kevin Grüneberg47ec07ca3aaf
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/ChangePaymentMethodModal.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/ChangePaymentMethodModal.tsx
index a58f2f57cd1..7b4485b01a8 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/ChangePaymentMethodModal.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/PaymentMethods/ChangePaymentMethodModal.tsx
@@ -1,10 +1,8 @@
import { useParams } from 'common'
import { OrganizationPaymentMethod } from 'data/organizations/organization-payment-methods-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
-import {
- SubscriptionTier,
- useOrgSubscriptionUpdateMutation,
-} from 'data/subscriptions/org-subscription-update-mutation'
+import { useOrgSubscriptionUpdateMutation } from 'data/subscriptions/org-subscription-update-mutation'
+import { SubscriptionTier } from 'data/subscriptions/types'
import { useStore } from 'hooks'
import { Button, Modal } from 'ui'
diff --git a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx
index 03c23fb582d..649e6984542 100644
--- a/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx
+++ b/studio/components/interfaces/Organization/BillingSettingsV2/Subscription/PlanUpdateSidePanel.tsx
@@ -7,10 +7,7 @@ import { useEffect, useState } from 'react'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useOrgPlansQuery } from 'data/subscriptions/org-plans-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
-import {
- SubscriptionTier,
- useOrgSubscriptionUpdateMutation,
-} from 'data/subscriptions/org-subscription-update-mutation'
+import { useOrgSubscriptionUpdateMutation } from 'data/subscriptions/org-subscription-update-mutation'
import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
import { PRICING_TIER_PRODUCT_IDS } from 'lib/constants'
import Telemetry from 'lib/telemetry'
@@ -27,6 +24,7 @@ import { useFreeProjectLimitCheckQuery } from 'data/organizations/free-project-l
import { useOrganizationBillingSubscriptionPreview } from 'data/organizations/organization-billing-subscription-preview'
import InformationBox from 'components/ui/InformationBox'
import AlertError from 'components/ui/AlertError'
+import { SubscriptionTier } from 'data/subscriptions/types'
// [Joshen TODO] Need to remove all contexts of "projects"
@@ -266,7 +264,7 @@ const PlanUpdateSidePanel = () => {
<div className="border-t my-6" />
<ul role="list">
- {(plan.features).map((feature) => (
+ {plan.features.map((feature) => (
<li key={feature} className="flex py-2">
<div className="w-[12px]">
<IconCheck
@@ -304,7 +302,7 @@ const PlanUpdateSidePanel = () => {
<Modal
loading={isUpdating}
alignFooter="right"
- className="!w-[550px]"
+ size="large"
visible={selectedTier !== undefined && selectedTier !== 'tier_free'}
onCancel={() => setSelectedTier(undefined)}
onConfirm={onUpdateSubscription}
diff --git a/studio/components/interfaces/Organization/GeneralSettings/MigrateOrganizationBillingButton.tsx b/studio/components/interfaces/Organization/GeneralSettings/MigrateOrganizationBillingButton.tsx
index 6a2710f8a1a..a6d84f2e874 100644
--- a/studio/components/interfaces/Organization/GeneralSettings/MigrateOrganizationBillingButton.tsx
+++ b/studio/components/interfaces/Organization/GeneralSettings/MigrateOrganizationBillingButton.tsx
@@ -37,7 +37,7 @@ const MigrateOrganizationBillingButton = observer(() => {
const [isOpen, setIsOpen] = useState(false)
const [tier, setTier] = useState('')
const [showSpendCapHelperModal, setShowSpendCapHelperModal] = useState(false)
- const [isSpendCapEnabled, setIsSpendCapEnabled] = useState(true)
+ const [isSpendCapEnabled, setIsSpendCapEnabled] = useState(false)
const [paymentMethodId, setPaymentMethodId] = useState('')
const dbTier = useMemo(() => {
@@ -95,6 +95,23 @@ const MigrateOrganizationBillingButton = observer(() => {
const canMigrateOrganization = useCheckPermissions(PermissionAction.UPDATE, 'organizations')
+ const selectedLimitedUsage = useMemo(
+ () => tier === 'PRO' && isSpendCapEnabled,
+ [tier, isSpendCapEnabled]
+ )
+
+ const downgradingToLimitedUsage = useMemo(() => {
+ if (migrationPreviewData) {
+ const hadUsageBillingEnabled = migrationPreviewData.old_tiers.some((it) =>
+ ['tier_payg', 'tier_team', 'tier_enterprise'].includes(it)
+ )
+
+ return hadUsageBillingEnabled && selectedLimitedUsage
+ } else {
+ return false
+ }
+ }, [migrationPreviewData, selectedLimitedUsage])
+
const toggle = () => {
setIsOpen(!isOpen)
}
@@ -297,8 +314,8 @@ const MigrateOrganizationBillingButton = observer(() => {
<div className="col-span-12">
<p className="text-sm text-scale-1000">
When enabled, usage is limited to the plan's quota, with restrictions when
- limits are exceeded. To scale beyond Pro limits without restrictions, disable
- the spend cap and pay for over-usage beyond the quota.
+ limits are exceeded. When disabled, you scale beyond Pro limits without
+ restrictions and pay for over-usage beyond the quota.
</p>
</div>
@@ -326,15 +343,46 @@ const MigrateOrganizationBillingButton = observer(() => {
<Modal.Content>
<Loading active={tier !== '' && migrationPreviewIsLoading}>
- {migrationPreviewError && (
- <Alert_Shadcn_ variant="destructive">
- <IconAlertCircle strokeWidth={2} />
- <AlertTitle_Shadcn_>Organization cannot be migrated</AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- {migrationPreviewError.message}
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
+ <div className="space-y-3">
+ {migrationPreviewError && (
+ <Alert_Shadcn_ variant="destructive">
+ <IconAlertCircle strokeWidth={2} />
+ <AlertTitle_Shadcn_>Organization cannot be migrated</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ {migrationPreviewError.message}
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
+
+ {(downgradingToLimitedUsage ||
+ (!downgradingToLimitedUsage && selectedLimitedUsage)) && (
+ <Alert_Shadcn_ variant="warning">
+ <IconAlertCircle strokeWidth={2} />
+ <AlertTitle_Shadcn_>Spend Cap is enabled</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <div className="space-y-2">
+ {downgradingToLimitedUsage ? (
+ <p>
+ You previously had the spend cap disabled to scale seamlessly beyond the
+ included quota. You will run into restrictions in case you exceed the
+ included quota.
+ </p>
+ ) : (
+ <p>
+ With the Spend Cap enabled, your projects will be restricted once you
+ exhaust the included quota. To scale seamlessly beyond the included
+ quota, disable the Spend Cap.
+ </p>
+ )}
+
+ <Button type="outline" onClick={() => setIsSpendCapEnabled(false)}>
+ Disable Spend Cap
+ </Button>
+ </div>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
+ </div>
</Loading>
{migrationError && (
diff --git a/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx b/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx
index 072b9c83c79..1bd733e909a 100644
--- a/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx
+++ b/studio/components/interfaces/Settings/General/TransferProjectPanel/TransferProjectButton.tsx
@@ -144,7 +144,13 @@ const TransferProjectButton = () => {
<Modal.Content>
<p className="text-sm">
To transfer projects, the owner must be a member of both the source and target
- organizations.
+ organizations. For further information see our{' '}
+ <Link href="https://supabase.com/docs/guides/platform/project-transfer">
+ <a className="text-brand hover:underline" target="_blank" rel="noreferrer">
+ Documentation
+ </a>
+ </Link>
+ .
</p>
<p className="font-bold mt-6 text-sm">Transferring considerations:</p>
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
index 17387da6b9f..05088113ee6 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
@@ -38,7 +38,7 @@ const LayoutHeader = ({ customHeaderComponents, breadcrumbs = [], headerBorder =
{ enabled: selectedOrganization && !selectedOrganization.subscription_id }
)
- const projectHasNoLimits = subscription?.usage_billing_enabled === false
+ const projectHasNoLimits = subscription?.usage_billing_enabled === true
const showOverUsageBadge =
useFlag('overusageBadge') &&
diff --git a/studio/data/organizations/organization-billing-subscription-preview.ts b/studio/data/organizations/organization-billing-subscription-preview.ts
index 8c9068d9322..910eef3bed4 100644
--- a/studio/data/organizations/organization-billing-subscription-preview.ts
+++ b/studio/data/organizations/organization-billing-subscription-preview.ts
@@ -2,10 +2,11 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { post } from 'data/fetchers'
import { organizationKeys } from './keys'
import { ResponseError } from 'types'
+import { SubscriptionTier } from 'data/subscriptions/types'
export type OrganizationBillingSubscriptionPreviewVariables = {
organizationSlug?: string
- tier?: 'tier_payg' | 'tier_pro' | 'tier_free' | 'tier_team' | 'tier_enterprise'
+ tier?: SubscriptionTier
}
export type OrganizationBillingSubscriptionPreviewResponse = {
diff --git a/studio/data/organizations/organization-migrate-billing-preview-query.ts b/studio/data/organizations/organization-migrate-billing-preview-query.ts
index ef5e6551319..4b6628acecd 100644
--- a/studio/data/organizations/organization-migrate-billing-preview-query.ts
+++ b/studio/data/organizations/organization-migrate-billing-preview-query.ts
@@ -2,6 +2,7 @@ import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { post } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
import { organizationKeys } from './keys'
+import { SubscriptionTier } from 'data/subscriptions/types'
export type OrganizationBillingMigrationPreviewVariables = {
organizationSlug?: string
@@ -21,6 +22,7 @@ export type OrganizationBillingMigrationPreviewResponse = {
quantity: number
total_price: number
}[]
+ old_tiers: SubscriptionTier[]
}
export async function previewOrganizationBillingMigration(
diff --git a/studio/data/subscriptions/org-subscription-update-mutation.ts b/studio/data/subscriptions/org-subscription-update-mutation.ts
index 4e91365c39e..ad6cae5e40a 100644
--- a/studio/data/subscriptions/org-subscription-update-mutation.ts
+++ b/studio/data/subscriptions/org-subscription-update-mutation.ts
@@ -5,13 +5,7 @@ import { toast } from 'react-hot-toast'
import { ResponseError } from 'types/base'
import { subscriptionKeys } from './keys'
import { usageKeys } from 'data/usage/keys'
-
-export type SubscriptionTier =
- | 'tier_free'
- | 'tier_pro'
- | 'tier_payg'
- | 'tier_team'
- | 'tier_enterprise'
+import { SubscriptionTier } from './types'
export type OrgSubscriptionUpdateVariables = {
slug: string
diff --git a/studio/data/subscriptions/types.ts b/studio/data/subscriptions/types.ts
new file mode 100644
index 00000000000..d0755cb9406
--- /dev/null
+++ b/studio/data/subscriptions/types.ts
@@ -0,0 +1,6 @@
+export type SubscriptionTier =
+ | 'tier_free'
+ | 'tier_pro'
+ | 'tier_payg'
+ | 'tier_team'
+ | 'tier_enterprise'
diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsx
index 3179618a1d9..16300ebd9ad 100644
--- a/studio/pages/new/[slug].tsx
+++ b/studio/pages/new/[slug].tsx
@@ -496,7 +496,14 @@ const Wizard: NextPageWithLayout = () => {
</div>
)}
- <div>
+ <div className="space-x-3">
+ <Link href="https://supabase.com/blog/organization-based-billing">
+ <a target="_blank" rel="noreferrer">
+ <Button type="default" icon={<IconExternalLink strokeWidth={1.5} />}>
+ Announcement
+ </Button>
+ </a>
+ </Link>
<Link href="https://supabase.com/docs/guides/platform/org-based-billing">
<a target="_blank" rel="noreferrer">
<Button type="default" icon={<IconExternalLink strokeWidth={1.5} />}>
@@ -573,6 +580,51 @@ const Wizard: NextPageWithLayout = () => {
</Panel.Content>
)}
+ {!billedViaOrg && (
+ <Panel.Content>
+ <InformationBox
+ icon={<IconInfo size="large" strokeWidth={1.5} />}
+ defaultVisibility={true}
+ hideCollapse
+ title="Legacy Billing"
+ description={
+ <div className="space-y-3">
+ <p className="text-sm leading-normal">
+ This organization uses the legacy project-based billing. We’ve recently made
+ some big improvements to our billing system. To opt-in to the new
+ organization-based billing, head over to your{' '}
+ <Link href={`/org/${slug}/billing`}>
+ <a>
+ <span className="text-sm text-green-900 transition hover:text-green-1000">
+ organization billing settings
+ </span>
+ </a>
+ </Link>
+ .
+ </p>
+
+ <div className="space-x-3">
+ <Link href="https://supabase.com/blog/organization-based-billing">
+ <a target="_blank" rel="noreferrer">
+ <Button type="default" icon={<IconExternalLink strokeWidth={1.5} />}>
+ Announcement
+ </Button>
+ </a>
+ </Link>
+ <Link href="https://supabase.com/docs/guides/platform/org-based-billing">
+ <a target="_blank" rel="noreferrer">
+ <Button type="default" icon={<IconExternalLink strokeWidth={1.5} />}>
+ Documentation
+ </Button>
+ </a>
+ </Link>
+ </div>
+ </div>
+ }
+ />
+ </Panel.Content>
+ )}
+
{!billedViaOrg && !isSelectFreeTier && (
<>
<Panel.Content className="border-b border-panel-border-interior-light dark:border-panel-border-interior-dark">