The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Remove back button in teams subscription page, and refactor to disable UI instead of redirecting if project update is disabled
Joshen Limd6ea9ed199cb
diff --git a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsxindex e8caaf6111f..41b797cefb3 100644--- a/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx+++ b/studio/components/interfaces/Billing/ExitSurvey/ExitSurvey.tsx@@ -1,10 +1,11 @@-import { FC, useReducer, useState, useEffect, useRef } from 'react'+import { useReducer, useState, useEffect, useRef } from 'react'import { useRouter } from 'next/router'import { includes, without } from 'lodash'import { Transition } from '@headlessui/react'+import * as Tooltip from '@radix-ui/react-tooltip'import { Button, Form, Input, Modal, IconArrowLeft, Alert } from 'ui'-import { useStore } from 'hooks'+import { useFlag, useStore } from 'hooks'import { post, patch } from 'lib/common/fetch'import { API_URL, PROJECT_STATUS } from 'lib/constants'import { CANCELLATION_REASONS } from '../Billing.constants'@@ -13,13 +14,13 @@ import { SubscriptionPreview } from '../Billing.types'import { StripeSubscription } from 'components/interfaces/Billing'import HCaptcha from '@hcaptcha/react-hcaptcha'-interface Props {+interface ExitSurveyProps {freeTier: anysubscription?: StripeSubscriptiononSelectBack: () => void}-const ExitSurvey: FC<Props> = ({ freeTier, subscription, onSelectBack }) => {+const ExitSurvey = ({ freeTier, subscription, onSelectBack }: ExitSurveyProps) => {const router = useRouter()const { app, ui } = useStore()const projectId = ui.selectedProject?.id ?? -1@@ -27,6 +28,7 @@ const ExitSurvey: FC<Props> = ({ freeTier, subscription, onSelectBack }) => {const captchaRef = useRef<HCaptcha>(null)const [captchaToken, setCaptchaToken] = useState<string | null>(null)+ const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')const formRef = useRef<any>()@@ -260,14 +262,36 @@ const ExitSurvey: FC<Props> = ({ freeTier, subscription, onSelectBack }) => {>Cancel</Button>- <Button- type="danger"- htmlType="submit"- loading={isSubmitting}- disabled={isSubmitting}- >- Confirm downgrade- </Button>+ <Tooltip.Root delayDuration={0}>+ <Tooltip.Trigger className="w-full">+ <Button+ type="danger"+ htmlType="submit"+ loading={isSubmitting}+ disabled={projectUpdateDisabled || isSubmitting}+ >+ Confirm downgrade+ </Button>+ </Tooltip.Trigger>+ {projectUpdateDisabled ? (+ <Tooltip.Portal>+ <Tooltip.Content side="bottom">+ <Tooltip.Arrow className="radix-tooltip-arrow" />+ <div+ className={[+ 'rounded bg-scale-100 py-1 px-2 leading-none shadow',+ 'border border-scale-200',+ ].join(' ')}+ >+ <span className="text-xs text-scale-1200">+ Subscription changes are currently disabled. Our engineers are+ working on a fix.+ </span>+ </div>+ </Tooltip.Content>+ </Tooltip.Portal>+ ) : null}+ </Tooltip.Root><p className="text-xs text-scale-900">The unused amount for the remaining of your billing cycle will be refunded ascreditsdiff --git a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsxindex 60d4149fda2..6dbdad3a164 100644--- a/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx+++ b/studio/components/interfaces/Billing/PaymentSummaryPanel/PaymentSummaryPanel.tsx@@ -3,7 +3,7 @@ import * as Tooltip from '@radix-ui/react-tooltip'import { Listbox, IconLoader, Button, IconPlus, IconAlertCircle, IconCreditCard } from 'ui'import { PermissionAction } from '@supabase/shared-types/out/constants'-import { checkPermissions, useStore } from 'hooks'+import { checkPermissions, useFlag, useStore } from 'hooks'import { BASE_PATH, PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'import { SubscriptionPreview } from '../Billing.types'import { getProductPrice, validateSubscriptionUpdatePayload } from '../Billing.utils'@@ -93,6 +93,7 @@ const PaymentSummaryPanel = ({)const [showConfirmModal, setShowConfirmModal] = useState(false)+ const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')const selectedPlanCost =selectedPlan !== undefined@@ -452,6 +453,7 @@ const PaymentSummaryPanel = ({loading={isSubmitting}disabled={!isActive ||+ projectUpdateDisabled ||isSubmitting ||isLoadingPaymentMethods ||!hasChangesToPlan ||@@ -479,6 +481,8 @@ const PaymentSummaryPanel = ({? 'Please select a payment method': !isActive? 'Unable to update subscription as project is not active'+ : projectUpdateDisabled+ ? 'Subscription changes are currently disabled. Our engineers are working on a fix.': ''}</span></div>diff --git a/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx b/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsxindex 8718452e6d1..f31eb7e8c6e 100644--- a/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx+++ b/studio/components/interfaces/Billing/PlanSelection/Plans/PlanCTAButton.tsx@@ -14,7 +14,7 @@ interface PlanCTAButtonProps {}const PlanCTAButton = ({ plan, currentPlan, onSelectPlan }: PlanCTAButtonProps) => {- const isActive = useIsProjectActive()+ const isProjectActive = useIsProjectActive()const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')const getButtonType = (plan: any, currentPlan: any) => {@@ -85,7 +85,7 @@ const PlanCTAButton = ({ plan, currentPlan, onSelectPlan }: PlanCTAButtonProps)const type = getButtonType(plan, currentPlan)const ctaText = getButtonText(plan, currentPlan)const disabled =- (!isActive && plan.name !== 'Enterprise') ||+ (!isProjectActive && plan.name !== 'Enterprise') ||(plan.id === STRIPE_PRODUCT_IDS.FREE && currentPlan.prod_id === STRIPE_PRODUCT_IDS.FREE)if (plan.name === 'Enterprise') {@@ -113,7 +113,7 @@ const PlanCTAButton = ({ plan, currentPlan, onSelectPlan }: PlanCTAButtonProps){ctaText}</Button></Tooltip.Trigger>- {(projectUpdateDisabled || !isActive) && (+ {(projectUpdateDisabled || !isProjectActive) && (<Tooltip.Portal><Tooltip.Portal><Tooltip.Content side="bottom">@@ -127,7 +127,7 @@ const PlanCTAButton = ({ plan, currentPlan, onSelectPlan }: PlanCTAButtonProps)<span className="text-xs text-scale-1200 text-center">{projectUpdateDisabled? 'Subscription changes are currently disabled, our engineers are working on a fix'- : !isActive+ : !isProjectActive? 'Unable to update subscription as project is not active': ''}</span>diff --git a/studio/components/interfaces/Billing/Subscription/Subscription.tsx b/studio/components/interfaces/Billing/Subscription/Subscription.tsxindex b803cd90204..f77be7f75d2 100644--- a/studio/components/interfaces/Billing/Subscription/Subscription.tsx+++ b/studio/components/interfaces/Billing/Subscription/Subscription.tsx@@ -1,6 +1,6 @@import dayjs from 'dayjs'+import Link from 'next/link'import { FC, useEffect } from 'react'-import { useRouter } from 'next/router'import { Button, Loading } from 'ui'import * as Tooltip from '@radix-ui/react-tooltip'import { PermissionAction } from '@supabase/shared-types/out/constants'@@ -23,7 +23,6 @@ interface Props {}const Subscription: FC<Props> = ({ showProjectName = false }) => {- const router = useRouter()const { ui } = useStore()const { ref: projectRef } = useParams()const isActive = useIsProjectActive()@@ -41,10 +40,12 @@ const Subscription: FC<Props> = ({ showProjectName = false }) => {isLoading: loading,error,} = useProjectSubscriptionQuery({ projectRef: ui.selectedProject?.ref })- const { data: usage, isLoading: loadingUsage } = useProjectUsageQuery({ projectRef })+ const { data: usage } = useProjectUsageQuery({ projectRef })const isPayg = subscription?.tier.prod_id === STRIPE_PRODUCT_IDS.PAYG+ const isTeams = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.TEAMconst isEnterprise = subscription?.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE+ const canOnlyUpdateAddons = isTeams || isEnterpriseconst addOns = subscription?.addons ?? []const paid = subscription && subscription.tier.unit_amount > 0@@ -69,6 +70,12 @@ const Subscription: FC<Props> = ({ showProjectName = false }) => {return basePlanCost + totalAddOnCost + totalUsageCost}+ const subscriptionUpdateURL = isEnterprise+ ? `/project/${projectRef}/settings/billing/update/enterprise`+ : isTeams+ ? `/project/${projectRef}/settings/billing/update/team`+ : `/project/${projectRef}/settings/billing/update`+useEffect(() => {if (error) {ui.setNotification({@@ -92,18 +99,16 @@ const Subscription: FC<Props> = ({ showProjectName = false }) => {<div className="flex flex-col items-end space-y-2"><Tooltip.Root delayDuration={0}><Tooltip.Trigger>- <Button- disabled={!canUpdateSubscription || projectUpdateDisabled || !isActive}- onClick={() => {- const url = isEnterprise- ? `/project/${projectRef}/settings/billing/update/enterprise`- : `/project/${projectRef}/settings/billing/update`- router.push(url)- }}- type="primary"- >- {isEnterprise ? 'Change add-ons' : 'Change subscription'}- </Button>+ <Link href={subscriptionUpdateURL}>+ <a>+ <Button+ type="primary"+ disabled={!canUpdateSubscription || projectUpdateDisabled || !isActive}+ >+ {canOnlyUpdateAddons ? 'Change add-ons' : 'Change subscription'}+ </Button>+ </a>+ </Link></Tooltip.Trigger>{!canUpdateSubscription || projectUpdateDisabled || !isActive ? (<Tooltip.Portal>diff --git a/studio/components/interfaces/Billing/TeamUpgrade.tsx b/studio/components/interfaces/Billing/TeamUpgrade.tsxindex a8033574110..b85d7c15fff 100644--- a/studio/components/interfaces/Billing/TeamUpgrade.tsx+++ b/studio/components/interfaces/Billing/TeamUpgrade.tsx@@ -1,4 +1,4 @@-import { FC, useEffect, useRef, useState } from 'react'+import { useEffect, useRef, useState } from 'react'import { Transition } from '@headlessui/react'import { useRouter } from 'next/router'@@ -25,27 +25,24 @@ import {formatCustomDomainOptions,formatPITROptions,} from './AddOns/AddOns.utils'-import BackButton from 'components/ui/BackButton'import SupportPlan from './AddOns/SupportPlan'import HCaptcha from '@hcaptcha/react-hcaptcha'// Do not allow compute size changes for af-south-1-interface Props {+interface TeamUpgradeProps {products: { tiers: any[]; addons: SubscriptionAddon[] }paymentMethods?: PaymentMethod[]currentSubscription: StripeSubscriptionisLoadingPaymentMethods: boolean- onSelectBack: () => void}-const TeamUpgrade: FC<Props> = ({+const TeamUpgrade = ({products,paymentMethods,currentSubscription,isLoadingPaymentMethods,- onSelectBack,-}) => {+}: TeamUpgradeProps) => {const { app, ui } = useStore()const router = useRouter()@@ -226,7 +223,6 @@ const TeamUpgrade: FC<Props> = ({<div className="flex-grow mt-10"><div className="relative space-y-4"><div className="relative px-32 mx-auto space-y-4 2xl:max-w-5xl">- <BackButton onClick={() => onSelectBack()} /><h4 className="text-lg text-scale-900 !mb-8">Change your project's subscription</h4></div>diff --git a/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx b/studio/pages/project/[ref]/settings/billing/update/enterprise.tsxindex e4f895b2fc7..90c6d4a9c94 100644--- a/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/enterprise.tsx@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'-import { useStore, useFlag } from 'hooks'+import { useStore } from 'hooks'import { NextPageWithLayout } from 'types'import { API_URL, PRICING_TIER_PRODUCT_IDS } from 'lib/constants'import { get } from 'lib/common/fetch'@@ -18,7 +18,6 @@ const BillingUpdateEnterprise: NextPageWithLayout = () => {const projectRef = ui.selectedProject?.refconst orgSlug = ui.selectedOrganization?.slug- const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')const [isLoadingPaymentMethods, setIsLoadingPaymentMethods] = useState(false)const [subscription, setSubscription] = useState<StripeSubscription>()@@ -29,9 +28,7 @@ const BillingUpdateEnterprise: NextPageWithLayout = () => {subscription && subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISEuseEffect(() => {- if (projectUpdateDisabled) {- router.push(`/project/${projectRef}/settings/billing/update`)- } else if (projectRef) {+ if (projectRef) {getStripeProducts()getSubscription()}diff --git a/studio/pages/project/[ref]/settings/billing/update/free.tsx b/studio/pages/project/[ref]/settings/billing/update/free.tsxindex ba62f0cd89f..efd5b49a206 100644--- a/studio/pages/project/[ref]/settings/billing/update/free.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/free.tsx@@ -3,7 +3,7 @@ import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'import { NextPageWithLayout } from 'types'-import { useStore, useFlag } from 'hooks'+import { useStore } from 'hooks'import { get } from 'lib/common/fetch'import { API_URL, PRICING_TIER_PRODUCT_IDS, STRIPE_PRODUCT_IDS } from 'lib/constants'@@ -16,8 +16,6 @@ const BillingUpdateFree: NextPageWithLayout = () => {const router = useRouter()const projectRef = ui.selectedProject?.ref- const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')-const [products, setProducts] = useState<{ tiers: any[]; addons: any[] }>()const [subscription, setSubscription] = useState<StripeSubscription>()@@ -25,9 +23,7 @@ const BillingUpdateFree: NextPageWithLayout = () => {subscription && subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISEuseEffect(() => {- if (projectUpdateDisabled) {- router.push(`/project/${projectRef}/settings/billing/update`)- } else if (projectRef) {+ if (projectRef) {getStripeProducts()getSubscription()}diff --git a/studio/pages/project/[ref]/settings/billing/update/index.tsx b/studio/pages/project/[ref]/settings/billing/update/index.tsxindex 7a9b49601b7..edd9d950568 100644--- a/studio/pages/project/[ref]/settings/billing/update/index.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/index.tsx@@ -31,8 +31,8 @@ const BillingUpdate: NextPageWithLayout = () => {const [subscription, setSubscription] = useState<StripeSubscription>()const [selectedPlan, setSelectedPlan] = useState<any>()- const isEnterprise =- subscription && subscription.tier.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISE+ const isTeams = subscription?.tier?.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.TEAM+ const isEnterprise = subscription?.tier?.supabase_prod_id === PRICING_TIER_PRODUCT_IDS.ENTERPRISEuseEffect(() => {if (projectRef) {@@ -44,6 +44,8 @@ const BillingUpdate: NextPageWithLayout = () => {useEffect(() => {if (isEnterprise) {router.push(`/project/${projectRef}/settings/billing/update/enterprise`)+ } else if (isTeams) {+ router.push(`/project/${projectRef}/settings/billing/update/team`)}}, [subscription])diff --git a/studio/pages/project/[ref]/settings/billing/update/pro.tsx b/studio/pages/project/[ref]/settings/billing/update/pro.tsxindex fb6db5a4c29..a175d3688f1 100644--- a/studio/pages/project/[ref]/settings/billing/update/pro.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/pro.tsx@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'-import { useStore, useFlag } from 'hooks'+import { useStore } from 'hooks'import { get } from 'lib/common/fetch'import { API_URL, PRICING_TIER_PRODUCT_IDS } from 'lib/constants'@@ -21,8 +21,6 @@ const BillingUpdatePro: NextPageWithLayout = () => {const projectRef = ui.selectedProject?.refconst orgSlug = ui.selectedOrganization?.slug- const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')-const [subscription, setSubscription] = useState<StripeSubscription>()const [products, setProducts] = useState<{ tiers: any[]; addons: SubscriptionAddon[] }>()const [paymentMethods, setPaymentMethods] = useState<PaymentMethod[]>()@@ -39,9 +37,7 @@ const BillingUpdatePro: NextPageWithLayout = () => {}, [])useEffect(() => {- if (projectUpdateDisabled) {- router.push(`/project/${projectRef}/settings/billing/update`)- } else if (projectRef) {+ if (projectRef) {getStripeProducts()getSubscription()}diff --git a/studio/pages/project/[ref]/settings/billing/update/team.tsx b/studio/pages/project/[ref]/settings/billing/update/team.tsxindex 00590a7e98d..316e1bb5976 100644--- a/studio/pages/project/[ref]/settings/billing/update/team.tsx+++ b/studio/pages/project/[ref]/settings/billing/update/team.tsx@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'-import { useStore, useFlag } from 'hooks'+import { useStore } from 'hooks'import { get } from 'lib/common/fetch'import { API_URL, PRICING_TIER_PRODUCT_IDS } from 'lib/constants'@@ -21,8 +21,6 @@ const BillingUpdateTeam: NextPageWithLayout = () => {const projectRef = ui.selectedProject?.refconst orgSlug = ui.selectedOrganization?.slug- const projectUpdateDisabled = useFlag('disableProjectCreationAndUpdate')-const [subscription, setSubscription] = useState<StripeSubscription>()const [products, setProducts] = useState<{ tiers: any[]; addons: SubscriptionAddon[] }>()const [paymentMethods, setPaymentMethods] = useState<PaymentMethod[]>()@@ -39,9 +37,7 @@ const BillingUpdateTeam: NextPageWithLayout = () => {}, [])useEffect(() => {- if (projectUpdateDisabled) {- router.push(`/project/${projectRef}/settings/billing/update`)- } else if (projectRef) {+ if (projectRef) {getStripeProducts()getSubscription()}@@ -122,7 +118,6 @@ const BillingUpdateTeam: NextPageWithLayout = () => {currentSubscription={subscription}isLoadingPaymentMethods={isLoadingPaymentMethods}paymentMethods={paymentMethods || []}- onSelectBack={() => router.push(`/project/${projectRef}/settings/billing/update`)}/>)}