Skip to content

Commit f06dd82

Browse files
authored
Merge pull request #9902 from gitbutlerapp/push-button-tooltip-improvements
Enhance PushButton tooltip logic and arguments
2 parents 7a3f820 + 4b54ed3 commit f06dd82

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)