Skip to content

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

block branch free plan (#36849)

Saxon Fletcherad22fa3a9661
diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
index 4d5c1f5dc30..276956b66e4 100644
--- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx
@@ -1,7 +1,7 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { useQueryClient } from '@tanstack/react-query'
import { useParams } from 'common'
-import { DollarSign, Github, GitMerge, Loader2 } from 'lucide-react'
+import { DollarSign, Github, GitMerge, Loader2, Merge } from 'lucide-react'
import Image from 'next/image'
import Link from 'next/link'
import { useEffect } from 'react'
@@ -12,6 +12,7 @@ import * as z from 'zod'
import { BranchingPITRNotice } from 'components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice'
import AlertError from 'components/ui/AlertError'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+import UpgradeToPro from 'components/ui/UpgradeToPro'
import { useBranchCreateMutation } from 'data/branches/branch-create-mutation'
import { useBranchesQuery } from 'data/branches/branches-query'
import { useCheckGithubBranchValidity } from 'data/integrations/github-branch-check-query'
@@ -21,7 +22,7 @@ import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { useFlag } from 'hooks/ui/useFlag'
-import { BASE_PATH } from 'lib/constants'
+import { BASE_PATH, IS_PLATFORM } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
import {
Badge,
@@ -35,7 +36,6 @@ import {
DialogTitle,
FormControl_Shadcn_,
FormField_Shadcn_,
- FormMessage_Shadcn_,
Form_Shadcn_,
Input_Shadcn_,
Label_Shadcn_ as Label,
@@ -53,6 +53,10 @@ export const CreateBranchModal = () => {
const gitlessBranching = useFlag('gitlessBranching')
const { showCreateBranchModal, setShowCreateBranchModal } = useAppStateSnapshot()
+ const organization = useSelectedOrganization()
+ const isProPlanAndUp = organization?.plan?.id !== 'free'
+ const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp
+
const isBranch = projectDetails?.parent_project_ref !== undefined
const projectRef =
projectDetails !== undefined ? (isBranch ? projectDetails.parent_project_ref : ref) : undefined
@@ -166,14 +170,36 @@ export const CreateBranchModal = () => {
return (
<Dialog open={showCreateBranchModal} onOpenChange={(open) => setShowCreateBranchModal(open)}>
- <DialogContent size="large" hideClose>
+ <DialogContent
+ size="large"
+ hideClose
+ onOpenAutoFocus={(e) => {
+ if (promptProPlanUpgrade) {
+ e.preventDefault()
+ }
+ }}
+ >
<DialogHeader padding="small">
<DialogTitle>Create a new preview branch</DialogTitle>
</DialogHeader>
<DialogSectionSeparator />
+
<Form_Shadcn_ {...form}>
<form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
- <DialogSection padding="medium" className="space-y-4">
+ {promptProPlanUpgrade && (
+ <>
+ <UpgradeToPro
+ primaryText="Upgrade to unlock branching"
+ secondaryText="Create and test schema changes, functions, and more in a separate, temporary instance without affecting production"
+ source="create-branch"
+ />
+ <DialogSectionSeparator />
+ </>
+ )}
+ <DialogSection
+ padding="medium"
+ className={cn('space-y-4', promptProPlanUpgrade && 'opacity-25 pointer-events-none')}
+ >
<FormField_Shadcn_
control={form.control}
name="branchName"
@@ -186,7 +212,6 @@ export const CreateBranchModal = () => {
autoComplete="off"
/>
</FormControl_Shadcn_>
- <FormMessage_Shadcn_ />
</FormItemLayout>
)}
/>
@@ -274,7 +299,13 @@ export const CreateBranchModal = () => {
<DialogSectionSeparator />
- <DialogSection padding="medium" className="flex flex-col gap-4">
+ <DialogSection
+ padding="medium"
+ className={cn(
+ 'flex flex-col gap-4',
+ promptProPlanUpgrade && 'opacity-25 pointer-events-none'
+ )}
+ >
{githubConnection && (
<div className="flex flex-row gap-4">
<div>
@@ -342,7 +373,8 @@ export const CreateBranchModal = () => {
isCreating ||
!canSubmit ||
isChecking ||
- (!gitlessBranching && !githubConnection)
+ (!gitlessBranching && !githubConnection) ||
+ promptProPlanUpgrade
}
loading={isCreating}
type="primary"
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
index 23d30c995a4..3a7483e7f28 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
@@ -9,10 +9,12 @@ import {
ScaffoldSectionDetail,
} from 'components/layouts/Scaffold'
import NoPermission from 'components/ui/NoPermission'
+import UpgradeToPro from 'components/ui/UpgradeToPro'
import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
-import { BASE_PATH } from 'lib/constants'
+import { BASE_PATH, IS_PLATFORM } from 'lib/constants'
+import { cn } from 'ui'
import GitHubIntegrationConnectionForm from './GitHubIntegrationConnectionForm'
const IntegrationImageHandler = ({ title }: { title: 'vercel' | 'github' }) => {
@@ -34,6 +36,10 @@ const GitHubSection = () => {
'integrations.github_connections'
)
+ const organization = useSelectedOrganization()
+ const isProPlanAndUp = organization?.plan?.id !== 'free'
+ const promptProPlanUpgrade = IS_PLATFORM && !isProPlanAndUp
+
const { data: connections } = useGitHubConnectionsQuery(
{ organizationId: selectedOrganization?.id },
{ enabled: !!projectRef && !!selectedOrganization?.id }
@@ -78,7 +84,18 @@ const GitHubSection = () => {
branch, keep your production branch in sync, and automatically create preview
branches for every pull request.
</p>
- <GitHubIntegrationConnectionForm connection={existingConnection} />
+ {promptProPlanUpgrade && (
+ <div className="mb-6">
+ <UpgradeToPro
+ primaryText="Upgrade to unlock GitHub integration"
+ secondaryText="Connect your GitHub repository to automatically sync preview branches and deploy changes."
+ source="github-integration"
+ />
+ </div>
+ )}
+ <div className={cn(promptProPlanUpgrade && 'opacity-25 pointer-events-none')}>
+ <GitHubIntegrationConnectionForm connection={existingConnection} />
+ </div>
</div>
</div>
</ScaffoldSectionContent>
diff --git a/apps/studio/components/ui/UpgradeToPro.tsx b/apps/studio/components/ui/UpgradeToPro.tsx
index a1adc8d103b..b9c3ddf9ba2 100644
--- a/apps/studio/components/ui/UpgradeToPro.tsx
+++ b/apps/studio/components/ui/UpgradeToPro.tsx
@@ -47,8 +47,8 @@ const UpgradeToPro = ({
>
<div className="flex gap-x-3">
{icon && <div className="mt-1">{icon}</div>}
- <div className="flex flex-col md:flex-row w-full md:items-center justify-between gap-4 md:gap-x-8 xl:gap-x-32">
- <div className="space-y-1">
+ <div className="flex flex-col md:flex-row w-full md:items-center justify-between gap-4 md:gap-x-8">
+ <div className="space-y-1 flex-1 max-w-2xl">
<p className="text-sm">{primaryText}</p>
<div>
<p className="text-sm text-foreground-light">{secondaryText}</p>