Skip to content

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

Fix

Joshen Lim663038732755
diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
index e0ed504aafe..5cd9623eb07 100644
--- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
@@ -182,6 +182,7 @@ const BranchManagement = () => {
<PullRequests
previewBranches={previewBranches}
generateCreatePullRequestURL={generateCreatePullRequestURL}
+ onSelectDeleteBranch={setSelectedBranchToDelete}
/>
<PreviewBranches
generateCreatePullRequestURL={generateCreatePullRequestURL}
diff --git a/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
index 13124713f6a..40a8102e285 100644
--- a/studio/components/interfaces/BranchManagement/BranchPanels.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
@@ -206,7 +206,13 @@ const BranchHeader = forwardRef<HTMLDivElement, BranchHeader>(
}
)
-const PullRequestPanel = ({ pr }: { pr: GitHubPullRequest }) => {
+const PullRequestPanel = ({
+ pr,
+ onSelectDelete = noop,
+}: {
+ pr: GitHubPullRequest
+ onSelectDelete: () => void
+}) => {
const [open, setOpen] = useState(false)
const daysFromNow = dayjs().diff(dayjs(pr.created_at), 'day')
const formattedTimeFromNow = dayjs(pr.created_at).fromNow()
@@ -243,7 +249,7 @@ const PullRequestPanel = ({ pr }: { pr: GitHubPullRequest }) => {
</Button>
</DropdownMenuTrigger_Shadcn_>
<DropdownMenuContent_Shadcn_ side="bottom" align="end">
- <DropdownMenuItem_Shadcn_ className="flex gap-2" onSelect={() => {}}>
+ <DropdownMenuItem_Shadcn_ className="flex gap-2" onSelect={() => onSelectDelete()}>
<IconTrash size={14} />
Delete branch
</DropdownMenuItem_Shadcn_>
diff --git a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx
index 872c52aedaa..6b11a67ae32 100644
--- a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx
+++ b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx
@@ -59,7 +59,9 @@ const PreviewBranches = ({
return (
<>
- <BranchHeader markdown={previewBranches.length > 0 ? `#### Preview branches` : undefined} />
+ {previewBranches.length > 0 && previewBranchesNotInPR.length > 0 && (
+ <BranchHeader markdown={previewBranches.length > 0 ? `#### Preview branches` : undefined} />
+ )}
{isLoadingBranches && (
<BranchContainer>
diff --git a/studio/components/interfaces/BranchManagement/PullRequests.tsx b/studio/components/interfaces/BranchManagement/PullRequests.tsx
index 6c9ca01ce76..3b7620135f8 100644
--- a/studio/components/interfaces/BranchManagement/PullRequests.tsx
+++ b/studio/components/interfaces/BranchManagement/PullRequests.tsx
@@ -13,9 +13,14 @@ import AlertError from 'components/ui/AlertError'
interface PullRequestsProps {
previewBranches: Branch[]
generateCreatePullRequestURL: (branch?: string) => string
+ onSelectDeleteBranch: (branch: Branch) => void
}
-const PullRequests = ({ previewBranches, generateCreatePullRequestURL }: PullRequestsProps) => {
+const PullRequests = ({
+ previewBranches,
+ generateCreatePullRequestURL,
+ onSelectDeleteBranch,
+}: PullRequestsProps) => {
const { ref } = useParams()
const selectedOrg = useSelectedOrganization()
const pullRequestUrl = generateCreatePullRequestURL()
@@ -118,7 +123,18 @@ const PullRequests = ({ previewBranches, generateCreatePullRequestURL }: PullReq
</div>
</BranchContainer>
) : (
- pullRequests?.map((pr) => <PullRequestPanel key={pr.id} pr={pr} />)
+ pullRequests?.map((pr) => {
+ const branch = branches?.find((branch) => branch.git_branch === pr.branch)
+ return (
+ <PullRequestPanel
+ key={pr.id}
+ pr={pr}
+ onSelectDelete={() => {
+ if (branch !== undefined) onSelectDeleteBranch(branch)
+ }}
+ />
+ )
+ })
)}
</>
)}