@@ -13,6 +13,7 @@ import { Button } from "@/shared/ui/button";
1313import {
1414 DropdownMenu ,
1515 DropdownMenuContent ,
16+ DropdownMenuItem ,
1617 DropdownMenuRadioGroup ,
1718 DropdownMenuRadioItem ,
1819 DropdownMenuTrigger ,
@@ -47,12 +48,12 @@ export function RepositoryBranchDropdown({
4748 < Button
4849 className = {
4950 compact
50- ? "h-7 max-w-full gap-1.5 rounded-md bg-muted px-3 font-mono text-sm font-medium hover:bg-muted/80 "
51- : "h-6 max-w-full gap-1.5 px-2 font-mono text-sm font-semibold"
51+ ? "h-7 max-w-full gap-1.5 rounded-md px-3 font-mono text-sm font-medium hover:border-input "
52+ : "h-6 max-w-full gap-1.5 px-2 font-mono text-sm font-semibold hover:border-input "
5253 }
5354 size = "sm"
5455 type = "button"
55- variant = "ghost "
56+ variant = "outline "
5657 >
5758 < GitBranch className = "h-4 w-4 shrink-0 text-muted-foreground" />
5859 < span className = "truncate" > { branch } </ span >
@@ -82,6 +83,9 @@ export type RepoSourceHeaderControls = {
8283 localDisabled : boolean ;
8384 localLabel : string ;
8485 remoteLabel : string ;
86+ /** Clones the repository when no local checkout is available. */
87+ onCloneLocal ?: ( ) => void ;
88+ clonePending ?: boolean ;
8589 /** Push of local commits, available when the local checkout is ahead. */
8690 canPush ?: boolean ;
8791 onPush ?: ( ) => void ;
@@ -110,15 +114,16 @@ export function RepoSourceDropdown({
110114 controls : RepoSourceHeaderControls ;
111115} ) {
112116 const isLocal = controls . source === "local" ;
117+ const cloneLocal = controls . localDisabled && controls . onCloneLocal ;
113118 const SourceIcon = isLocal ? HardDrive : Cloud ;
114119 return (
115120 < DropdownMenu >
116121 < DropdownMenuTrigger asChild >
117122 < Button
118- className = "h-7 max-w-full shrink-0 gap-1.5 rounded-md bg-muted px-3 text-sm font-medium hover:bg-muted/80 "
123+ className = "h-7 max-w-full shrink-0 gap-1.5 rounded-md px-3 text-sm font-medium hover:border-input "
119124 size = "sm"
120125 type = "button"
121- variant = "ghost "
126+ variant = "outline "
122127 >
123128 < SourceIcon className = "h-4 w-4 shrink-0 text-muted-foreground" />
124129 < span className = "truncate" >
@@ -138,14 +143,33 @@ export function RepoSourceDropdown({
138143 < Cloud className = "mr-1.5 h-3.5 w-3.5 text-muted-foreground" />
139144 { controls . remoteLabel }
140145 </ DropdownMenuRadioItem >
141- < DropdownMenuRadioItem
142- disabled = { controls . localDisabled }
143- value = "local"
144- >
145- < HardDrive className = "mr-1.5 h-3.5 w-3.5 text-muted-foreground" />
146- { controls . localLabel }
147- </ DropdownMenuRadioItem >
146+ { ! cloneLocal ? (
147+ < DropdownMenuRadioItem
148+ disabled = { controls . localDisabled }
149+ value = "local"
150+ >
151+ < HardDrive className = "mr-1.5 h-3.5 w-3.5 text-muted-foreground" />
152+ { controls . localLabel }
153+ </ DropdownMenuRadioItem >
154+ ) : null }
148155 </ DropdownMenuRadioGroup >
156+ { cloneLocal ? (
157+ < DropdownMenuItem
158+ className = "group"
159+ disabled = { controls . clonePending }
160+ onSelect = { controls . onCloneLocal }
161+ >
162+ { controls . clonePending ? (
163+ < Loader2 className = "animate-spin text-muted-foreground" />
164+ ) : (
165+ < DownloadCloud className = "text-muted-foreground" />
166+ ) }
167+ < span className = "text-muted-foreground" > { controls . localLabel } </ span >
168+ < span className = "ml-auto rounded-md border border-input/60 bg-background px-2 py-0.5 text-xs font-medium text-foreground shadow-xs group-focus:border-input" >
169+ { controls . clonePending ? "Cloning…" : "Clone" }
170+ </ span >
171+ </ DropdownMenuItem >
172+ ) : null }
149173 </ DropdownMenuContent >
150174 </ DropdownMenu >
151175 ) ;
0 commit comments