The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/branch feature preview (#37135)
Saxon Fletcher16ee99ff9b47
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/Branching2Preview.tsx b/apps/studio/components/interfaces/App/FeaturePreview/Branching2Preview.tsxnew file mode 100644index 00000000000..88911c2d4b0--- /dev/null+++ b/apps/studio/components/interfaces/App/FeaturePreview/Branching2Preview.tsx@@ -0,0 +1,64 @@+import Image from 'next/image'++import { InlineLink } from 'components/ui/InlineLink'+import { BASE_PATH } from 'lib/constants'++export const Branching2Preview = () => {+ return (+ <div>+ <Image+ src={`${BASE_PATH}/img/previews/branching-preview.png`}+ width={1296}+ height={900}+ alt="api-docs-side-panel-preview"+ className="rounded border mb-4"+ />+ <p className="text-sm text-foreground-light mb-4">+ Branching 2.0 introduces a new workflow for managing database branches without having to use+ Git. Create branches, review changes and merge back into production all through the+ dashboard. Read the below limitations and our{' '}+ <InlineLink href="https://supabase.com/docs/guides/platform/branching">+ branching documentation+ </InlineLink>{' '}+ before opting in.+ </p>+ <div className="my-6">+ <p className="text-sm text-foreground mb-2 font-medium">Limitations:</p>+ <ul className="list-disc pl-6 text-sm text-foreground-light space-y-1">+ <li>Custom roles created through the dashboard are not captured on branch creation.</li>+ <li>+ Only <code>public</code> schema changes are supported right now.+ </li>+ <li>Extensions are not included in the diff process</li>+ <li>+ Branches can only be merged to <code>main</code>; merging between preview branches is+ not supported.+ </li>+ <li>+ If your branch is out of date, you can pull in latest changes from <code>main</code>,+ but keep in mind that all functions will be overwritten.+ </li>+ <li>+ Deleting functions must be done manually on <code>main</code>.+ </li>+ <li>Migration conflicts must be manually resolved on the preview branch.</li>+ <li>+ If you have run migrations on <code>main</code>, new branches will be created from+ existing migrations instead of a full schema dump.+ </li>+ </ul>+ </div>++ <div className="space-y-2 !mt-4">+ <p className="text-sm">Enabling this preview will:</p>+ <ul className="list-disc pl-6 text-sm text-foreground-light space-y-1">+ <li>Enable the new Branching 2.0 workflow for your project.</li>+ <li>+ Allow you to create, manage, and merge database branches with improved UI and features.+ </li>+ <li>Access new merge request and deployment management tools.</li>+ </ul>+ </div>+ </div>+ )+}diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsxindex 2db32d6c747..5c64c574707 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx@@ -1,6 +1,13 @@import { LOCAL_STORAGE_KEYS } from 'common'export const FEATURE_PREVIEWS = [+ {+ key: LOCAL_STORAGE_KEYS.UI_PREVIEW_BRANCHING_2_0,+ name: 'Branching 2.0',+ discussionsUrl: 'https://github.com/orgs/supabase/discussions/branching-2-0',+ isNew: true,+ isPlatformOnly: true,+ },{key: LOCAL_STORAGE_KEYS.UI_PREVIEW_REALTIME_SETTINGS,name: 'Realtime settings',diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsxindex 01ed929dc86..c71a9beda01 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx@@ -84,3 +84,8 @@ export const useIsRealtimeSettingsEnabled = () => {const { flags } = useFeaturePreviewContext()return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_REALTIME_SETTINGS]}++export const useIsBranching2Enabled = () => {+ const { flags } = useFeaturePreviewContext()+ return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_BRANCHING_2_0]+}diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsxindex 477392fa4f6..906853d35f1 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx@@ -5,7 +5,7 @@ import { ReactNode } from 'react'import { LOCAL_STORAGE_KEYS, useParams } from 'common'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { useIsRealtimeSettingsFFEnabled } from 'hooks/ui/useFlag'+import { useIsRealtimeSettingsFFEnabled, useFlag } from 'hooks/ui/useFlag'import { IS_PLATFORM } from 'lib/constants'import { useAppStateSnapshot } from 'state/app-state'import { Badge, Button, Modal, ScrollArea, cn } from 'ui'@@ -15,10 +15,12 @@ import { FEATURE_PREVIEWS } from './FeaturePreview.constants'import { useFeaturePreviewContext } from './FeaturePreviewContext'import { InlineEditorPreview } from './InlineEditorPreview'import { RealtimeSettingsPreview } from './RealtimeSettingsPreview'+import { Branching2Preview } from './Branching2Preview'const FEATURE_PREVIEW_KEY_TO_CONTENT: {[key: string]: ReactNode} = {+ [LOCAL_STORAGE_KEYS.UI_PREVIEW_BRANCHING_2_0]: <Branching2Preview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_REALTIME_SETTINGS]: <RealtimeSettingsPreview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR]: <InlineEditorPreview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL]: <APISidePanelPreview />,@@ -31,14 +33,16 @@ const FeaturePreviewModal = () => {const org = useSelectedOrganization()const featurePreviewContext = useFeaturePreviewContext()const { mutate: sendEvent } = useSendEventMutation()-const isRealtimeSettingsEnabled = useIsRealtimeSettingsFFEnabled()+ const gitlessBranchingEnabled = useFlag('gitlessBranching')// [Joshen] Use this if we want to feature flag previewsfunction isReleasedToPublic(feature: (typeof FEATURE_PREVIEWS)[number]) {switch (feature.key) {case 'supabase-ui-realtime-settings':return isRealtimeSettingsEnabled+ case 'supabase-ui-branching-2-0':+ return gitlessBranchingEnableddefault:return true}diff --git a/apps/studio/components/interfaces/BranchManagement/BranchSelector.tsx b/apps/studio/components/interfaces/BranchManagement/BranchSelector.tsxindex 51c2c5528e1..9714d8e5e06 100644--- a/apps/studio/components/interfaces/BranchManagement/BranchSelector.tsx+++ b/apps/studio/components/interfaces/BranchManagement/BranchSelector.tsx@@ -56,9 +56,11 @@ export const BranchSelector = ({content: {side: 'bottom',text:- availableBranches.length === 0- ? 'All branches currently have merge requests'- : undefined,+ branches.length === 0+ ? 'Create a branch first to start a merge request'+ : availableBranches.length === 0+ ? 'All branches currently have merge requests'+ : undefined,},}}>diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsxindex fca9784bed0..7f3074d1269 100644--- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx@@ -10,8 +10,10 @@ import { toast } from 'sonner'import * as z from 'zod'import { useParams } from 'common'+import { useIsBranching2Enabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'import { BranchingPITRNotice } from 'components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice'import AlertError from 'components/ui/AlertError'+import { ButtonTooltip } from 'components/ui/ButtonTooltip'import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import UpgradeToPro from 'components/ui/UpgradeToPro'import { useBranchCreateMutation } from 'data/branches/branch-create-mutation'@@ -22,7 +24,6 @@ import { projectKeys } from 'data/projects/keys'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, IS_PLATFORM } from 'lib/constants'import { useAppStateSnapshot } from 'state/app-state'import {@@ -50,7 +51,7 @@ export const CreateBranchModal = () => {const queryClient = useQueryClient()const projectDetails = useSelectedProject()const selectedOrg = useSelectedOrganization()- const gitlessBranching = useFlag('gitlessBranching')+ const gitlessBranching = useIsBranching2Enabled()const { showCreateBranchModal, setShowCreateBranchModal } = useAppStateSnapshot()const organization = useSelectedOrganization()@@ -367,7 +368,7 @@ export const CreateBranchModal = () => {>Cancel</Button>- <Button+ <ButtonTooltipform={formId}disabled={!isSuccessConnections ||@@ -380,9 +381,18 @@ export const CreateBranchModal = () => {loading={isCreating}type="primary"htmlType="submit"+ tooltip={{+ content: {+ side: 'bottom',+ text:+ !gitlessBranching && !githubConnection+ ? 'Set up a GitHub connection first to create branches'+ : undefined,+ },+ }}>Create branch- </Button>+ </ButtonTooltip></DialogFooter></form></Form_Shadcn_>diff --git a/apps/studio/components/interfaces/BranchManagement/EditBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/EditBranchModal.tsxindex 7161c91db31..bed088dd528 100644--- a/apps/studio/components/interfaces/BranchManagement/EditBranchModal.tsx+++ b/apps/studio/components/interfaces/BranchManagement/EditBranchModal.tsx@@ -16,7 +16,7 @@ import { useCheckGithubBranchValidity } from 'data/integrations/github-branch-chimport { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'import { useSelectedProject } from 'hooks/misc/useSelectedProject'-import { useFlag } from 'hooks/ui/useFlag'+import { useIsBranching2Enabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'import { BASE_PATH } from 'lib/constants'import { useRouter } from 'next/router'import {@@ -50,7 +50,7 @@ export const EditBranchModal = ({ branch, visible, onClose }: EditBranchModalProconst router = useRouter()const projectDetails = useSelectedProject()const selectedOrg = useSelectedOrganization()- const gitlessBranching = useFlag('gitlessBranching')+ const gitlessBranching = useIsBranching2Enabled()const [isGitBranchValid, setIsGitBranchValid] = useState(false)diff --git a/apps/studio/components/interfaces/BranchManagement/Overview.tsx b/apps/studio/components/interfaces/BranchManagement/Overview.tsxindex e631c4d394e..c4c2be7670c 100644--- a/apps/studio/components/interfaces/BranchManagement/Overview.tsx+++ b/apps/studio/components/interfaces/BranchManagement/Overview.tsx@@ -23,7 +23,7 @@ import { useBranchUpdateMutation } from 'data/branches/branch-update-mutation'import type { Branch } from 'data/branches/branches-query'import { branchKeys } from 'data/branches/keys'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'-import { useFlag } from 'hooks/ui/useFlag'+import { useIsBranching2Enabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'import {Button,DropdownMenu,@@ -163,7 +163,7 @@ const PreviewBranchActions = ({onSelectDeleteBranch: () => voidgenerateCreatePullRequestURL: (branchName?: string) => string}) => {- const gitlessBranching = useFlag('gitlessBranching')+ const gitlessBranching = useIsBranching2Enabled()const queryClient = useQueryClient()const projectRef = branch.parent_project_ref ?? branch.project_refdiff --git a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx b/apps/studio/pages/project/[ref]/branches/merge-requests.tsxindex 7aed9e003b4..fa7ae63947d 100644--- a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx+++ b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx@@ -25,7 +25,7 @@ import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'import { useSelectedProject } from 'hooks/misc/useSelectedProject'-import { useFlag } from 'hooks/ui/useFlag'+import { useIsBranching2Enabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'import type { NextPageWithLayout } from 'types'import {Button,@@ -42,7 +42,7 @@ const MergeRequestsPage: NextPageWithLayout = () => {const { ref } = useParams()const project = useSelectedProject()const selectedOrg = useSelectedOrganization()- const gitlessBranching = useFlag('gitlessBranching')+ const gitlessBranching = useIsBranching2Enabled()const isBranch = project?.parent_project_ref !== undefinedconst projectRef =@@ -282,7 +282,7 @@ const MergeRequestsPageWrapper = ({ children }: PropsWithChildren<{}>) => {const router = useRouter()const { ref } = useParams()const project = useSelectedProject()- const gitlessBranching = useFlag('gitlessBranching')+ const gitlessBranching = useIsBranching2Enabled()const isBranch = project?.parent_project_ref !== undefinedconst projectRef =diff --git a/apps/studio/pages/project/[ref]/merge.tsx b/apps/studio/pages/project/[ref]/merge.tsxindex 2f8d10228cf..9cd7be10928 100644--- a/apps/studio/pages/project/[ref]/merge.tsx+++ b/apps/studio/pages/project/[ref]/merge.tsx@@ -1,13 +1,5 @@import dayjs from 'dayjs'-import {- AlertTriangle,- ExternalLink,- GitBranchIcon,- GitMerge,- MoreVertical,- Shield,- X,-} from 'lucide-react'+import { AlertTriangle, GitBranchIcon, GitMerge, MoreVertical, Shield, X } from 'lucide-react'import Link from 'next/link'import { useRouter } from 'next/router'import { useCallback, useEffect, useMemo, useState } from 'react'@@ -33,7 +25,6 @@ import { useBranchesQuery } from 'data/branches/branches-query'import { useBranchMergeDiff } from 'hooks/branches/useBranchMergeDiff'import { useWorkflowManagement } from 'hooks/branches/useWorkflowManagement'import { useProjectByRef, useSelectedProject } from 'hooks/misc/useSelectedProject'-import { useFlag } from 'hooks/ui/useFlag'import type { NextPageWithLayout } from 'types'import {Badge,@@ -53,8 +44,6 @@ const MergePage: NextPageWithLayout = () => {const { ref } = useParams()const project = useSelectedProject()- const gitlessBranching = useFlag('gitlessBranching')-const [isSubmitting, setIsSubmitting] = useState(false)const [workflowFinalStatus, setWorkflowFinalStatus] = useState<string | null>(null)const [showConfirmDialog, setShowConfirmDialog] = useState(false)@@ -314,33 +303,6 @@ const MergePage: NextPageWithLayout = () => {setWorkflowFinalStatus(null)}, [currentWorkflowRunId])- if (!gitlessBranching) {- return (- <PageLayout>- <ScaffoldContainer size="full">- <div className="flex items-center flex-col justify-center w-full py-16">- <ProductEmptyState title="Branch Merge - Coming Soon">- <p className="text-sm text-foreground-light">- The branch merge feature is currently in development and will be available soon.- </p>- <div className="flex items-center space-x-2 !mt-4">- <Button type="default" icon={<ExternalLink strokeWidth={1.5} />} asChild>- <a- target="_blank"- rel="noreferrer"- href="https://supabase.com/docs/guides/platform/branching"- >- View the docs- </a>- </Button>- </div>- </ProductEmptyState>- </div>- </ScaffoldContainer>- </PageLayout>- )- }-// If not on a preview branch or branch info unavailable, show noticeif (!isBranch || !currentBranch) {return (@@ -349,7 +311,7 @@ const MergePage: NextPageWithLayout = () => {<div className="flex items-center flex-col justify-center w-full py-16"><ProductEmptyState title="Merge Request"><p className="text-sm text-foreground-light">- This page is only available for preview branches.+ You can only review changes when on a preview branch</p></ProductEmptyState></div>diff --git a/apps/studio/public/img/previews/branching-preview.png b/apps/studio/public/img/previews/branching-preview.pngnew file mode 100644index 00000000000..91b5435f111Binary files /dev/null and b/apps/studio/public/img/previews/branching-preview.png differdiff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.tsindex dda4acaa245..3a8045b300d 100644--- a/packages/common/constants/local-storage.ts+++ b/packages/common/constants/local-storage.ts@@ -12,6 +12,7 @@ export const LOCAL_STORAGE_KEYS = {UI_PREVIEW_INLINE_EDITOR: 'supabase-ui-preview-inline-editor',UI_ONBOARDING_NEW_PAGE_SHOWN: 'supabase-ui-onboarding-new-page-shown',UI_PREVIEW_REALTIME_SETTINGS: 'supabase-ui-realtime-settings',+ UI_PREVIEW_BRANCHING_2_0: 'supabase-ui-branching-2-0',NEW_LAYOUT_NOTICE_ACKNOWLEDGED: 'new-layout-notice-acknowledge',TABS_INTERFACE_ACKNOWLEDGED: 'tabs-interface-acknowledge',@@ -107,6 +108,7 @@ const LOCAL_STORAGE_KEYS_ALLOWLIST = [LOCAL_STORAGE_KEYS.BLOG_VIEW,LOCAL_STORAGE_KEYS.AI_ASSISTANT_MCP_OPT_IN,LOCAL_STORAGE_KEYS.UI_PREVIEW_REALTIME_SETTINGS,+ LOCAL_STORAGE_KEYS.UI_PREVIEW_BRANCHING_2_0,]export function clearLocalStorage() {