Skip to content

Commit 837b74c

Browse files
authored
SCM - history item group context menu (microsoft#203712)
1 parent 88f74b7 commit 837b74c

File tree

7 files changed

+61
-3
lines changed

7 files changed

+61
-3
lines changed

extensions/git/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,18 @@
18571857
"when": "scmProvider == git"
18581858
}
18591859
],
1860+
"scm/incomingChanges/context": [
1861+
{
1862+
"command": "git.fetchRef",
1863+
"group": "1_modification@1",
1864+
"when": "scmProvider == git"
1865+
},
1866+
{
1867+
"command": "git.pullRef",
1868+
"group": "1_modification@2",
1869+
"when": "scmProvider == git"
1870+
}
1871+
],
18601872
"scm/incomingChanges/allChanges/context": [
18611873
{
18621874
"command": "git.viewAllChanges",
@@ -1878,6 +1890,13 @@
18781890
"when": "scmProvider == git"
18791891
}
18801892
],
1893+
"scm/outgoingChanges/context": [
1894+
{
1895+
"command": "git.pushRef",
1896+
"group": "1_modification@1",
1897+
"when": "scmProvider == git"
1898+
}
1899+
],
18811900
"scm/outgoingChanges/allChanges/context": [
18821901
{
18831902
"command": "git.viewAllChanges",

src/vs/platform/actions/common/actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export class MenuId {
108108
static readonly ProblemsPanelContext = new MenuId('ProblemsPanelContext');
109109
static readonly SCMInputBox = new MenuId('SCMInputBox');
110110
static readonly SCMIncomingChanges = new MenuId('SCMIncomingChanges');
111+
static readonly SCMIncomingChangesContext = new MenuId('SCMIncomingChangesContext');
111112
static readonly SCMOutgoingChanges = new MenuId('SCMOutgoingChanges');
113+
static readonly SCMOutgoingChangesContext = new MenuId('SCMOutgoingChangesContext');
112114
static readonly SCMIncomingChangesAllChangesContext = new MenuId('SCMIncomingChangesAllChangesContext');
113115
static readonly SCMIncomingChangesHistoryItemContext = new MenuId('SCMIncomingChangesHistoryItemContext');
114116
static readonly SCMOutgoingChangesAllChangesContext = new MenuId('SCMOutgoingChangesAllChangesContext');

src/vs/workbench/contrib/scm/browser/menus.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,29 @@ export class SCMHistoryProviderMenus implements ISCMHistoryProviderMenus, IDispo
261261
private _incomingHistoryItemGroupMenu: IMenu;
262262
get incomingHistoryItemGroupMenu(): IMenu { return this._incomingHistoryItemGroupMenu; }
263263

264+
private _incomingHistoryItemGroupContextMenu: IMenu;
265+
get incomingHistoryItemGroupContextMenu(): IMenu { return this._incomingHistoryItemGroupContextMenu; }
266+
264267
private _outgoingHistoryItemGroupMenu: IMenu;
265268
get outgoingHistoryItemGroupMenu(): IMenu { return this._outgoingHistoryItemGroupMenu; }
266269

270+
private _outgoingHistoryItemGroupContextMenu: IMenu;
271+
get outgoingHistoryItemGroupContextMenu(): IMenu { return this._outgoingHistoryItemGroupContextMenu; }
272+
267273
constructor(
268274
@IContextKeyService private readonly contextKeyService: IContextKeyService,
269275
@IMenuService private readonly menuService: IMenuService) {
270276
this._incomingHistoryItemGroupMenu = this.menuService.createMenu(MenuId.SCMIncomingChanges, this.contextKeyService);
271277
this.disposables.add(this._incomingHistoryItemGroupMenu);
272278

279+
this._incomingHistoryItemGroupContextMenu = this.menuService.createMenu(MenuId.SCMIncomingChangesContext, this.contextKeyService);
280+
this.disposables.add(this._incomingHistoryItemGroupContextMenu);
281+
273282
this._outgoingHistoryItemGroupMenu = this.menuService.createMenu(MenuId.SCMOutgoingChanges, this.contextKeyService);
274283
this.disposables.add(this._outgoingHistoryItemGroupMenu);
284+
285+
this._outgoingHistoryItemGroupContextMenu = this.menuService.createMenu(MenuId.SCMOutgoingChangesContext, this.contextKeyService);
286+
this.disposables.add(this._outgoingHistoryItemGroupContextMenu);
275287
}
276288

277289
getHistoryItemMenu(historyItem: SCMHistoryItemTreeElement): IMenu {

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,11 +3006,13 @@ export class SCMViewPane extends ViewPane {
30063006
const element = e.element;
30073007
let context: any = element;
30083008
let actions: IAction[] = [];
3009+
let actionRunner: IActionRunner = new RepositoryPaneActionRunner(() => this.getSelectedResources());
30093010

30103011
if (isSCMRepository(element)) {
30113012
const menus = this.scmViewService.menus.getRepositoryMenus(element.provider);
30123013
const menu = menus.repositoryContextMenu;
30133014
context = element.provider;
3015+
actionRunner = new RepositoryActionRunner(() => this.getSelectedRepositories());
30143016
actions = collectContextMenuActions(menu);
30153017
} else if (isSCMInput(element) || isSCMActionButton(element)) {
30163018
// noop
@@ -3032,11 +3034,18 @@ export class SCMViewPane extends ViewPane {
30323034
const menu = menus.getResourceFolderMenu(element.context);
30333035
actions = collectContextMenuActions(menu);
30343036
}
3037+
} else if (isSCMHistoryItemGroupTreeElement(element)) {
3038+
const menus = this.scmViewService.menus.getRepositoryMenus(element.repository.provider);
3039+
const menu = element.direction === 'incoming' ?
3040+
menus.historyProviderMenu?.incomingHistoryItemGroupContextMenu :
3041+
menus.historyProviderMenu?.outgoingHistoryItemGroupContextMenu;
3042+
3043+
if (menu) {
3044+
actionRunner = new HistoryItemGroupActionRunner();
3045+
createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, actions);
3046+
}
30353047
}
30363048

3037-
const actionRunner = isSCMRepository(element) ?
3038-
new RepositoryActionRunner(() => this.getSelectedRepositories()) :
3039-
new RepositoryPaneActionRunner(() => this.getSelectedResources());
30403049
actionRunner.onWillRun(() => this.tree.domFocus());
30413050

30423051
this.contextMenuService.showContextMenu({

src/vs/workbench/contrib/scm/common/history.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { ISCMRepository } from 'vs/workbench/contrib/scm/common/scm';
1111

1212
export interface ISCMHistoryProviderMenus {
1313
readonly incomingHistoryItemGroupMenu: IMenu;
14+
readonly incomingHistoryItemGroupContextMenu: IMenu;
1415
readonly outgoingHistoryItemGroupMenu: IMenu;
16+
readonly outgoingHistoryItemGroupContextMenu: IMenu;
1517

1618
getHistoryItemMenu(historyItem: SCMHistoryItemTreeElement): IMenu;
1719
}

src/vs/workbench/services/actions/common/menusExtensionPoint.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,24 @@ const apiMenus: IAPIMenu[] = [
162162
description: localize('menus.incomingChanges', "The Source Control incoming changes menu"),
163163
proposed: 'contribSourceControlHistoryItemGroupMenu'
164164
},
165+
{
166+
key: 'scm/incomingChanges/context',
167+
id: MenuId.SCMIncomingChangesContext,
168+
description: localize('menus.incomingChangesContext', "The Source Control incoming changes context menu"),
169+
proposed: 'contribSourceControlHistoryItemGroupMenu'
170+
},
165171
{
166172
key: 'scm/outgoingChanges',
167173
id: MenuId.SCMOutgoingChanges,
168174
description: localize('menus.outgoingChanges', "The Source Control outgoing changes menu"),
169175
proposed: 'contribSourceControlHistoryItemGroupMenu'
170176
},
177+
{
178+
key: 'scm/outgoingChanges/context',
179+
id: MenuId.SCMOutgoingChangesContext,
180+
description: localize('menus.outgoingChangesContext', "The Source Control outgoing changes context menu"),
181+
proposed: 'contribSourceControlHistoryItemGroupMenu'
182+
},
171183
{
172184
key: 'scm/incomingChanges/allChanges/context',
173185
id: MenuId.SCMIncomingChangesAllChangesContext,

src/vscode-dts/vscode.proposed.contribSourceControlHistoryItemGroupMenu.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
// empty placeholder declaration for the `scm/incomingChanges`-menu contribution point
7+
// empty placeholder declaration for the `scm/incomingChanges/context`-menu contribution point
78
// empty placeholder declaration for the `scm/outgoingChanges`-menu contribution point
9+
// empty placeholder declaration for the `scm/outgoingChanges/context`-menu contribution point
810
// https://github.com/microsoft/vscode/issues/201997

0 commit comments

Comments
 (0)