Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCM - history item group context menu #203712

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,18 @@
"when": "scmProvider == git"
}
],
"scm/incomingChanges/context": [
{
"command": "git.fetchRef",
"group": "1_modification@1",
"when": "scmProvider == git"
},
{
"command": "git.pullRef",
"group": "1_modification@2",
"when": "scmProvider == git"
}
],
"scm/incomingChanges/allChanges/context": [
{
"command": "git.viewAllChanges",
Expand All @@ -1878,6 +1890,13 @@
"when": "scmProvider == git"
}
],
"scm/outgoingChanges/context": [
{
"command": "git.pushRef",
"group": "1_modification@1",
"when": "scmProvider == git"
}
],
"scm/outgoingChanges/allChanges/context": [
{
"command": "git.viewAllChanges",
Expand Down
2 changes: 2 additions & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export class MenuId {
static readonly ProblemsPanelContext = new MenuId('ProblemsPanelContext');
static readonly SCMInputBox = new MenuId('SCMInputBox');
static readonly SCMIncomingChanges = new MenuId('SCMIncomingChanges');
static readonly SCMIncomingChangesContext = new MenuId('SCMIncomingChangesContext');
static readonly SCMOutgoingChanges = new MenuId('SCMOutgoingChanges');
static readonly SCMOutgoingChangesContext = new MenuId('SCMOutgoingChangesContext');
static readonly SCMIncomingChangesAllChangesContext = new MenuId('SCMIncomingChangesAllChangesContext');
static readonly SCMIncomingChangesHistoryItemContext = new MenuId('SCMIncomingChangesHistoryItemContext');
static readonly SCMOutgoingChangesAllChangesContext = new MenuId('SCMOutgoingChangesAllChangesContext');
Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/contrib/scm/browser/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,29 @@ export class SCMHistoryProviderMenus implements ISCMHistoryProviderMenus, IDispo
private _incomingHistoryItemGroupMenu: IMenu;
get incomingHistoryItemGroupMenu(): IMenu { return this._incomingHistoryItemGroupMenu; }

private _incomingHistoryItemGroupContextMenu: IMenu;
get incomingHistoryItemGroupContextMenu(): IMenu { return this._incomingHistoryItemGroupContextMenu; }

private _outgoingHistoryItemGroupMenu: IMenu;
get outgoingHistoryItemGroupMenu(): IMenu { return this._outgoingHistoryItemGroupMenu; }

private _outgoingHistoryItemGroupContextMenu: IMenu;
get outgoingHistoryItemGroupContextMenu(): IMenu { return this._outgoingHistoryItemGroupContextMenu; }

constructor(
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IMenuService private readonly menuService: IMenuService) {
this._incomingHistoryItemGroupMenu = this.menuService.createMenu(MenuId.SCMIncomingChanges, this.contextKeyService);
this.disposables.add(this._incomingHistoryItemGroupMenu);

this._incomingHistoryItemGroupContextMenu = this.menuService.createMenu(MenuId.SCMIncomingChangesContext, this.contextKeyService);
this.disposables.add(this._incomingHistoryItemGroupContextMenu);

this._outgoingHistoryItemGroupMenu = this.menuService.createMenu(MenuId.SCMOutgoingChanges, this.contextKeyService);
this.disposables.add(this._outgoingHistoryItemGroupMenu);

this._outgoingHistoryItemGroupContextMenu = this.menuService.createMenu(MenuId.SCMOutgoingChangesContext, this.contextKeyService);
this.disposables.add(this._outgoingHistoryItemGroupContextMenu);
}

getHistoryItemMenu(historyItem: SCMHistoryItemTreeElement): IMenu {
Expand Down
15 changes: 12 additions & 3 deletions src/vs/workbench/contrib/scm/browser/scmViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3006,11 +3006,13 @@ export class SCMViewPane extends ViewPane {
const element = e.element;
let context: any = element;
let actions: IAction[] = [];
let actionRunner: IActionRunner = new RepositoryPaneActionRunner(() => this.getSelectedResources());

if (isSCMRepository(element)) {
const menus = this.scmViewService.menus.getRepositoryMenus(element.provider);
const menu = menus.repositoryContextMenu;
context = element.provider;
actionRunner = new RepositoryActionRunner(() => this.getSelectedRepositories());
actions = collectContextMenuActions(menu);
} else if (isSCMInput(element) || isSCMActionButton(element)) {
// noop
Expand All @@ -3032,11 +3034,18 @@ export class SCMViewPane extends ViewPane {
const menu = menus.getResourceFolderMenu(element.context);
actions = collectContextMenuActions(menu);
}
} else if (isSCMHistoryItemGroupTreeElement(element)) {
const menus = this.scmViewService.menus.getRepositoryMenus(element.repository.provider);
const menu = element.direction === 'incoming' ?
menus.historyProviderMenu?.incomingHistoryItemGroupContextMenu :
menus.historyProviderMenu?.outgoingHistoryItemGroupContextMenu;

if (menu) {
actionRunner = new HistoryItemGroupActionRunner();
createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, actions);
}
}

const actionRunner = isSCMRepository(element) ?
new RepositoryActionRunner(() => this.getSelectedRepositories()) :
new RepositoryPaneActionRunner(() => this.getSelectedResources());
actionRunner.onWillRun(() => this.tree.domFocus());

this.contextMenuService.showContextMenu({
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/scm/common/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { ISCMRepository } from 'vs/workbench/contrib/scm/common/scm';

export interface ISCMHistoryProviderMenus {
readonly incomingHistoryItemGroupMenu: IMenu;
readonly incomingHistoryItemGroupContextMenu: IMenu;
readonly outgoingHistoryItemGroupMenu: IMenu;
readonly outgoingHistoryItemGroupContextMenu: IMenu;

getHistoryItemMenu(historyItem: SCMHistoryItemTreeElement): IMenu;
}
Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/services/actions/common/menusExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,24 @@ const apiMenus: IAPIMenu[] = [
description: localize('menus.incomingChanges', "The Source Control incoming changes menu"),
proposed: 'contribSourceControlHistoryItemGroupMenu'
},
{
key: 'scm/incomingChanges/context',
id: MenuId.SCMIncomingChangesContext,
description: localize('menus.incomingChangesContext', "The Source Control incoming changes context menu"),
proposed: 'contribSourceControlHistoryItemGroupMenu'
},
{
key: 'scm/outgoingChanges',
id: MenuId.SCMOutgoingChanges,
description: localize('menus.outgoingChanges', "The Source Control outgoing changes menu"),
proposed: 'contribSourceControlHistoryItemGroupMenu'
},
{
key: 'scm/outgoingChanges/context',
id: MenuId.SCMOutgoingChangesContext,
description: localize('menus.outgoingChangesContext', "The Source Control outgoing changes context menu"),
proposed: 'contribSourceControlHistoryItemGroupMenu'
},
{
key: 'scm/incomingChanges/allChanges/context',
id: MenuId.SCMIncomingChangesAllChangesContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
*--------------------------------------------------------------------------------------------*/

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