Skip to content

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

Chore/direct upgrade prompts to support based on flag (#39166)

Joshen Lim75212d44e152
diff --git a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx
index 56b8644e1cb..a9bb25d96aa 100644
--- a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx
+++ b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx
@@ -124,7 +124,7 @@ export const RedirectUrlList = ({
<div
className={[
'flex items-center border-overlay bg-studio text-foreground',
- 'justify-center gap-2 rounded border px-6 py-8 text-sm',
+ 'justify-center gap-2 rounded-b border px-6 py-8 text-sm',
].join(' ')}
>
<EmptyListState
diff --git a/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx b/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx
index 5e28e21bec2..2205f7f0235 100644
--- a/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx
+++ b/apps/studio/components/interfaces/Auth/SessionsAuthSettingsForm/SessionsAuthSettingsForm.tsx
@@ -270,15 +270,6 @@ export const SessionsAuthSettingsForm = () => {
>
<Card>
<CardContent>
- {promptProPlanUpgrade && (
- <div className="mb-4">
- <UpgradeToPro
- primaryText="Upgrade to Pro"
- secondaryText="Configuring user sessions requires the Pro Plan."
- />
- </div>
- )}
-
<FormField_Shadcn_
control={userSessionsForm.control}
name="SESSIONS_SINGLE_PER_USER"
@@ -352,6 +343,15 @@ export const SessionsAuthSettingsForm = () => {
)}
/>
</CardContent>
+
+ {promptProPlanUpgrade && (
+ <UpgradeToPro
+ fullWidth
+ primaryText="Configuring user sessions is only available on the Pro Plan and above"
+ secondaryText="Upgrade to the Pro plan to configure settings for user sessions"
+ />
+ )}
+
<CardFooter className="justify-end space-x-2">
{userSessionsForm.formState.isDirty && (
<Button type="default" onClick={() => userSessionsForm.reset()}>
diff --git a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx
index ca6c338b015..1dd9201fcf3 100644
--- a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx
+++ b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/CurrentPaymentMethod.tsx
@@ -67,7 +67,7 @@ const CurrentPaymentMethod = () => {
<Button type="outline" asChild>
{subscription?.payment_method_type === 'invoice' ? (
<Link
- href={`/support/new?slug=${slug}&ref=no-project&message=${encodeURIComponent('I would like to change my payment method')}&category=${SupportCategories.BILLING}`}
+ href={`/support/new?slug=${slug}&projectRef=no-project&message=${encodeURIComponent('I would like to change my payment method')}&category=${SupportCategories.BILLING}`}
>
Contact support
</Link>
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
index fd272699088..cee0f6f73c7 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
@@ -3,7 +3,6 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
import { AnimatePresence, motion } from 'framer-motion'
import { ChevronRight } from 'lucide-react'
-import Link from 'next/link'
import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
@@ -11,6 +10,7 @@ import { toast } from 'sonner'
import { useParams } from 'common'
import { MAX_WIDTH_CLASSES, PADDING_CLASSES, ScaffoldContainer } from 'components/layouts/Scaffold'
import { DocsButton } from 'components/ui/DocsButton'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import {
useDiskAttributesQuery,
useRemainingDurationForDiskAttributeUpdate,
@@ -318,15 +318,7 @@ export function DiskManagementForm() {
type="default"
visible={isPlanUpgradeRequired}
title="Compute and Disk configuration is not available on the Free Plan"
- actions={
- <Button type="default" asChild>
- <Link
- href={`/org/${org?.slug}/billing?panel=subscriptionPlan&source=diskManagementConfigure`}
- >
- Upgrade plan
- </Link>
- </Button>
- }
+ actions={<UpgradePlanButton source="diskManagementConfigure" plan="Pro" />}
description="You will need to upgrade to at least the Pro Plan to configure compute and disk"
/>
diff --git a/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx b/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
index e4b49eecc6e..92b454ebc25 100644
--- a/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
+++ b/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
@@ -3,7 +3,6 @@ import { useParams } from 'common'
import dayjs from 'dayjs'
import { ArrowDown, ArrowUp, RefreshCw, User } from 'lucide-react'
import Image from 'next/legacy/image'
-import Link from 'next/link'
import { useEffect, useState } from 'react'
import { LogDetailsPanel } from 'components/interfaces/AuditLogs'
@@ -15,6 +14,7 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { FilterPopover } from 'components/ui/FilterPopover'
import NoPermission from 'components/ui/NoPermission'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { useOrganizationRolesV2Query } from 'data/organization-members/organization-roles-query'
import {
AuditLog,
@@ -231,11 +231,9 @@ export const AuditLogs = () => {
</div>
<div className="flex items-center">
- <Button type="primary" asChild>
- <Link href={`/org/${slug}/billing?panel=subscriptionPlan&source=auditLogs`}>
- Upgrade subscription
- </Link>
- </Button>
+ <UpgradePlanButton source="auditLogs" plan="Team" type="primary">
+ Upgrade subscription
+ </UpgradePlanButton>
</div>
</div>
</Alert_Shadcn_>
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx
index ed79e6d5687..17a8c017113 100644
--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx
+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx
@@ -1,12 +1,13 @@
import Link from 'next/link'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { PricingMetric } from 'data/analytics/org-daily-stats-query'
import type { OrgSubscription } from 'data/subscriptions/types'
import type { OrgUsageResponse } from 'data/usage/org-usage-query'
import { formatCurrency } from 'lib/helpers'
import { ChevronRight } from 'lucide-react'
import { useMemo } from 'react'
-import { Button, cn, HoverCard, HoverCardContent, HoverCardTrigger } from 'ui'
+import { cn, HoverCard, HoverCardContent, HoverCardTrigger } from 'ui'
import { billingMetricUnit, formatUsage } from '../helpers'
import { Metric, USAGE_APPROACHING_THRESHOLD } from './BillingBreakdown.constants'
@@ -156,13 +157,9 @@ export const BillingMetric = ({
</div>
) : (
<div>
- <Button type="default" asChild>
- <Link
- href={`/org/${slug}/billing?panel=subscriptionPlan&source=billingBreakdownUsage${metric.anchor}`}
- >
- Upgrade
- </Link>
- </Button>
+ <UpgradePlanButton source={`billingBreakdownUsage${metric.anchor}`}>
+ Upgrade
+ </UpgradePlanButton>
</div>
)}
</div>
diff --git a/apps/studio/components/interfaces/Organization/SSO/SSOConfig.tsx b/apps/studio/components/interfaces/Organization/SSO/SSOConfig.tsx
index 3d8359288c8..7bd3b6df393 100644
--- a/apps/studio/components/interfaces/Organization/SSO/SSOConfig.tsx
+++ b/apps/studio/components/interfaces/Organization/SSO/SSOConfig.tsx
@@ -1,5 +1,4 @@
import { zodResolver } from '@hookform/resolvers/zod'
-import Link from 'next/link'
import { useEffect } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
import z from 'zod'
@@ -8,6 +7,7 @@ import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { InlineLink } from 'components/ui/InlineLink'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { useSSOConfigCreateMutation } from 'data/sso/sso-config-create-mutation'
import { useOrgSSOConfigQuery } from 'data/sso/sso-config-query'
import { useSSOConfigUpdateMutation } from 'data/sso/sso-config-update-mutation'
@@ -67,7 +67,7 @@ export type SSOConfigFormSchema = z.infer<typeof FormSchema>
export const SSOConfig = () => {
const FORM_ID = 'sso-config-form'
- const { data: organization, isLoading: isLoadingOrganization } = useSelectedOrganizationQuery()
+ const { data: organization } = useSelectedOrganizationQuery()
const plan = organization?.plan.id
const canSetupSSOConfig = ['team', 'enterprise'].includes(plan ?? '')
@@ -179,13 +179,7 @@ export const SSOConfig = () => {
</div>
<div className="flex items-center">
- <Button type="primary" asChild>
- <Link
- href={`/org/${organization?.slug}/billing?panel=subscriptionPlan&source=sso`}
- >
- Upgrade to Team
- </Link>
- </Button>
+ <UpgradePlanButton type="primary" source="sso" plan="Team" />
</div>
</div>
</Alert_Shadcn_>
diff --git a/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx b/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx
index 4254c054a91..22c0513dfc9 100644
--- a/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx
+++ b/apps/studio/components/interfaces/Organization/SecuritySettings/SecuritySettings.tsx
@@ -1,6 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import Link from 'next/link'
import { useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
@@ -12,6 +11,7 @@ import AlertError from 'components/ui/AlertError'
import { InlineLink } from 'components/ui/InlineLink'
import NoPermission from 'components/ui/NoPermission'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { useOrganizationMembersQuery } from 'data/organizations/organization-members-query'
import { useOrganizationMfaToggleMutation } from 'data/organizations/organization-mfa-mutation'
import { useOrganizationMfaQuery } from 'data/organizations/organization-mfa-query'
@@ -128,11 +128,9 @@ export const SecuritySettings = () => {
</div>
<div className="flex items-center">
- <Button type="primary" asChild>
- <Link href={`/org/${slug}/billing?panel=subscriptionPlan&source=mfa`}>
- Upgrade subscription
- </Link>
- </Button>
+ <UpgradePlanButton type="primary" source="mfa" plan="Pro">
+ Upgrade subscription
+ </UpgradePlanButton>
</div>
</div>
</Alert_Shadcn_>
diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx
index 8c420f75008..6872cf036db 100644
--- a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx
+++ b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx
@@ -10,6 +10,7 @@ import { useParams } from 'common'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import InformationBox from 'components/ui/InformationBox'
import { OrganizationProjectSelector } from 'components/ui/OrganizationProjectSelector'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { useOrganizationCreateInvitationMutation } from 'data/organization-members/organization-invitation-create-mutation'
import { useOrganizationRolesV2Query } from 'data/organization-members/organization-roles-query'
import { useOrganizationMembersQuery } from 'data/organizations/organization-members-query'
@@ -309,13 +310,7 @@ export const InviteMemberButton = () => {
</Link>
</Button>
{(currentPlan?.id === 'free' || currentPlan?.id === 'pro') && (
- <Button asChild type="default">
- <Link
- href={`/org/${slug}/billing?panel=subscriptionPlan&source=inviteMemberSSO`}
- >
- Upgrade to Team
- </Link>
- </Button>
+ <UpgradePlanButton source="inviteMemberSSO" plan="Team" />
)}
</div>
</div>
diff --git a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx
index b7b4b05a9e5..606d9df0910 100644
--- a/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx
+++ b/apps/studio/components/interfaces/Realtime/RealtimeSettings.tsx
@@ -9,7 +9,8 @@ import { useParams } from 'common'
import { ScaffoldSection } from 'components/layouts/Scaffold'
import AlertError from 'components/ui/AlertError'
import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'
-import { InlineLink } from 'components/ui/InlineLink'
+import { ToggleSpendCapButton } from 'components/ui/ToggleSpendCapButton'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
import { useMaxConnectionsQuery } from 'data/database/max-connections-query'
import { useRealtimeConfigurationUpdateMutation } from 'data/realtime/realtime-config-mutation'
@@ -61,6 +62,7 @@ export const RealtimeSettings = () => {
schema: 'realtime',
})
+ const isFreePlan = organization?.plan.id === 'free'
const isUsageBillingEnabled = organization?.usage_billing_enabled
// Check if RLS policies exist for realtime.messages table
@@ -255,21 +257,27 @@ export const RealtimeSettings = () => {
</FormControl_Shadcn_>
<FormMessage_Shadcn_ />
{isSuccessOrganization && !isUsageBillingEnabled && (
- <Admonition
- showIcon={false}
- type="default"
- title="Spend cap needs to be disabled to configure this value"
- description={
- <>
- You may adjust this setting in the{' '}
- <InlineLink
- href={`/org/${organization?.slug}/billing?panel=costControl`}
- >
- organization billing settings
- </InlineLink>
- </>
- }
- />
+ <Admonition showIcon={false} type="default">
+ <div className="flex items-center gap-x-2">
+ <div>
+ <h5 className="text-foreground mb-1">
+ Spend cap needs to be disabled to configure this value
+ </h5>
+ <p className="text-foreground-light">
+ {isFreePlan
+ ? 'Upgrade to the Pro plan first to disable spend cap'
+ : 'You may adjust this setting in the organization billing settings'}
+ </p>
+ </div>
+ <div className="flex-grow flex items-center justify-end">
+ {false ? (
+ <UpgradePlanButton source="realtimeSettings" plan="Pro" />
+ ) : (
+ <ToggleSpendCapButton />
+ )}
+ </div>
+ </div>
+ </Admonition>
)}
</FormSectionContent>
</FormSection>
diff --git a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
index c172b266acf..172f0c9966c 100644
--- a/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Addons/PITRSidePanel.tsx
@@ -7,6 +7,7 @@ import { toast } from 'sonner'
import { useParams } from 'common'
import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'
+import { UpgradePlanButton } from 'components/ui/UpgradePlanButton'
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'
@@ -271,15 +272,7 @@ const PITRSidePanel = () => {
variant="info"
className="mb-4"
title="Changing your Point-In-Time-Recovery is only available on the Pro Plan"
- actions={
- <Button asChild type="default">
- <Link
- href={`/org/${organization?.slug}/billing?panel=subscriptionPlan&source=pitrSidePanel`}
- >
- View available plans
- </Link>
- </Button>
- }
+ actions={<UpgradePlanButton source="pitrSidePanel" plan="Pro" />}
>
Upgrade your plan to change PITR for your project
</Alert>
diff --git a/apps/studio/components/interfaces/Support/Support.constants.ts b/apps/studio/components/interfaces/Support/Support.constants.ts
index 963a39e1be0..9b209304c48 100644
--- a/apps/studio/components/interfaces/Support/Support.constants.ts
+++ b/apps/studio/components/interfaces/Support/Support.constants.ts
@@ -1,6 +1,11 @@
import { SupportCategories } from '@supabase/shared-types/out/constants'
-export const CATEGORY_OPTIONS = [
+export const CATEGORY_OPTIONS: {
+ value: SupportCategories | 'Plan_upgrade'
+ label: string
+ description: string
+ query?: string
+}[] = [
{
value: SupportCategories.PROBLEM,
label: 'APIs and client libraries',
@@ -55,6 +60,13 @@ export const CATEGORY_OPTIONS = [
description: 'Issues with logging in and MFA',
query: undefined,
},
+ // [Joshen] Ideally shift this to shared-types, although not critical as API isn't validating the category
+ {
+ value: 'Plan_upgrade',
+ label: 'Plan upgrade',
+ description: 'Enquire a plan upgrade for your organization',
+ query: undefined,
+ },
]
export const SEVERITY_OPTIONS = [
diff --git a/apps/studio/components/interfaces/Support/SupportFormV2.tsx b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
index 7de9cf432ef..883f88881db 100644
--- a/apps/studio/components/interfaces/Support/SupportFormV2.tsx
+++ b/apps/studio/components/interfaces/Support/SupportFormV2.tsx
@@ -26,6 +26,7 @@ import { useDocsSearch, useParams, type DocsSearchResult as Page } from 'common'
import { CLIENT_LIBRARIES } from 'common/constants'
import CopyButton from 'components/ui/CopyButton'
import { OrganizationProjectSelector } from 'components/ui/OrganizationProjectSelector'
+import { PLAN_REQUEST_EMPTY_PLACEHOLDER } from 'components/ui/UpgradePlanButton'
import { getProjectAuthConfig } from 'data/auth/auth-config-query'
import { useSendSupportTicketMutation } from 'data/feedback/support-ticket-send'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
@@ -92,21 +93,41 @@ const createFormSchema = (showClientLibraries: boolean) => {
})
if (showClientLibraries) {
- return baseSchema.refine(
+ return baseSchema
+ .refine(
+ (data) => {
+ return !(data.category === 'Problem' && data.library === '')
+ },
+ {
+ message: "Please select the library that you're facing issues with",
+ path: ['library'],
+ }
+ )
+ .refine(
+ (data) => {
+ return !data.message.includes(PLAN_REQUEST_EMPTY_PLACEHOLDER)
+ },
+ {
+ message: `Please let us know which plan you'd like to upgrade to for your organization`,
+ path: ['message'],
+ }
+ )
+ }
+
+ // When showClientLibraries is false, make library optional and remove the refine validation
+ return baseSchema
+ .extend({
+ library: z.string().optional(),
+ })
+ .refine(
(data) => {
- return !(data.category === 'Problem' && data.library === '')
+ return !data.message.includes(PLAN_REQUEST_EMPTY_PLACEHOLDER)
},
{
- message: "Please select the library that you're facing issues with",
- path: ['library'],
+ message: `Please let us know which plan you'd like to upgrade to for your organization`,
+ path: ['message'],
}
)
- }
-
- // When showClientLibraries is false, make library optional and remove the refine validation
- return baseSchema.extend({
- library: z.string().optional(),
- })
}
const defaultValues = {
@@ -128,8 +149,6 @@ interface SupportFormV2Props {
setSentCategory: (value: string) => void
}
-// [Joshen] Just naming it as V2 for now for PR review purposes so its easier to view
-// This is a rewrite of the old SupportForm to use the new form components
export const SupportFormV2 = ({
onProjectSelected: setSelectedProject,
onOrganizationSelected: setSelectedOrganization,
@@ -161,7 +180,10 @@ export const SupportFormV2 = ({
option.value === SupportCategories.SALES_ENQUIRY
) {
return isBillingEnabled
+ } else if (option.value === 'Plan_upgrade') {
+ return !isBillingEnabled
}
+
return true
})
}, [isBillingEnabled])
@@ -323,7 +345,7 @@ export const SupportFormV2 = ({
if (isSuccessOrganizations) {
if (organizations.length === 0) {
form.setValue('organizationSlug', 'no-org')
- } else if (urlRef) {
+ } else if (urlRef && urlRef !== 'no-project') {
// Check validity of project via project details
const selectedProject = await getProjectDetail({ ref: urlRef })
if (!!selectedProject) {
@@ -750,7 +772,7 @@ export const SupportFormV2 = ({
{library && library.length > 0 && <LibrarySuggestions library={library} />}
- {category !== 'Login_issues' && (
+ {category !== 'Login_issues' && category !== 'Plan_upgrade' && (
<FormField_Shadcn_
name="affectedServices"
control={form.control}
diff --git a/apps/studio/components/ui/ToggleSpendCapButton.tsx b/apps/studio/components/ui/ToggleSpendCapButton.tsx
new file mode 100644
index 00000000000..30fe58b0ab2
--- /dev/null
+++ b/apps/studio/components/ui/ToggleSpendCapButton.tsx
@@ -0,0 +1,37 @@
+import Link from 'next/link'
+import { PropsWithChildren } from 'react'
+
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { Button } from 'ui'
+
+interface ToggleSpendCapButtonProps {
+ action?: 'disable' | 'enable'
+ type?: 'default' | 'primary'
+}
+
+export const ToggleSpendCapButton = ({
+ action = 'disable',
+ type = 'default',
+ children,
+}: PropsWithChildren<ToggleSpendCapButtonProps>) => {
+ const { data: organization } = useSelectedOrganizationQuery()
+ const slug = organization?.slug ?? '_'
+
+ const { billingAll } = useIsFeatureEnabled(['billing:all'])
+
+ const subject = `Enquiry to ${action} spend cap for organization`
+ const message = `Name: ${organization?.name}\nSlug: ${organization?.slug}`
+
+ const href = billingAll
+ ? `/org/${slug}/billing?panel=costControl`
+ : `/support/new?slug=${slug}&projectRef=no-project&category=Plan_upgrade&subject=${subject}&message=${encodeURIComponent(message)}`
+
+ return (
+ <Button type={type} asChild>
+ <Link href={href} className="capitalize">
+ {children || `${action} spend cap`}
+ </Link>
+ </Button>
+ )
+}
diff --git a/apps/studio/components/ui/UpgradePlanButton.tsx b/apps/studio/components/ui/UpgradePlanButton.tsx
new file mode 100644
index 00000000000..8c9db51c95c
--- /dev/null
+++ b/apps/studio/components/ui/UpgradePlanButton.tsx
@@ -0,0 +1,45 @@
+import Link from 'next/link'
+import { PropsWithChildren } from 'react'
+
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { Button } from 'ui'
+
+export const PLAN_REQUEST_EMPTY_PLACEHOLDER =
+ '<Specify which plan to upgrade to: Pro | Team | Enterprise>'
+
+interface UpgradePlanButtonProps {
+ source?: string
+ type?: 'default' | 'primary'
+ plan?: 'Pro' | 'Team' | 'Enterprise'
+ href?: string // [Joshen] As an override if needed (Used in UpgradeToPro)
+ disabled?: boolean
+}
+
+export const UpgradePlanButton = ({
+ source,
+ type = 'default',
+ plan,
+ href: propsHref,
+ disabled,
+ children,
+}: PropsWithChildren<UpgradePlanButtonProps>) => {
+ const { data: organization } = useSelectedOrganizationQuery()
+ const slug = organization?.slug ?? '_'
+
+ const { billingAll } = useIsFeatureEnabled(['billing:all'])
+
+ const subject = `Enquiry to upgrade ${!!plan ? `to ${plan} ` : ''}plan for organization`
+ const message = `Name: ${organization?.name}\nSlug: ${organization?.slug}\nRequested plan: ${plan ?? PLAN_REQUEST_EMPTY_PLACEHOLDER}`
+
+ const href = billingAll
+ ? propsHref ??
+ `/org/${slug}/billing?panel=subscriptionPlan${!!source ? `&source=${source}` : ''}`
+ : `/support/new?slug=${slug}&projectRef=no-project&category=Plan_upgrade&subject=${subject}&message=${encodeURIComponent(message)}`
+
+ return (
+ <Button asChild type={type} disabled={disabled}>
+ <Link href={href}>{children || `Upgrade to ${plan}`}</Link>
+ </Button>
+ )
+}
diff --git a/apps/studio/components/ui/UpgradeToPro.tsx b/apps/studio/components/ui/UpgradeToPro.tsx
index 7cf9aa39523..dd4e1f07dbc 100644
--- a/apps/studio/components/ui/UpgradeToPro.tsx
+++ b/apps/studio/components/ui/UpgradeToPro.tsx
@@ -1,13 +1,13 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import Link from 'next/link'
import { ReactNode } from 'react'
import { useFlag } from 'common'
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-import { Button, cn } from 'ui'
+import { cn } from 'ui'
import { ButtonTooltip } from './ButtonTooltip'
+import { UpgradePlanButton } from './UpgradePlanButton'
interface UpgradeToProProps {
icon?: ReactNode
@@ -74,23 +74,21 @@ const UpgradeToPro = ({
{buttonText || (plan === 'free' ? 'Upgrade to Pro' : 'Enable add on')}
</ButtonTooltip>
) : (
- <Button
- asChild
+ <UpgradePlanButton
type="primary"
- disabled={!canUpdateSubscription || projectUpdateDisabled || disabled}
+ plan="Pro"
+ source={source}
+ disabled={disabled}
+ href={
+ plan === 'free'
+ ? `/org/${organization?.slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
+ : addon == null
+ ? `/org/${organization?.slug ?? '_'}/billing?panel=costControl&source=${source}`
+ : `/project/${project?.ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
+ }
>
- <Link
- href={
- plan === 'free'
- ? `/org/${organization?.slug ?? '_'}/billing?panel=subscriptionPlan&source=${source}`
- : addon == null
- ? `/org/${organization?.slug ?? '_'}/billing?panel=costControl&source=${source}`
- : `/project/${project?.ref ?? '_'}/settings/addons?panel=${addon}&source=${source}`
- }
- >
- {buttonText || (plan === 'free' ? 'Upgrade to Pro' : 'Enable add on')}
- </Link>
- </Button>
+ {buttonText || (plan === 'free' ? 'Upgrade to Pro' : 'Enable add on')}
+ </UpgradePlanButton>
)}
</div>
</div>