Keep git panel when branchstatus fails (vibe-kanban) (#913)
* Done! I've updated the code to keep the Git panel visible when `branchStatus` fails:
**Changes made:**
1. **GitOperations.tsx:253-256**: Changed the early return condition to only hide the panel when PR is merged, not when `branchStatus` is null
2. **GitOperations.tsx:438-505**: Wrapped the merge/PR/rebase buttons in a conditional `{branchStatus && ...}` so they only display when branch status is available
3. **TaskDetailsToolbar.tsx:227-238**: Removed the `branchStatus` condition from the parent, so `GitOperations` is always rendered when `selectedAttempt` exists
**Result:**
- The Git panel (showing branch names and the arrow) will now always display when there's a selected attempt
- The merge, PR, and rebase buttons will only show when branch status loads successfully
- The panel still hides completely if the PR has been merged
* Updated! Now the target branch will fallback to `selectedAttempt.target_branch` if `branchStatus` doesn't load, ensuring the target branch label always displays correctly.
This commit is contained in:
@@ -224,12 +224,12 @@ function TaskDetailsToolbar({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Independent Git Operations Section */}
|
{/* Independent Git Operations Section */}
|
||||||
{selectedAttempt && branchStatus && (
|
{selectedAttempt && (
|
||||||
<GitOperations
|
<GitOperations
|
||||||
selectedAttempt={selectedAttempt}
|
selectedAttempt={selectedAttempt}
|
||||||
task={task}
|
task={task}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
branchStatus={branchStatus}
|
branchStatus={branchStatus ?? null}
|
||||||
branches={branches}
|
branches={branches}
|
||||||
isAttemptRunning={isAttemptRunning}
|
isAttemptRunning={isAttemptRunning}
|
||||||
setError={setError}
|
setError={setError}
|
||||||
|
|||||||
@@ -250,7 +250,8 @@ function GitOperations({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!branchStatus || mergeInfo.hasMergedPR) {
|
// Hide entire panel only if PR is merged
|
||||||
|
if (mergeInfo.hasMergedPR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +299,7 @@ function GitOperations({
|
|||||||
<GitBranchIcon className="h-3 w-3 text-muted-foreground" />
|
<GitBranchIcon className="h-3 w-3 text-muted-foreground" />
|
||||||
<span className="text-sm font-medium truncate">
|
<span className="text-sm font-medium truncate">
|
||||||
{branchStatus?.target_branch_name ||
|
{branchStatus?.target_branch_name ||
|
||||||
|
selectedAttempt.target_branch ||
|
||||||
selectedBranch ||
|
selectedBranch ||
|
||||||
t('git.branch.current')}
|
t('git.branch.current')}
|
||||||
</span>
|
</span>
|
||||||
@@ -434,72 +436,74 @@ function GitOperations({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Git Operations */}
|
{/* Git Operations - only show when branchStatus is available */}
|
||||||
<div className="flex gap-2">
|
{branchStatus && (
|
||||||
<Button
|
<div className="flex gap-2">
|
||||||
onClick={handleMergeClick}
|
<Button
|
||||||
disabled={
|
onClick={handleMergeClick}
|
||||||
mergeInfo.hasOpenPR ||
|
disabled={
|
||||||
merging ||
|
mergeInfo.hasOpenPR ||
|
||||||
hasConflictsCalculated ||
|
merging ||
|
||||||
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
hasConflictsCalculated ||
|
||||||
isAttemptRunning ||
|
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
||||||
((branchStatus.commits_ahead ?? 0) === 0 &&
|
isAttemptRunning ||
|
||||||
!pushSuccess &&
|
((branchStatus.commits_ahead ?? 0) === 0 &&
|
||||||
!mergeSuccess)
|
!pushSuccess &&
|
||||||
}
|
!mergeSuccess)
|
||||||
variant="outline"
|
}
|
||||||
size="xs"
|
variant="outline"
|
||||||
className="border-success text-success hover:bg-success gap-1 flex-1"
|
size="xs"
|
||||||
>
|
className="border-success text-success hover:bg-success gap-1 flex-1"
|
||||||
<GitBranchIcon className="h-3 w-3" />
|
>
|
||||||
{mergeButtonLabel}
|
<GitBranchIcon className="h-3 w-3" />
|
||||||
</Button>
|
{mergeButtonLabel}
|
||||||
<Button
|
</Button>
|
||||||
onClick={handlePRButtonClick}
|
<Button
|
||||||
disabled={
|
onClick={handlePRButtonClick}
|
||||||
pushing ||
|
disabled={
|
||||||
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
pushing ||
|
||||||
isAttemptRunning ||
|
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
||||||
hasConflictsCalculated ||
|
isAttemptRunning ||
|
||||||
(mergeInfo.hasOpenPR &&
|
hasConflictsCalculated ||
|
||||||
branchStatus.remote_commits_ahead === 0) ||
|
(mergeInfo.hasOpenPR &&
|
||||||
((branchStatus.commits_ahead ?? 0) === 0 &&
|
branchStatus.remote_commits_ahead === 0) ||
|
||||||
(branchStatus.remote_commits_ahead ?? 0) === 0 &&
|
((branchStatus.commits_ahead ?? 0) === 0 &&
|
||||||
!pushSuccess &&
|
(branchStatus.remote_commits_ahead ?? 0) === 0 &&
|
||||||
!mergeSuccess)
|
!pushSuccess &&
|
||||||
}
|
!mergeSuccess)
|
||||||
variant="outline"
|
}
|
||||||
size="xs"
|
variant="outline"
|
||||||
className="border-info text-info hover:bg-info gap-1 flex-1"
|
size="xs"
|
||||||
>
|
className="border-info text-info hover:bg-info gap-1 flex-1"
|
||||||
<GitPullRequest className="h-3 w-3" />
|
>
|
||||||
{mergeInfo.hasOpenPR
|
<GitPullRequest className="h-3 w-3" />
|
||||||
? pushSuccess
|
{mergeInfo.hasOpenPR
|
||||||
? t('git.states.pushed')
|
? pushSuccess
|
||||||
: pushing
|
? t('git.states.pushed')
|
||||||
? t('git.states.pushing')
|
: pushing
|
||||||
: t('git.states.push')
|
? t('git.states.pushing')
|
||||||
: t('git.states.createPr')}
|
: t('git.states.push')
|
||||||
</Button>
|
: t('git.states.createPr')}
|
||||||
<Button
|
</Button>
|
||||||
onClick={handleRebaseDialogOpen}
|
<Button
|
||||||
disabled={
|
onClick={handleRebaseDialogOpen}
|
||||||
rebasing ||
|
disabled={
|
||||||
isAttemptRunning ||
|
rebasing ||
|
||||||
hasConflictsCalculated ||
|
isAttemptRunning ||
|
||||||
(branchStatus.commits_behind ?? 0) === 0
|
hasConflictsCalculated ||
|
||||||
}
|
(branchStatus.commits_behind ?? 0) === 0
|
||||||
variant="outline"
|
}
|
||||||
size="xs"
|
variant="outline"
|
||||||
className="border-warning text-warning hover:bg-warning gap-1 flex-1"
|
size="xs"
|
||||||
>
|
className="border-warning text-warning hover:bg-warning gap-1 flex-1"
|
||||||
<RefreshCw
|
>
|
||||||
className={`h-3 w-3 ${rebasing ? 'animate-spin' : ''}`}
|
<RefreshCw
|
||||||
/>
|
className={`h-3 w-3 ${rebasing ? 'animate-spin' : ''}`}
|
||||||
{rebaseButtonLabel}
|
/>
|
||||||
</Button>
|
{rebaseButtonLabel}
|
||||||
</div>
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user