Skip to content

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

add default main branch if none exists (#37134)

Saxon Fletcher927f92f2d4b6
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx
index a34c813599d..bb29f74a0ce 100644
--- a/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/BranchPanels.tsx
@@ -91,7 +91,7 @@ export const BranchRow = ({
}
return (
- <div className="w-full flex items-center justify-between px-4 py-2.5 transition hover:bg-surface-100">
+ <div className="w-full flex items-center justify-between px-4 py-2.5 hover:bg-surface-100">
<div className="flex items-center gap-x-3">
{branch.git_branch && (
<ButtonTooltip
diff --git a/apps/studio/components/interfaces/BranchManagement/Overview.tsx b/apps/studio/components/interfaces/BranchManagement/Overview.tsx
index dc3a9dfcbf0..e631c4d394e 100644
--- a/apps/studio/components/interfaces/BranchManagement/Overview.tsx
+++ b/apps/studio/components/interfaces/BranchManagement/Overview.tsx
@@ -45,7 +45,6 @@ interface OverviewProps {
onSelectCreateBranch: () => void
onSelectDeleteBranch: (branch: Branch) => void
generateCreatePullRequestURL: (branchName?: string) => string
- showProductionBranch?: boolean
}
export const Overview = ({
@@ -57,33 +56,41 @@ export const Overview = ({
onSelectCreateBranch,
onSelectDeleteBranch,
generateCreatePullRequestURL,
- showProductionBranch = true,
}: OverviewProps) => {
const [persistentBranches, ephemeralBranches] = partition(
previewBranches,
(branch) => branch.persistent
)
+ const { ref: projectRef } = useParams()
return (
<>
- {showProductionBranch && (
- <BranchManagementSection header="Production branch">
- {isLoading && <BranchRowLoader />}
- {isSuccess && mainBranch !== undefined && (
- <BranchRow
- branch={mainBranch}
- label={
- <div className="flex items-center gap-x-2">
- <Shield size={14} strokeWidth={1.5} className="text-warning" />
- {mainBranch.name}
- </div>
- }
- repo={repo}
- rowActions={<MainBranchActions branch={mainBranch} repo={repo} />}
- />
- )}
- </BranchManagementSection>
- )}
+ <BranchManagementSection header="Production branch">
+ {isLoading && <BranchRowLoader />}
+ {isSuccess && mainBranch !== undefined && (
+ <BranchRow
+ branch={mainBranch}
+ label={
+ <div className="flex items-center gap-x-2">
+ <Shield size={14} strokeWidth={1.5} className="text-warning" />
+ {mainBranch.name}
+ </div>
+ }
+ repo={repo}
+ rowActions={<MainBranchActions branch={mainBranch} repo={repo} />}
+ />
+ )}
+ {isSuccess && mainBranch === undefined && (
+ <div className="w-full flex items-center justify-between px-4 py-2.5 hover:bg-surface-100">
+ <Link href={`/project/${projectRef}`} className="text-foreground block w-full">
+ <div className="flex items-center gap-x-3">
+ <Shield size={14} strokeWidth={1.5} className="text-warning" />
+ main
+ </div>
+ </Link>
+ </div>
+ )}
+ </BranchManagementSection>
{/* Persistent Branches Section */}
<BranchManagementSection header="Persistent branches">
diff --git a/apps/studio/pages/project/[ref]/branches/index.tsx b/apps/studio/pages/project/[ref]/branches/index.tsx
index fdff72d9dbc..975d6b9e3a1 100644
--- a/apps/studio/pages/project/[ref]/branches/index.tsx
+++ b/apps/studio/pages/project/[ref]/branches/index.tsx
@@ -35,8 +35,6 @@ const BranchesPage: NextPageWithLayout = () => {
const [selectedBranchToDelete, setSelectedBranchToDelete] = useState<Branch>()
- const hasBranchEnabled = project?.is_branch_enabled
-
const isBranch = project?.parent_project_ref !== undefined
const projectRef =
project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefined
@@ -136,7 +134,6 @@ const BranchesPage: NextPageWithLayout = () => {
onSelectCreateBranch={() => snap.setShowCreateBranchModal(true)}
onSelectDeleteBranch={setSelectedBranchToDelete}
generateCreatePullRequestURL={generateCreatePullRequestURL}
- showProductionBranch={hasBranchEnabled}
/>
)}
</>