11import { Button } from "@/components/ui/button" ;
22import { Badge } from "@/components/ui/badge" ;
33import { Checkbox } from "@/components/ui/checkbox" ;
4- import { Loader2 , Trash2 , GitBranch , ExternalLink } from "lucide-react" ;
4+ import { Loader2 , Trash2 , ExternalLink } from "lucide-react" ;
55import { useNavigate } from "react-router-dom" ;
6- import { useState } from "react" ;
7- import { AddBranchWorkspaceDialog } from "./AddBranchWorkspaceDialog " ;
6+
7+ import { BranchSwitcher } from "./BranchSwitcher " ;
88
99interface RepoCardProps {
1010 repo : {
@@ -31,7 +31,7 @@ export function RepoCard({
3131 onSelect,
3232} : RepoCardProps ) {
3333 const navigate = useNavigate ( ) ;
34- const [ addBranchOpen , setAddBranchOpen ] = useState ( false ) ;
34+
3535 const repoName = repo . repoUrl
3636 ? repo . repoUrl . split ( "/" ) . slice ( - 1 ) [ 0 ] . replace ( ".git" , "" )
3737 : repo . localPath || "Local Repo" ;
@@ -90,10 +90,7 @@ export function RepoCard({
9090 </ Badge >
9191 ) }
9292 </ div >
93- < p className = "text-sm text-muted-foreground truncate flex items-center gap-1" >
94- < GitBranch className = "w-3 h-3" />
95- { branchToDisplay }
96- </ p >
93+
9794 </ div >
9895
9996
@@ -118,21 +115,17 @@ export function RepoCard({
118115 < ExternalLink className = "w-4 h-4 mr-2" />
119116 Open
120117 </ Button >
121-
122118
123- < Button
124- size = "sm"
125-
126- variant = "outline"
127- onClick = { ( e ) => {
128- e . stopPropagation ( ) ;
129- setAddBranchOpen ( true ) ;
130- } }
131- disabled = { ! isReady || ! repo . repoUrl }
119+ { ! repo . isWorktree && (
120+ < BranchSwitcher
121+ repoId = { repo . id }
122+ currentBranch = { branchToDisplay || "" }
123+ isWorktree = { repo . isWorktree }
124+ repoUrl = { repo . repoUrl }
125+ repoLocalPath = { repo . localPath }
132126 className = "h-10 sm:h-9 w-10 p-0"
133- >
134- < GitBranch className = "w-4 h-4" />
135- </ Button >
127+ />
128+ ) }
136129
137130 < Button
138131 size = "sm"
@@ -153,13 +146,7 @@ export function RepoCard({
153146 </ div >
154147 </ div >
155148
156- { repo . repoUrl && (
157- < AddBranchWorkspaceDialog
158- open = { addBranchOpen }
159- onOpenChange = { setAddBranchOpen }
160- repoUrl = { repo . repoUrl }
161- />
162- ) }
149+
163150 </ div >
164151 ) ;
165152}
0 commit comments