@@ -3,11 +3,9 @@ import React from 'react';
3
3
import type { BranchState , State } from '../../../../../plus/webviews/graph/protocol' ;
4
4
import { pluralize } from '../../../../../system/string' ;
5
5
import { createWebviewCommandLink } from '../../../../../system/webview' ;
6
- import { MenuItem , MenuLabel } from '../../../shared/components/menu/react' ;
7
- import { GlPopover } from '../../../shared/components/overlays/popover.react' ;
8
6
import { GlTooltip } from '../../../shared/components/overlays/tooltip.react' ;
9
7
10
- export const SyncButton = ( {
8
+ export const PushPullButton = ( {
11
9
branchState,
12
10
state,
13
11
fetchedText,
@@ -20,17 +18,21 @@ export const SyncButton = ({
20
18
branchName : string | undefined ;
21
19
remote : ReactNode ;
22
20
} ) => {
23
- const isBehind = Boolean ( branchState ?. behind ) ;
24
- const isAhead = Boolean ( branchState ?. ahead ) ;
25
- const hasChanges = isAhead || isBehind ;
26
- if ( ! hasChanges || ! branchState ) {
21
+ let isBehind = false ;
22
+ let isAhead = false ;
23
+ if ( branchState ) {
24
+ isBehind = branchState . behind > 0 ;
25
+ isAhead = branchState . ahead > 0 ;
26
+ }
27
+
28
+ if ( ! branchState || ( ! isAhead && ! isBehind ) ) {
27
29
return null ;
28
30
}
29
31
30
- let action : 'pull' | 'push' | 'sync' = 'sync' ;
31
- let icon = 'codicon codicon-repo-sync' ;
32
- let label = 'Fetch' ;
33
- let tooltip ;
32
+ let action : 'pull' | 'push' ;
33
+ let icon : string ;
34
+ let label : string ;
35
+ let tooltip : ReactNode ;
34
36
35
37
const branchPrefix = (
36
38
< >
@@ -68,7 +70,7 @@ export const SyncButton = ({
68
70
</ >
69
71
) ;
70
72
}
71
- } else if ( isAhead ) {
73
+ } else {
72
74
action = 'push' ;
73
75
icon = 'glicon glicon-repo-push' ;
74
76
label = 'Push' ;
@@ -83,7 +85,7 @@ export const SyncButton = ({
83
85
}
84
86
85
87
return (
86
- < span className = "button-group" >
88
+ < >
87
89
< GlTooltip placement = "bottom" >
88
90
< a
89
91
href = { createWebviewCommandLink ( `gitlens.graph.${ action } ` , state . webviewId , state . webviewInstanceId ) }
@@ -119,30 +121,21 @@ export const SyncButton = ({
119
121
</ div >
120
122
</ GlTooltip >
121
123
{ isAhead && isBehind && (
122
- < GlPopover className = "popover" placement = "bottom-start" trigger = "focus" arrow = { false } distance = { 0 } >
123
- < GlTooltip placement = "top" slot = "anchor" >
124
- < button type = "button" className = "action-button" aria-label = "Branch Actions" >
125
- < span
126
- className = "codicon codicon-chevron-down action-button__more"
127
- aria-hidden = "true"
128
- > </ span >
129
- </ button >
130
- < span slot = "content" > Branch Actions</ span >
131
- </ GlTooltip >
132
- < div slot = "content" >
133
- < MenuLabel > Branch actions</ MenuLabel >
134
- < MenuItem
135
- href = { createWebviewCommandLink (
136
- 'gitlens.graph.pushWithForce' ,
137
- state . webviewId ,
138
- state . webviewInstanceId ,
139
- ) }
140
- >
141
- Push (force)
142
- </ MenuItem >
143
- </ div >
144
- </ GlPopover >
124
+ < GlTooltip placement = "top" slot = "anchor" >
125
+ < a
126
+ href = { createWebviewCommandLink (
127
+ 'gitlens.graph.pushWithForce' ,
128
+ state . webviewId ,
129
+ state . webviewInstanceId ,
130
+ ) }
131
+ className = "action-button"
132
+ aria-label = "Push (force)"
133
+ >
134
+ < span className = "codicon codicon-repo-force-push" aria-hidden = "true" > </ span >
135
+ </ a >
136
+ < span slot = "content" > Push (force)</ span >
137
+ </ GlTooltip >
145
138
) }
146
- </ span >
139
+ </ >
147
140
) ;
148
141
} ;
0 commit comments