Skip to content

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

Joshenlim/fe 4512 make GitHub connection setup obvious on empty branching page (#51393)

Joshen Lim18080d88f7eb
diff --git a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
index b426fb729e6..4e9fee06a89 100644
--- a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx
@@ -4,7 +4,6 @@ import { PageType, useRegisterCommands, useRegisterPage, useSetPage } from 'ui-p
import { COMMAND_MENU_SECTIONS } from '../App/CommandMenu/CommandMenu.utils'
import { orderCommandSectionsByPriority } from '../App/CommandMenu/ordering'
-import { BRANCHING_GITHUB_DISCUSSION_LINK } from './BranchManagement.constants'
import { useBranchesQuery } from '@/data/branches/branches-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
@@ -107,12 +106,4 @@ export function useBranchCommands() {
],
{ enabled: !!selectedProject }
)
-
- useRegisterCommands(COMMAND_MENU_SECTIONS.NAVIGATE, [
- {
- id: 'nav-branch-feedback',
- name: 'Branching feedback',
- route: BRANCHING_GITHUB_DISCUSSION_LINK,
- },
- ])
}
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchManagement.constants.ts b/apps/studio/components/interfaces/BranchManagement/BranchManagement.constants.ts
deleted file mode 100644
index d52b0fd0dc1..00000000000
--- a/apps/studio/components/interfaces/BranchManagement/BranchManagement.constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const BRANCHING_GITHUB_DISCUSSION_LINK = 'https://github.com/orgs/supabase/discussions/18937'
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchingEmptyState.tsx b/apps/studio/components/interfaces/BranchManagement/BranchingEmptyState.tsx
new file mode 100644
index 00000000000..985a927b08c
--- /dev/null
+++ b/apps/studio/components/interfaces/BranchManagement/BranchingEmptyState.tsx
@@ -0,0 +1,90 @@
+import { useParams } from 'common'
+import { GitBranch } from 'lucide-react'
+import Link from 'next/link'
+import { Badge, Button, Card, CardContent, CardDescription, CardHeader, CardTitle } from 'ui'
+
+import { IntegrationSectionIcon } from '../Settings/Integrations/IntegrationsSettings'
+import { CreateBranchButton } from './CreateBranchButton'
+import { DocsButton } from '@/components/ui/DocsButton'
+import { DOCS_URL } from '@/lib/constants'
+
+export const BranchingEmptyState = ({
+ isGithubConnected = false,
+}: {
+ isGithubConnected?: boolean
+}) => {
+ const { ref } = useParams()
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>Get started with branching</CardTitle>
+ <CardDescription>
+ Create isolated environments to test changes before merging to production
+ </CardDescription>
+ </CardHeader>
+
+ <CardContent className="p-0 grid grid-cols-1 lg:grid-cols-2 divide-y lg:divide-y-0 lg:divide-x items-stretch">
+ <div className="p-8">
+ <div className="flex items-start gap-x-4">
+ <div className="shrink-0 text-foreground-light">
+ <Card className="flex h-10 w-10 shrink-0 items-center justify-center p-0">
+ <GitBranch size={16} />
+ </Card>
+ </div>
+ <div className="text-sm">
+ <p className="space-x-2">Create a preview branch</p>
+ <p className="text-foreground-light text-balance mt-1 mb-4">
+ Make schema or Edge Function changes on a clone of your project, then merge them
+ back when ready.
+ </p>
+ <div className="flex items-center gap-x-2">
+ <CreateBranchButton />
+ <DocsButton
+ label="Learn more"
+ topic="Branching via the dashboard"
+ href={`${DOCS_URL}/deployment/branching/dashboard`}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div className="p-8">
+ <div className="flex items-start gap-x-4">
+ <IntegrationSectionIcon title="github" className=" h-10 w-10" />
+ <div className="text-sm">
+ <p className="space-x-2">
+ <span>Connect with GitHub</span>
+ {isGithubConnected ? (
+ <Badge variant="success" className="-translate-y-px">
+ Connected
+ </Badge>
+ ) : (
+ <Badge variant="default" className="-translate-y-px">
+ Optional
+ </Badge>
+ )}
+ </p>
+ <p className="text-foreground-light text-balance mt-1 mb-4">
+ Automatically create a preview branch for each pull request and apply your
+ migrations on every commit.
+ </p>
+ <div className="flex items-center gap-x-2">
+ {!isGithubConnected && (
+ <Button asChild>
+ <Link href={`/project/${ref}/settings/integrations`}>Connect GitHub</Link>
+ </Button>
+ )}
+ <DocsButton
+ label="Learn more"
+ topic="Branching GitHub integration"
+ href={`${DOCS_URL}/deployment/branching/github-integration`}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+ )
+}
diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchButton.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchButton.tsx
new file mode 100644
index 00000000000..d63ecf9ad18
--- /dev/null
+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchButton.tsx
@@ -0,0 +1,32 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
+
+import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
+import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { useAppStateSnapshot } from '@/state/app-state'
+
+export const CreateBranchButton = () => {
+ const snap = useAppStateSnapshot()
+ const { can: canCreateBranches } = useAsyncCheckPermissions(
+ PermissionAction.CREATE,
+ 'preview_branches',
+ { resource: { is_default: false } }
+ )
+
+ return (
+ <ButtonTooltip
+ variant="primary"
+ disabled={!canCreateBranches}
+ onClick={() => snap.setShowCreateBranchModal(true)}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: !canCreateBranches
+ ? 'You need additional permissions to create branches'
+ : undefined,
+ },
+ }}
+ >
+ Create branch
+ </ButtonTooltip>
+ )
+}
diff --git a/apps/studio/components/interfaces/Functions/FunctionsEmptyState.tsx b/apps/studio/components/interfaces/Functions/FunctionsEmptyState.tsx
index b7d66890bcf..5ed42035782 100644
--- a/apps/studio/components/interfaces/Functions/FunctionsEmptyState.tsx
+++ b/apps/studio/components/interfaces/Functions/FunctionsEmptyState.tsx
@@ -49,7 +49,7 @@ export const FunctionsEmptyState = () => {
<CardHeader>
<CardTitle>{emptyStateTitle}</CardTitle>
</CardHeader>
- <CardContent className="p-0 grid grid-cols-[repeat(auto-fit,minmax(240px,1fr))] divide-y md:divide-y-0 md:divide-x divide-default items-stretch">
+ <CardContent className="p-0 grid grid-cols-[repeat(auto-fit,minmax(240px,1fr))] divide-y md:divide-y-0 md:divide-x items-stretch">
{/* Editor Option */}
{IS_PLATFORM && (
<>
diff --git a/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx b/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
index a4c68e74162..709d78ae9cb 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
@@ -1,4 +1,4 @@
-import { Card } from 'ui'
+import { Card, cn } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { AWSPrivateLinkSection } from './AWSPrivateLink/AWSPrivateLinkSection'
@@ -13,7 +13,7 @@ import { BASE_PATH } from '@/lib/constants'
export const IntegrationImageHandler = ({ title }: { title: 'vercel' | 'github' | 'aws' }) => {
return (
<img
- className="border rounded-lg shadow-sm w-full sm:w-48 border-body"
+ className="border rounded-lg shadow-sm w-full sm:w-48"
src={`${BASE_PATH}/img/integrations/covers/${title}-cover.png`}
alt={`${title} cover`}
/>
@@ -51,10 +51,16 @@ const INTEGRATION_ICONS: Record<
),
}
-export const IntegrationSectionIcon = ({ title }: { title: 'vercel' | 'github' | 'aws' }) => {
+export const IntegrationSectionIcon = ({
+ title,
+ className,
+}: {
+ title: 'vercel' | 'github' | 'aws'
+ className?: string
+}) => {
return (
<div className="shrink-0 text-foreground-light">
- <Card className="flex h-14 w-14 shrink-0 items-center justify-center p-0">
+ <Card className={cn('flex h-14 w-14 shrink-0 items-center justify-center p-0', className)}>
{INTEGRATION_ICONS[title]('h-5 w-5')}
</Card>
</div>
diff --git a/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx b/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
index e77fef3876f..25739d72ee9 100644
--- a/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
+++ b/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
@@ -1,4 +1,4 @@
-import { ListTree, MessageCircle, Plus } from 'lucide-react'
+import { ListTree, Plus } from 'lucide-react'
import Link from 'next/link'
import {
Button,
@@ -14,7 +14,6 @@ import {
} from 'ui'
import { BranchLink } from './BranchLink'
-import { BRANCHING_GITHUB_DISCUSSION_LINK } from '@/components/interfaces/BranchManagement/BranchManagement.constants'
import { CommandItemLink } from '@/components/ui/CommandItemLink'
import type { Branch } from '@/data/branches/branches-query'
import { useTrack } from '@/lib/telemetry/track'
@@ -63,23 +62,6 @@ export function BranchDropdownCommandContent({
Manage branches
</Link>
</Button>
- <Button
- variant="text"
- size="small"
- asChild
- block
- icon={<MessageCircle size={14} strokeWidth={1.5} />}
- >
- <a
- target="_blank"
- rel="noreferrer noopener"
- href={BRANCHING_GITHUB_DISCUSSION_LINK}
- onClick={onClose}
- className="text-xs text-foreground-light hover:text-foreground"
- >
- Branching feedback
- </a>
- </Button>
<Button
size="small"
block
@@ -160,23 +142,6 @@ export function BranchDropdownCommandContent({
<p>Manage branches</p>
</CommandItemLink>
</CommandGroup>
-
- <CommandSeparator />
-
- <CommandGroup>
- <CommandItemLink
- href={BRANCHING_GITHUB_DISCUSSION_LINK}
- linkProps={{ target: '_blank', rel: 'noreferrer noopener' }}
- className="cursor-pointer w-full gap-2"
- onSelect={onClose}
- >
- <MessageCircle size={14} strokeWidth={1} className="mt-0.5" />
- <div>
- <p>Branching feedback</p>
- <p className="text-lighter">Join GitHub Discussion</p>
- </div>
- </CommandItemLink>
- </CommandGroup>
</CommandList>
</Command>
)
diff --git a/apps/studio/pages/project/[ref]/branches/index.tsx b/apps/studio/pages/project/[ref]/branches/index.tsx
index e40721ce812..a0e069b30c1 100644
--- a/apps/studio/pages/project/[ref]/branches/index.tsx
+++ b/apps/studio/pages/project/[ref]/branches/index.tsx
@@ -1,12 +1,11 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { partition } from 'lodash'
-import { MessageCircle } from 'lucide-react'
import { useRouter } from 'next/router'
import { useState, type PropsWithChildren } from 'react'
-import { Button } from 'ui'
-import { BRANCHING_GITHUB_DISCUSSION_LINK } from '@/components/interfaces/BranchManagement/BranchManagement.constants'
+import { BranchingEmptyState } from '@/components/interfaces/BranchManagement/BranchingEmptyState'
+import { CreateBranchButton } from '@/components/interfaces/BranchManagement/CreateBranchButton'
import { DeleteBranchModal } from '@/components/interfaces/BranchManagement/DeleteBranchModal'
import { Overview } from '@/components/interfaces/BranchManagement/Overview'
import BranchLayout from '@/components/layouts/BranchLayout/BranchLayout'
@@ -14,7 +13,6 @@ import { DefaultLayout } from '@/components/layouts/DefaultLayout'
import { PageLayout } from '@/components/layouts/PageLayout/PageLayout'
import { ScaffoldContainer, ScaffoldSection } from '@/components/layouts/Scaffold'
import { AlertError } from '@/components/ui/AlertError'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DocsButton } from '@/components/ui/DocsButton'
import { NoPermission } from '@/components/ui/NoPermission'
import { Branch, useBranchesQuery } from '@/data/branches/branches-query'
@@ -70,14 +68,14 @@ const BranchesPage: NextPageWithLayout = () => {
)
const githubConnection = connections?.find((connection) => connection.project.ref === projectRef)
+ const isGithubConnected = githubConnection !== undefined
const repo = githubConnection?.repository.name ?? ''
+ const showEmptyState = isSuccessConnections && isSuccessBranches && previewBranches.length === 0
const isError = isErrorConnections || isErrorBranches
const isLoading = isLoadingConnections || isLoadingBranches
const isSuccess = isSuccessConnections && isSuccessBranches
- const isGithubConnected = githubConnection !== undefined
-
const generateCreatePullRequestURL = (branch?: string) => {
if (githubConnection === undefined) return 'https://github.com'
@@ -110,7 +108,9 @@ const BranchesPage: NextPageWithLayout = () => {
/>
)}
- {!isError && (
+ {!isError && showEmptyState ? (
+ <BranchingEmptyState isGithubConnected={isGithubConnected} />
+ ) : (
<Overview
isGithubConnected={isGithubConnected}
isLoading={isLoading}
@@ -156,54 +156,12 @@ const BranchesPage: NextPageWithLayout = () => {
// directly. Same shape and identical body as before — accepts the page
// content as `children` instead of capturing it from a closure.
export const BranchesPageWrapper = ({ children }: PropsWithChildren) => {
- const snap = useAppStateSnapshot()
- const { can: canCreateBranches } = useAsyncCheckPermissions(
- PermissionAction.CREATE,
- 'preview_branches',
- {
- resource: { is_default: false },
- }
- )
-
- const primaryActions = (
- <ButtonTooltip
- variant="primary"
- disabled={!canCreateBranches}
- onClick={() => snap.setShowCreateBranchModal(true)}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canCreateBranches
- ? 'You need additional permissions to create branches'
- : undefined,
- },
- }}
- >
- Create branch
- </ButtonTooltip>
- )
-
- const secondaryActions = (
- <div className="flex items-center gap-x-2">
- <Button
- asChild
- variant="text"
- icon={<MessageCircle className="text-muted" strokeWidth={1} />}
- >
- <a target="_blank" rel="noreferrer" href={BRANCHING_GITHUB_DISCUSSION_LINK}>
- Branching feedback
- </a>
- </Button>
- <DocsButton href={`${DOCS_URL}/guides/platform/branching`} />
- </div>
- )
-
return (
<PageLayout
title="Branches"
subtitle="Manage your database preview branches and deployments"
- primaryActions={primaryActions}
- secondaryActions={secondaryActions}
+ primaryActions={<CreateBranchButton />}
+ secondaryActions={<DocsButton href={`${DOCS_URL}/guides/platform/branching`} />}
>
{children}
</PageLayout>
diff --git a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx
index e98869a918e..eb4a71b14f5 100644
--- a/apps/studio/pages/project/[ref]/branches/merge-requests.tsx
+++ b/apps/studio/pages/project/[ref]/branches/merge-requests.tsx
@@ -1,7 +1,7 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { partition } from 'lodash'
-import { ArrowRight, GitMerge, MessageCircle, MoreVertical, Shield, X } from 'lucide-react'
+import { ArrowRight, GitMerge, MoreVertical, Shield, X } from 'lucide-react'
import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { toast } from 'sonner'
@@ -17,7 +17,6 @@ import {
} from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
-import { BRANCHING_GITHUB_DISCUSSION_LINK } from '@/components/interfaces/BranchManagement/BranchManagement.constants'
import {
BranchManagementSection,
BranchRow,
@@ -373,20 +372,7 @@ export const MergeRequestsPageWrapper = ({ children }: PropsWithChildren<{}>) =>
isUpdating={isUpdating}
/>
}
- secondaryActions={
- <div className="flex items-center gap-x-2">
- <Button
- asChild
- variant="text"
- icon={<MessageCircle className="text-muted" strokeWidth={1} />}
- >
- <a target="_blank" rel="noreferrer" href={BRANCHING_GITHUB_DISCUSSION_LINK}>
- Branching feedback
- </a>
- </Button>
- <DocsButton href={`${DOCS_URL}/guides/platform/branching`} />
- </div>
- }
+ secondaryActions={<DocsButton href={`${DOCS_URL}/guides/platform/branching`} />}
>
{children}
</PageLayout>