mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 21:23:07 +00:00
Add branch switch to mobile worktree panel
This commit is contained in:
@@ -20,6 +20,8 @@ interface BranchSwitchDropdownProps {
|
|||||||
branchFilter: string;
|
branchFilter: string;
|
||||||
isLoadingBranches: boolean;
|
isLoadingBranches: boolean;
|
||||||
isSwitching: boolean;
|
isSwitching: boolean;
|
||||||
|
/** When true, renders as a standalone button (not attached to another element) */
|
||||||
|
standalone?: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
onFilterChange: (value: string) => void;
|
onFilterChange: (value: string) => void;
|
||||||
onSwitchBranch: (worktree: WorktreeInfo, branchName: string) => void;
|
onSwitchBranch: (worktree: WorktreeInfo, branchName: string) => void;
|
||||||
@@ -33,6 +35,7 @@ export function BranchSwitchDropdown({
|
|||||||
branchFilter,
|
branchFilter,
|
||||||
isLoadingBranches,
|
isLoadingBranches,
|
||||||
isSwitching,
|
isSwitching,
|
||||||
|
standalone = false,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
onFilterChange,
|
onFilterChange,
|
||||||
onSwitchBranch,
|
onSwitchBranch,
|
||||||
@@ -42,16 +45,18 @@ export function BranchSwitchDropdown({
|
|||||||
<DropdownMenu onOpenChange={onOpenChange}>
|
<DropdownMenu onOpenChange={onOpenChange}>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant={isSelected ? 'default' : 'outline'}
|
variant={standalone ? 'outline' : isSelected ? 'default' : 'outline'}
|
||||||
size="sm"
|
size="sm"
|
||||||
className={cn(
|
className={cn(
|
||||||
'h-7 w-7 p-0 rounded-none border-r-0',
|
'h-7 w-7 p-0',
|
||||||
isSelected && 'bg-primary text-primary-foreground',
|
!standalone && 'rounded-none border-r-0',
|
||||||
!isSelected && 'bg-secondary/50 hover:bg-secondary'
|
standalone && 'h-8 w-8 shrink-0',
|
||||||
|
!standalone && isSelected && 'bg-primary text-primary-foreground',
|
||||||
|
!standalone && !isSelected && 'bg-secondary/50 hover:bg-secondary'
|
||||||
)}
|
)}
|
||||||
title="Switch branch"
|
title="Switch branch"
|
||||||
>
|
>
|
||||||
<GitBranch className="w-3 h-3" />
|
<GitBranch className={standalone ? 'w-3.5 h-3.5' : 'w-3 h-3'} />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="start" className="w-64">
|
<DropdownMenuContent align="start" className="w-64">
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ import {
|
|||||||
useWorktreeActions,
|
useWorktreeActions,
|
||||||
useRunningFeatures,
|
useRunningFeatures,
|
||||||
} from './hooks';
|
} from './hooks';
|
||||||
import { WorktreeTab, WorktreeMobileDropdown, WorktreeActionsDropdown } from './components';
|
import {
|
||||||
|
WorktreeTab,
|
||||||
|
WorktreeMobileDropdown,
|
||||||
|
WorktreeActionsDropdown,
|
||||||
|
BranchSwitchDropdown,
|
||||||
|
} from './components';
|
||||||
|
|
||||||
export function WorktreePanel({
|
export function WorktreePanel({
|
||||||
projectPath,
|
projectPath,
|
||||||
@@ -186,6 +191,24 @@ export function WorktreePanel({
|
|||||||
onSelectWorktree={handleSelectWorktree}
|
onSelectWorktree={handleSelectWorktree}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Branch switch dropdown for the selected worktree */}
|
||||||
|
{selectedWorktree && (
|
||||||
|
<BranchSwitchDropdown
|
||||||
|
worktree={selectedWorktree}
|
||||||
|
isSelected={true}
|
||||||
|
standalone={true}
|
||||||
|
branches={branches}
|
||||||
|
filteredBranches={filteredBranches}
|
||||||
|
branchFilter={branchFilter}
|
||||||
|
isLoadingBranches={isLoadingBranches}
|
||||||
|
isSwitching={isSwitching}
|
||||||
|
onOpenChange={handleBranchDropdownOpenChange(selectedWorktree)}
|
||||||
|
onFilterChange={setBranchFilter}
|
||||||
|
onSwitchBranch={handleSwitchBranch}
|
||||||
|
onCreateBranch={onCreateBranch}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Actions menu for the selected worktree */}
|
{/* Actions menu for the selected worktree */}
|
||||||
{selectedWorktree && (
|
{selectedWorktree && (
|
||||||
<WorktreeActionsDropdown
|
<WorktreeActionsDropdown
|
||||||
|
|||||||
Reference in New Issue
Block a user