Skip to content

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

Chore/branch management fixes (#18974)

Joshen Lim3f75db8d2ccc
diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
index 43747e3daad..58a26dff930 100644
--- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
@@ -68,7 +68,10 @@ const BranchManagement = () => {
isError: isErrorBranches,
isSuccess: isSuccessBranches,
} = useBranchesQuery({ projectRef })
- const [[mainBranch], previewBranches] = partition(branches, (branch) => branch.is_default)
+ const [[mainBranch], previewBranchesUnsorted] = partition(branches, (branch) => branch.is_default)
+ const previewBranches = previewBranchesUnsorted.sort((a, b) =>
+ new Date(a.updated_at) < new Date(b.updated_at) ? 1 : -1
+ )
const branchesWithPRs = previewBranches.filter((branch) => branch.pr_number !== undefined)
const prNumbers =
branches !== undefined
@@ -289,6 +292,7 @@ const BranchManagement = () => {
branch={branch}
pullRequest={pullRequest}
generateCreatePullRequestURL={generateCreatePullRequestURL}
+ onSelectDeleteBranch={() => setSelectedBranchToDelete(branch)}
/>
)
})
@@ -328,6 +332,7 @@ const BranchManagement = () => {
branch={branch}
pullRequest={pullRequest}
generateCreatePullRequestURL={generateCreatePullRequestURL}
+ onSelectDeleteBranch={() => setSelectedBranchToDelete(branch)}
/>
)
})}
diff --git a/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
index d8ab75c738c..f2a1cf2035e 100644
--- a/studio/components/interfaces/BranchManagement/BranchPanels.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
@@ -75,7 +75,7 @@ interface BranchRowProps {
isMain?: boolean
pullRequest?: GitHubPullRequest
generateCreatePullRequestURL?: (branchName?: string) => string
- onSelectDeleteBranch?: () => void
+ onSelectDeleteBranch: () => void
}
export const BranchRow = ({
@@ -89,9 +89,9 @@ export const BranchRow = ({
const { ref } = useParams()
const isActive = ref === branch?.project_ref
- const daysFromNow = dayjs().diff(dayjs(branch.created_at), 'day')
- const formattedTimeFromNow = dayjs(branch.created_at).fromNow()
- const formattedCreatedAt = dayjs(branch.created_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')
+ const daysFromNow = dayjs().diff(dayjs(branch.updated_at), 'day')
+ const formattedTimeFromNow = dayjs(branch.updated_at).fromNow()
+ const formattedUpdatedAt = dayjs(branch.updated_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')
const createPullRequestURL =
generateCreatePullRequestURL?.(branch.git_branch) ?? 'https://github.com'
@@ -102,13 +102,16 @@ export const BranchRow = ({
<Button
asChild
type="default"
+ className="max-w-[300px]"
icon={isMain && <IconShield strokeWidth={2} className="text-amber-900" />}
>
- <Link href={`/project/${branch.project_ref}/branches`}>{branch.name}</Link>
+ <Link href={`/project/${branch.project_ref}/branches`} title={branch.name}>
+ {branch.name}
+ </Link>
</Button>
{isActive && <Badge color="slate">Current</Badge>}
<p className="text-xs text-foreground-lighter">
- {daysFromNow > 1 ? `Created on ${formattedCreatedAt}` : `Created ${formattedTimeFromNow}`}
+ {daysFromNow > 1 ? `Updated on ${formattedUpdatedAt}` : `Updated ${formattedTimeFromNow}`}
</p>
</div>
<div className="flex items-center gap-x-8">
diff --git a/studio/components/interfaces/BranchManagement/Overview.tsx b/studio/components/interfaces/BranchManagement/Overview.tsx
index 47cbd02b975..e50e0aed985 100644
--- a/studio/components/interfaces/BranchManagement/Overview.tsx
+++ b/studio/components/interfaces/BranchManagement/Overview.tsx
@@ -1,4 +1,4 @@
-import { useParams } from 'common'
+import { noop } from 'lodash'
import { Button, IconChevronRight } from 'ui'
import { Branch } from 'data/branches/branches-query'
@@ -38,7 +38,7 @@ const Overview = ({
<BranchManagementSection header="Production branch">
{isLoading && <BranchRowLoader />}
{isSuccess && mainBranch !== undefined && (
- <BranchRow isMain branch={mainBranch} repo={repo} />
+ <BranchRow isMain branch={mainBranch} repo={repo} onSelectDeleteBranch={noop} />
)}
</BranchManagementSection>