Skip to content

Commit daf5754

Browse files
author
Chris Scott
committed
Replace branch button with dropdown in RepoCard
1 parent 73db8c4 commit daf5754

2 files changed

Lines changed: 18 additions & 30 deletions

File tree

frontend/src/components/repo/BranchSwitcher.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ interface BranchSwitcherProps {
2020
isWorktree?: boolean;
2121
repoUrl?: string | null;
2222
repoLocalPath?: string;
23+
className?: string;
2324
}
2425

25-
export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, repoLocalPath }: BranchSwitcherProps) {
26+
export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, repoLocalPath, className }: BranchSwitcherProps) {
2627
const [addBranchOpen, setAddBranchOpen] = useState(false);
2728
const [gitChangesOpen, setGitChangesOpen] = useState(false);
2829
const queryClient = useQueryClient();
@@ -60,7 +61,7 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
6061
<Button
6162
variant="ghost"
6263
size="sm"
63-
className="h-6 px-1 sm:px-2 text-[10px] sm:text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-accent gap-1 border border-blue-500/20"
64+
className={`h-6 px-1 sm:px-2 text-[10px] sm:text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-accent gap-1 border border-blue-500/20 ${className || ""}`}
6465
>
6566
<GitBranch className="w-3 h-3" />
6667
<span className="hidden sm:inline">{currentBranch}</span>

frontend/src/components/repo/RepoCard.tsx

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Button } from "@/components/ui/button";
22
import { Badge } from "@/components/ui/badge";
33
import { Checkbox } from "@/components/ui/checkbox";
4-
import { Loader2, Trash2, GitBranch, ExternalLink } from "lucide-react";
4+
import { Loader2, Trash2, ExternalLink } from "lucide-react";
55
import { useNavigate } from "react-router-dom";
6-
import { useState } from "react";
7-
import { AddBranchWorkspaceDialog } from "./AddBranchWorkspaceDialog";
6+
7+
import { BranchSwitcher } from "./BranchSwitcher";
88

99
interface 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

Comments
 (0)