Skip to content

Commit f6e080e

Browse files
committed
Updates graph force push button
1 parent 1772745 commit f6e080e

File tree

3 files changed

+32
-40
lines changed

3 files changed

+32
-40
lines changed

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import {
6565
} from '../../../../plus/webviews/graph/protocol';
6666
import { createCommandLink } from '../../../../system/commands';
6767
import { filterMap, first, groupByFilterMap, join } from '../../../../system/iterable';
68-
import { pluralize } from '../../../../system/string';
6968
import { createWebviewCommandLink } from '../../../../system/webview';
7069
import type { IpcNotification } from '../../../protocol';
7170
import { DidChangeHostWindowFocusNotification } from '../../../protocol';

src/webviews/apps/plus/graph/actions/gitActionsButtons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import type { BranchState, State } from '../../../../../plus/webviews/graph/protocol';
33
import { fromNow } from '../../../../../system/date';
44
import { FetchButton } from './fetchButton';
5-
import { SyncButton } from './syncButton';
5+
import { PushPullButton } from './pushPullButton';
66

77
export const GitActionsButtons = ({
88
branchState,
@@ -22,7 +22,7 @@ export const GitActionsButtons = ({
2222

2323
return (
2424
<>
25-
<SyncButton
25+
<PushPullButton
2626
branchState={branchState}
2727
state={state}
2828
fetchedText={fetchedText}

src/webviews/apps/plus/graph/actions/syncButton.tsx renamed to src/webviews/apps/plus/graph/actions/pushPullButton.tsx

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import React from 'react';
33
import type { BranchState, State } from '../../../../../plus/webviews/graph/protocol';
44
import { pluralize } from '../../../../../system/string';
55
import { createWebviewCommandLink } from '../../../../../system/webview';
6-
import { MenuItem, MenuLabel } from '../../../shared/components/menu/react';
7-
import { GlPopover } from '../../../shared/components/overlays/popover.react';
86
import { GlTooltip } from '../../../shared/components/overlays/tooltip.react';
97

10-
export const SyncButton = ({
8+
export const PushPullButton = ({
119
branchState,
1210
state,
1311
fetchedText,
@@ -20,17 +18,21 @@ export const SyncButton = ({
2018
branchName: string | undefined;
2119
remote: ReactNode;
2220
}) => {
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)) {
2729
return null;
2830
}
2931

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;
3436

3537
const branchPrefix = (
3638
<>
@@ -68,7 +70,7 @@ export const SyncButton = ({
6870
</>
6971
);
7072
}
71-
} else if (isAhead) {
73+
} else {
7274
action = 'push';
7375
icon = 'glicon glicon-repo-push';
7476
label = 'Push';
@@ -83,7 +85,7 @@ export const SyncButton = ({
8385
}
8486

8587
return (
86-
<span className="button-group">
88+
<>
8789
<GlTooltip placement="bottom">
8890
<a
8991
href={createWebviewCommandLink(`gitlens.graph.${action}`, state.webviewId, state.webviewInstanceId)}
@@ -119,30 +121,21 @@ export const SyncButton = ({
119121
</div>
120122
</GlTooltip>
121123
{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>
145138
)}
146-
</span>
139+
</>
147140
);
148141
};

0 commit comments

Comments
 (0)