Skip to content

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

Hide compute size options for af south 1 region

Joshen Lim2960c7ba1b68
diff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx
index de23d8e25a6..d7433a38272 100644
--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx
+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/index.tsx
@@ -1,6 +1,7 @@
import { FC } from 'react'
import { Listbox, IconLoader, Button, IconPlus, IconAlertCircle } from '@supabase/ui'
+import { useStore } from 'hooks'
import { STRIPE_PRODUCT_IDS } from 'lib/constants'
import { StripeProduct } from '..'
import { SubscriptionPreview } from '../Billing.types'
@@ -47,6 +48,9 @@ const PaymentSummaryPanel: FC<Props> = ({
onConfirmPayment,
isSubmitting,
}) => {
+ const { ui } = useStore()
+ const projectRegion = ui.selectedProject?.region
+
const isChangingPlan =
(currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG && currentPlan.prod_id !== selectedPlan?.id) ||
(currentPlan.prod_id !== STRIPE_PRODUCT_IDS.PAYG && !isSpendCapEnabled) ||
@@ -88,41 +92,47 @@ const PaymentSummaryPanel: FC<Props> = ({
</div>
{/* Add on details */}
- <div className="space-y-1">
- <p className="text-sm">Selected add-ons</p>
- {currentComputeSize === undefined && selectedComputeSize === undefined && (
- <p className="text-scale-1100 text-sm">No add-ons selected</p>
- )}
- {currentComputeSize !== undefined && (
- <div className="flex items-center justify-between">
- <p className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}>
- {currentComputeSize.name}
- </p>
- <p className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}>
- ${(currentComputeSize.prices[0].unit_amount / 100).toFixed(2)}
- </p>
- </div>
- )}
- {isChangingComputeSize && (
- <div className="flex items-center justify-between">
- <p className="text-sm">{selectedComputeSize.name}</p>
- <p className="text-sm">
- ${(selectedComputeSize.prices[0].unit_amount / 100).toFixed(2)}
- </p>
- </div>
- )}
- {isChangingComputeSize && (
- <div className="!mt-4">
- <InformationBox
- hideCollapse
- defaultVisibility
- icon={<IconAlertCircle strokeWidth={2} />}
- title="Changing your compute size"
- description="It will take up to 2 minutes for changes to take place, and your project will be unavailable during that time"
- />
- </div>
- )}
- </div>
+ {projectRegion !== 'af-south-1' && (
+ <div className="space-y-1">
+ <p className="text-sm">Selected add-ons</p>
+ {currentComputeSize === undefined && selectedComputeSize === undefined && (
+ <p className="text-scale-1100 text-sm">No add-ons selected</p>
+ )}
+ {currentComputeSize !== undefined && (
+ <div className="flex items-center justify-between">
+ <p
+ className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}
+ >
+ {currentComputeSize.name}
+ </p>
+ <p
+ className={`${isChangingComputeSize ? 'text-scale-1100 line-through' : ''} text-sm`}
+ >
+ ${(currentComputeSize.prices[0].unit_amount / 100).toFixed(2)}
+ </p>
+ </div>
+ )}
+ {isChangingComputeSize && (
+ <div className="flex items-center justify-between">
+ <p className="text-sm">{selectedComputeSize.name}</p>
+ <p className="text-sm">
+ ${(selectedComputeSize.prices[0].unit_amount / 100).toFixed(2)}
+ </p>
+ </div>
+ )}
+ {isChangingComputeSize && (
+ <div className="!mt-4">
+ <InformationBox
+ hideCollapse
+ defaultVisibility
+ icon={<IconAlertCircle strokeWidth={2} />}
+ title="Changing your compute size"
+ description="It will take up to 2 minutes for changes to take place, and your project will be unavailable during that time"
+ />
+ </div>
+ )}
+ </div>
+ )}
<div className="h-px w-full bg-scale-600" />
diff --git a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.ts b/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.ts
index 9a20e68b4a9..1dc9d883fa1 100644
--- a/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.ts
+++ b/studio/components/interfaces/Billing/ProUpgrade/ProUpgrade.utils.ts
@@ -1,16 +1,11 @@
export const formSubscriptionUpdatePayload = (
selectedTier: any,
selectedComputeSize: any,
- selectedPaymentMethod: string
+ selectedPaymentMethod: string,
+ region: string
) => {
- // [TODO] Small currently has no stripe product attached, so FE has a hardcoded ID just for that product
- // [UPDATE] it now has, just verify if attaching a Small will mess things up
- // const addons = selectedComputeSize.name.includes('[Small]')
- // ? []
- // : [selectedComputeSize.prices[0].id]
- const addons = [selectedComputeSize.prices[0].id]
+ const addons = region === 'af-south-1' ? [] : [selectedComputeSize.prices[0].id]
const proration_date = Math.floor(Date.now() / 1000)
-
return {
tier: selectedTier.prices[0].id,
addons,
diff --git a/studio/components/interfaces/Billing/ProUpgrade/index.tsx b/studio/components/interfaces/Billing/ProUpgrade/index.tsx
index 1f42a2896e1..5cba4c01f02 100644
--- a/studio/components/interfaces/Billing/ProUpgrade/index.tsx
+++ b/studio/components/interfaces/Billing/ProUpgrade/index.tsx
@@ -18,6 +18,8 @@ import { SubscriptionPreview } from '../Billing.types'
import UpdateSuccess from '../UpdateSuccess'
import { formSubscriptionUpdatePayload } from './ProUpgrade.utils'
+// Do not allow compute size changes for af-south-1
+
interface Props {
products: { tiers: any[]; addons: any[] }
paymentMethods?: any[]
@@ -37,6 +39,7 @@ const ProUpgrade: FC<Props> = ({
const { addons } = products
const projectRef = ui.selectedProject?.ref
+ const projectRegion = ui.selectedProject?.region ?? ''
const currentComputeSize =
addons.find((option: any) => option.id === currentSubscription?.addons[0]?.prod_id) ||
@@ -47,7 +50,10 @@ const ProUpgrade: FC<Props> = ({
currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PAYG
const [isSpendCapEnabled, setIsSpendCapEnabled] = useState(
- currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PRO
+ // If project is currently free, default to enabling spend caps
+ currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.FREE ||
+ // Otherwise, Pro plan implies spend caps enabled
+ currentSubscription.tier.prod_id === STRIPE_PRODUCT_IDS.PRO
)
const [isRefreshingPreview, setIsRefreshingPreview] = useState(false)
@@ -86,7 +92,8 @@ const ProUpgrade: FC<Props> = ({
const payload = formSubscriptionUpdatePayload(
selectedTier,
selectedComputeSize,
- selectedPaymentMethod
+ selectedPaymentMethod,
+ projectRegion
)
setIsRefreshingPreview(true)
@@ -106,7 +113,8 @@ const ProUpgrade: FC<Props> = ({
const payload = formSubscriptionUpdatePayload(
selectedTier,
selectedComputeSize,
- selectedPaymentMethod
+ selectedPaymentMethod,
+ projectRegion
)
setIsSubmitting(true)
@@ -194,16 +202,20 @@ const ProUpgrade: FC<Props> = ({
onChange={() => setIsSpendCapEnabled(!isSpendCapEnabled)}
/>
</div>
- <Divider light />
- <div className="flex items-center space-x-2">
- <h4 className="text-lg">Extend your project with add-ons</h4>
- <Badge color="green">Optional</Badge>
- </div>
- <ComputeSizeSelection
- computeSizes={addons || []}
- selectedComputeSize={selectedComputeSize}
- onSelectOption={onSelectComputeSizeOption}
- />
+ {projectRegion !== 'af-south-1' && (
+ <>
+ <Divider light />
+ <div className="flex items-center space-x-2">
+ <h4 className="text-lg">Extend your project with add-ons</h4>
+ <Badge color="green">Optional</Badge>
+ </div>
+ <ComputeSizeSelection
+ computeSizes={addons || []}
+ selectedComputeSize={selectedComputeSize}
+ onSelectOption={onSelectComputeSizeOption}
+ />
+ </>
+ )}
</div>
</div>
</div>
@@ -247,7 +259,6 @@ const ProUpgrade: FC<Props> = ({
>
<div className="py-4 space-y-4">
<Modal.Content>
- {/* [TODO] revise wording for "enabling spend caps" instead of overages */}
<div className="space-y-4">
<p className="text-sm">
A spend cap allows you to restrict your project's resource usage within the limits
diff --git a/studio/pages/project/[ref]/settings/billing/update/pro.tsx b/studio/pages/project/[ref]/settings/billing/update/pro.tsx
index d36898cfbd7..01f11969b52 100644
--- a/studio/pages/project/[ref]/settings/billing/update/pro.tsx
+++ b/studio/pages/project/[ref]/settings/billing/update/pro.tsx
@@ -15,8 +15,9 @@ import { ProUpgrade } from 'components/interfaces/Billing'
const BillingUpdatePro: NextPage = () => {
const { ui } = useStore()
const router = useRouter()
+
const projectRef = ui.selectedProject?.ref
- const stripeCustomerId = ui.selectedOrganization?.stripe_customer_id
+ const orgSlug = ui.selectedOrganization?.slug
const [isLoadingProducts, setIsLoadingProducts] = useState(false)
const [isLoadingPaymentMethods, setIsLoadingPaymentMethods] = useState(false)
@@ -36,10 +37,15 @@ const BillingUpdatePro: NextPage = () => {
if (projectRef) {
getStripeProducts()
getSubscription()
- getPaymentMethods()
}
}, [projectRef])
+ useEffect(() => {
+ if (orgSlug) {
+ getPaymentMethods()
+ }
+ }, [orgSlug])
+
const getStripeProducts = async () => {
try {
setIsLoadingProducts(true)