Skip to content

Commit 4b54ed3

Browse files
committed
Enhance PushButton tooltip logic and arguments
- Expanded getButtonTooltip signature to accept withForce and remoteTrackingBranch parameters. - Updated tooltip logic to handle force-push messaging and include remote tracking branch name when present. - Adjusted call site to pass withForce and branchDetails.remoteTrackingBranch into getButtonTooltip. - Minor formatting changes to function parameters and return cases. These changes are confined to apps/desktop/src/components/PushButton.svelte and implement improved contextual tooltips for push actions.
1 parent efda00d commit 4b54ed3

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

apps/desktop/src/components/PushButton.svelte

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,33 @@
9393
9494
const loading = $derived(pushResult.current.isLoading);
9595
96-
function getButtonTooltip(hasThingsToPush: boolean, hasConflicts: boolean): string | undefined {
96+
function getButtonTooltip(
97+
hasThingsToPush: boolean,
98+
hasConflicts: boolean,
99+
withForce: boolean,
100+
remoteTrackingBranch: string | null
101+
): string | undefined {
97102
if (!hasThingsToPush) {
98103
return 'No commits to push';
99104
}
105+
100106
if (hasConflicts) {
101107
return 'In order to push, please resolve any conflicted commits.';
102108
}
109+
103110
if (multipleBranches && !isLastBranchInStack) {
104111
return 'Push this and all branches below';
105112
}
106113
107-
return undefined;
114+
if (withForce) {
115+
return remoteTrackingBranch
116+
? 'Force push this branch'
117+
: `Force push this branch to ${remoteTrackingBranch}`;
118+
}
119+
120+
return remoteTrackingBranch
121+
? `Push this branch to ${remoteTrackingBranch}`
122+
: 'Push this branch';
108123
}
109124
110125
const doNotShowPushBelowWarning = persisted<boolean>(false, 'doNotShowPushBelowWarning');
@@ -125,7 +140,12 @@
125140
style="neutral"
126141
{loading}
127142
disabled={!hasThingsToPush || hasConflicts}
128-
tooltip={getButtonTooltip(hasThingsToPush, hasConflicts)}
143+
tooltip={getButtonTooltip(
144+
hasThingsToPush,
145+
hasConflicts,
146+
withForce,
147+
branchDetails.remoteTrackingBranch
148+
)}
129149
onclick={() => handleClick({ withForce, skipForcePushProtection: false })}
130150
icon={multipleBranches && !isLastBranchInStack ? 'push-below' : 'push'}
131151
>

0 commit comments

Comments
 (0)