Skip to content

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

Update branch management page with all GH stuff, scaffold change production branch CTA, add ScrollArea to org projects and branch popovers

Joshen Lim7c790c7c8bc9
diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
index 6b0a239d64a..e7c892dd3d6 100644
--- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
@@ -125,7 +125,6 @@ const BranchManagement = () => {
{isBranchingAllowed ? (
<div className="!mt-4">
<Button
- type="default"
icon={<IconGitBranch strokeWidth={1.5} />}
onClick={() => snap.setShowEnableBranchingModal(true)}
>
diff --git a/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
index 6e7d661f2da..074d6f02a91 100644
--- a/studio/components/interfaces/BranchManagement/BranchPanels.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
@@ -33,7 +33,12 @@ interface BranchPanelProps {
generatePullRequestURL?: (branch?: string) => string
}
-const MainBranchPanel = ({ repo, branch, onSelectDisableBranching = noop }: BranchPanelProps) => {
+const MainBranchPanel = ({
+ repo,
+ branch,
+ onSelectUpdate = noop,
+ onSelectDisableBranching = noop,
+}: BranchPanelProps) => {
const { ref } = useParams()
const [open, setOpen] = useState(false)
const isActive = ref === branch.project_ref
@@ -77,9 +82,15 @@ const MainBranchPanel = ({ repo, branch, onSelectDisableBranching = noop }: Bran
</Button>
</DropdownMenuTrigger_Shadcn_>
<DropdownMenuContent_Shadcn_ side="bottom" align="end">
- <DropdownMenuItem_Shadcn_ className="flex gap-2" onSelect={() => {}}>
- Change production branch
- </DropdownMenuItem_Shadcn_>
+ <Link passHref href={`/project/${ref}/settings/general`}>
+ <DropdownMenuItem_Shadcn_
+ asChild
+ className="flex gap-2"
+ onSelect={() => onSelectUpdate()}
+ >
+ <a>Change production branch</a>
+ </DropdownMenuItem_Shadcn_>
+ </Link>
<Dropdown.Separator />
<DropdownMenuItem_Shadcn_
className="flex gap-2"
diff --git a/studio/components/interfaces/BranchManagement/CreateBranchSidePanel.tsx b/studio/components/interfaces/BranchManagement/CreateBranchSidePanel.tsx
index f4d72984dd8..057b95a2600 100644
--- a/studio/components/interfaces/BranchManagement/CreateBranchSidePanel.tsx
+++ b/studio/components/interfaces/BranchManagement/CreateBranchSidePanel.tsx
@@ -61,9 +61,12 @@ const CreateBranchSidePanel = ({ visible, onClose }: CreateBranchSidePanelProps)
const githubIntegration = integrations?.find(
(integration) =>
integration.integration.name === 'GitHub' &&
- integration.connections.some((connection) => connection.supabase_project_ref === projectRef)
+ integration.organization.slug === selectedOrg?.slug
+ )
+
+ const repositoryMeta = githubIntegration?.connections?.find(
+ (connection) => connection.supabase_project_ref === ref
)
- const repositoryMeta = githubIntegration?.connections?.[0]
const [repoOwner, repoName] = repositoryMeta?.metadata.name.split('/') || []
const {
data: githubBranches,
@@ -169,6 +172,9 @@ const CreateBranchSidePanel = ({ visible, onClose }: CreateBranchSidePanelProps)
)}
<div className="[&>*:first-child]:rounded-t-md">
{branchOptions?.map((branch) => {
+ const isProductionBranch = branches?.find(
+ (b) => b.git_branch === branch.name && b.is_default
+ )
const alreadyHasDatabaseBranch =
branches?.some((b) => b.git_branch === branch.name) ?? false
return (
@@ -182,7 +188,7 @@ const CreateBranchSidePanel = ({ visible, onClose }: CreateBranchSidePanelProps)
<p className="text-sm">{branch.name}</p>
</div>
<Button
- type="default"
+ type={isProductionBranch ? 'warning' : 'default'}
loading={isCreating}
disabled={isCreating || alreadyHasDatabaseBranch}
onClick={() => onCreateBranch(branch.name)}
@@ -192,7 +198,11 @@ const CreateBranchSidePanel = ({ visible, onClose }: CreateBranchSidePanelProps)
: ''
}
>
- {alreadyHasDatabaseBranch ? 'Branch already created' : 'Create branch'}
+ {isProductionBranch
+ ? 'Production branch'
+ : alreadyHasDatabaseBranch
+ ? 'Branch already created'
+ : 'Create branch'}
</Button>
</div>
</div>
diff --git a/studio/components/layouts/AppLayout/BranchDropdown.tsx b/studio/components/layouts/AppLayout/BranchDropdown.tsx
index 4e7e3378cb1..6eb09304f71 100644
--- a/studio/components/layouts/AppLayout/BranchDropdown.tsx
+++ b/studio/components/layouts/AppLayout/BranchDropdown.tsx
@@ -1,10 +1,11 @@
+import Link from 'next/link'
import { useRouter } from 'next/router'
import { useRef, useState } from 'react'
-import Link from 'next/link'
import { useParams } from 'common'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { Branch, useBranchesQuery } from 'data/branches/branches-query'
+import { useSelectedProject } from 'hooks'
import {
Badge,
Button,
@@ -18,12 +19,11 @@ import {
IconCheck,
IconCode,
IconGitBranch,
- IconPlus,
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
+ ScrollArea,
} from 'ui'
-import { useSelectedProject } from 'hooks'
import { sanitizeRoute } from './ProjectDropdown'
const BranchLink = ({
@@ -126,14 +126,16 @@ const BranchDropdown = () => {
<CommandList_Shadcn_>
<CommandEmpty_Shadcn_>No branches found</CommandEmpty_Shadcn_>
<CommandGroup_Shadcn_>
- {branches?.map((branch) => (
- <BranchLink
- key={branch.id}
- branch={branch}
- isSelected={branch.id === selectedBranch?.id}
- setOpen={setOpen}
- />
- ))}
+ <ScrollArea className={(branches || []).length > 7 ? 'h-[210px]' : ''}>
+ {branches?.map((branch) => (
+ <BranchLink
+ key={branch.id}
+ branch={branch}
+ isSelected={branch.id === selectedBranch?.id}
+ setOpen={setOpen}
+ />
+ ))}
+ </ScrollArea>
</CommandGroup_Shadcn_>
<CommandGroup_Shadcn_ className="border-t">
<Link passHref href={`/project/${ref}/branches`}>
diff --git a/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx b/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx
index 41a4ae16676..f86e96b19b1 100644
--- a/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx
+++ b/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx
@@ -155,7 +155,13 @@ const EnableBranchingButton = () => {
<Modal.Content className="px-7">
<div className="flex items-center space-x-2 py-2 pb-4">
- <Button size="medium" block disabled={isCreating} type="default">
+ <Button
+ size="medium"
+ block
+ disabled={isCreating}
+ type="default"
+ onClick={() => snap.setShowEnableBranchingModal(false)}
+ >
Cancel
</Button>
<Button
diff --git a/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx b/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx
index 8df21d08933..ac7f4060509 100644
--- a/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx
+++ b/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx
@@ -127,7 +127,7 @@ const GithubRepositorySelection = ({
size="medium"
ref={comboBoxRef}
className={clsx(
- 'justify-start w-64',
+ 'justify-start',
selectedBranch === undefined ? 'text-light' : 'text'
)}
iconRight={
diff --git a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
index 79fe2d975e5..64c77a964f9 100644
--- a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
+++ b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
@@ -16,6 +16,7 @@ import {
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
+ ScrollArea,
} from 'ui'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
@@ -73,30 +74,32 @@ const OrganizationDropdown = () => {
<CommandList_Shadcn_>
<CommandEmpty_Shadcn_>No organizations found</CommandEmpty_Shadcn_>
<CommandGroup_Shadcn_>
- {organizations?.map((org) => {
- const href = router.pathname.includes('[slug]')
- ? router.pathname.replace('[slug]', org.slug)
- : `/org/${org.slug}`
- return (
- <Link passHref href={href} key={org.slug}>
- <CommandItem_Shadcn_
- asChild
- value={org.name}
- className="cursor-pointer w-full flex items-center justify-between"
- onSelect={() => {
- setOpen(false)
- router.push(href)
- }}
- onClick={() => setOpen(false)}
- >
- <a>
- {org.name}
- {org.slug === slug && <IconCheck />}
- </a>
- </CommandItem_Shadcn_>
- </Link>
- )
- })}
+ <ScrollArea className={(organizations || []).length > 7 ? 'h-[210px]' : ''}>
+ {organizations?.map((org) => {
+ const href = router.pathname.includes('[slug]')
+ ? router.pathname.replace('[slug]', org.slug)
+ : `/org/${org.slug}`
+ return (
+ <Link passHref href={href} key={org.slug}>
+ <CommandItem_Shadcn_
+ asChild
+ value={org.name}
+ className="cursor-pointer w-full flex items-center justify-between"
+ onSelect={() => {
+ setOpen(false)
+ router.push(href)
+ }}
+ onClick={() => setOpen(false)}
+ >
+ <a>
+ {org.name}
+ {org.slug === slug && <IconCheck />}
+ </a>
+ </CommandItem_Shadcn_>
+ </Link>
+ )
+ })}
+ </ScrollArea>
</CommandGroup_Shadcn_>
<CommandGroup_Shadcn_ className="border-t">
<Link passHref href={orgCreationV2 ? `/new-with-subscription` : `/new`}>
diff --git a/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/studio/components/layouts/AppLayout/ProjectDropdown.tsx
index 42283f06859..5e5b37d974d 100644
--- a/studio/components/layouts/AppLayout/ProjectDropdown.tsx
+++ b/studio/components/layouts/AppLayout/ProjectDropdown.tsx
@@ -17,6 +17,7 @@ import {
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
+ ScrollArea,
} from 'ui'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
@@ -159,14 +160,16 @@ const ProjectDropdown = () => {
<CommandList_Shadcn_>
<CommandEmpty_Shadcn_>No projects found</CommandEmpty_Shadcn_>
<CommandGroup_Shadcn_>
- {projects?.map((project) => (
- <ProjectLink
- key={project.ref}
- project={project}
- organization={selectedOrganization}
- setOpen={setOpen}
- />
- ))}
+ <ScrollArea className={(projects || []).length > 7 ? 'h-[210px]' : ''}>
+ {projects?.map((project) => (
+ <ProjectLink
+ key={project.ref}
+ project={project}
+ organization={selectedOrganization}
+ setOpen={setOpen}
+ />
+ ))}
+ </ScrollArea>
</CommandGroup_Shadcn_>
<CommandGroup_Shadcn_ className="border-t">
<Link
diff --git a/studio/data/branches/branches-disable-mutation.ts b/studio/data/branches/branches-disable-mutation.ts
index b557cf77ef4..32f3cdbaedc 100644
--- a/studio/data/branches/branches-disable-mutation.ts
+++ b/studio/data/branches/branches-disable-mutation.ts
@@ -24,7 +24,7 @@ export async function disableBranching({ branchIds, projectRef }: BranchesDisabl
}
})
)
- const hasError = res.some((item: any) => item.message !== undefined)
+ const hasError = res.some((item: any) => item.message !== 'ok')
if (hasError) throw new Error('Failed to disable branching: Unable to delete all branches')
}