1- import { AlertCircle , Check , ChevronsUpDown , ListTree , MessageCircle } from 'lucide-react'
1+ import { AlertCircle , Check , ChevronsUpDown , ListTree , MessageCircle , Shield } from 'lucide-react'
22import Link from 'next/link'
33import { useRouter } from 'next/router'
44import { useState } from 'react'
@@ -51,10 +51,11 @@ const BranchLink = ({
5151 setOpen ( false )
5252 } }
5353 >
54- < p className = "truncate w-60" title = { branch . name } >
54+ < p className = "truncate w-60 flex items-center gap-1" title = { branch . name } >
55+ { branch . is_default && < Shield size = { 14 } className = "text-amber-900" /> }
5556 { branch . name }
5657 </ p >
57- { isSelected && < Check /> }
58+ { isSelected && < Check size = { 14 } strokeWidth = { 1.5 } /> }
5859 </ CommandItem_Shadcn_ >
5960 </ Link >
6061 )
@@ -77,6 +78,15 @@ const BranchDropdown = ({ isNewNav = false }: BranchDropdownProps) => {
7778 const [ open , setOpen ] = useState ( false )
7879 const selectedBranch = branches ?. find ( ( branch ) => branch . project_ref === ref )
7980
81+ const mainBranch = branches ?. find ( ( branch ) => branch . is_default )
82+ const restOfBranches = branches
83+ ?. filter ( ( branch ) => ! branch . is_default )
84+ . sort ( ( a , b ) => new Date ( b . created_at ) . getTime ( ) - new Date ( a . created_at ) . getTime ( ) )
85+
86+ const sortedBranches = mainBranch
87+ ? [ mainBranch ] . concat ( restOfBranches ?? [ ] )
88+ : restOfBranches ?? [ ]
89+
8090 const BRANCHING_GITHUB_DISCUSSION_LINK = 'https://github.com/orgs/supabase/discussions/18937'
8191
8292 return (
@@ -112,7 +122,7 @@ const BranchDropdown = ({ isNewNav = false }: BranchDropdownProps) => {
112122 < CommandEmpty_Shadcn_ > No branches found</ CommandEmpty_Shadcn_ >
113123 < CommandGroup_Shadcn_ >
114124 < ScrollArea className = "max-h-[210px] overflow-y-auto" >
115- { branches ?. map ( ( branch ) => (
125+ { sortedBranches ?. map ( ( branch ) => (
116126 < BranchLink
117127 key = { branch . id }
118128 branch = { branch }
0 commit comments