瀏覽代碼

App context menu opens to WIP row on graph (#2458)

* App context menu opens to WIP row on graph

* Use commit context value

* Remove unneeded fallback logic
main
Ramin Tadayon 1 年之前
committed by GitHub
父節點
當前提交
805c49b723
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 2 個文件被更改,包括 59 次插入3 次删除
  1. +22
    -1
      package.json
  2. +37
    -2
      src/plus/webviews/graph/graphWebview.ts

+ 22
- 1
package.json 查看文件

@ -6581,6 +6581,11 @@
"icon": "$(eye)"
},
{
"command": "gitlens.graph.openSCM",
"title": "Open Source Control",
"category": "GitLens"
},
{
"command": "gitlens.graph.openCommitOnRemote",
"title": "Open Commit on Remote",
"category": "GitLens",
@ -6619,6 +6624,12 @@
"icon": "$(discard)"
},
{
"command": "gitlens.graph.saveStash",
"title": "Stash All Changes",
"category": "GitLens",
"icon": "$(gitlens-stash-save)"
},
{
"command": "gitlens.graph.applyStash",
"title": "Apply Stash",
"category": "GitLens",
@ -11328,10 +11339,15 @@
},
{
"command": "gitlens.graph.showInDetailsView",
"when": "webviewItem =~ /gitlens:(commit|stash)\\b/",
"when": "webviewItem =~ /gitlens:(commit|stash|wip)\\b/",
"group": "3_gitlens_explore@0"
},
{
"command": "gitlens.graph.openSCM",
"when": "webviewItem == gitlens:wip",
"group": "3_gitlens_explore@1"
},
{
"command": "gitlens.graph.openCommitOnRemote",
"when": "gitlens:hasRemotes && webviewItem =~ /gitlens:commit\\b/",
"group": "3_gitlens_explore@2",
@ -11353,6 +11369,11 @@
"group": "1_gitlens_actions@2"
},
{
"command": "gitlens.graph.saveStash",
"when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem == gitlens:wip",
"group": "1_gitlens_actions@3"
},
{
"command": "gitlens.graph.switchToTag",
"when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:tag\\b/",
"group": "1_gitlens_actions@1"

+ 37
- 2
src/plus/webviews/graph/graphWebview.ts 查看文件

@ -30,7 +30,7 @@ import { parseCommandContext } from '../../../commands/base';
import { GitActions } from '../../../commands/gitCommands.actions';
import type { Config } from '../../../configuration';
import { configuration } from '../../../configuration';
import { Commands, ContextKeys, CoreGitCommands, GlyphChars } from '../../../constants';
import { Commands, ContextKeys, CoreCommands, CoreGitCommands, GlyphChars } from '../../../constants';
import type { Container } from '../../../container';
import { getContext, onDidChangeContext } from '../../../context';
import { PlusFeatures } from '../../../features';
@ -53,7 +53,13 @@ import type { GitSearch } from '../../../git/search';
import { getSearchQueryComparisonKey } from '../../../git/search';
import { RepositoryPicker } from '../../../quickpicks/repositoryPicker';
import type { StoredGraphFilters, StoredGraphIncludeOnlyRef } from '../../../storage';
import { executeActionCommand, executeCommand, executeCoreGitCommand, registerCommand } from '../../../system/command';
import {
executeActionCommand,
executeCommand,
executeCoreCommand,
executeCoreGitCommand,
registerCommand,
} from '../../../system/command';
import { gate } from '../../../system/decorators/gate';
import { debug } from '../../../system/decorators/log';
import type { Deferrable } from '../../../system/function';
@ -347,6 +353,7 @@ export class GraphWebview extends WebviewBase {
registerCommand('gitlens.graph.copyRemoteCommitUrl', item => this.openCommitOnRemote(item, true), this),
registerCommand('gitlens.graph.showInDetailsView', this.openInDetailsView, this),
registerCommand('gitlens.graph.openCommitOnRemote', this.openCommitOnRemote, this),
registerCommand('gitlens.graph.openSCM', this.openSCM, this),
registerCommand('gitlens.graph.rebaseOntoCommit', this.rebase, this),
registerCommand('gitlens.graph.resetCommit', this.resetCommit, this),
registerCommand('gitlens.graph.resetToCommit', this.resetToCommit, this),
@ -354,6 +361,7 @@ export class GraphWebview extends WebviewBase {
registerCommand('gitlens.graph.switchToCommit', this.switchTo, this),
registerCommand('gitlens.graph.undoCommit', this.undoCommit, this),
registerCommand('gitlens.graph.saveStash', this.saveStash, this),
registerCommand('gitlens.graph.applyStash', this.applyStash, this),
registerCommand('gitlens.graph.deleteStash', this.deleteStash, this),
@ -1611,6 +1619,17 @@ export class GraphWebview extends WebviewBase {
added: workingTreeStatus?.added ?? 0,
deleted: workingTreeStatus?.deleted ?? 0,
modified: workingTreeStatus?.changed ?? 0,
context: serializeWebviewItemContext<GraphItemContext>({
webviewItem: 'gitlens:wip',
webviewItemValue: {
type: 'commit',
ref: this.getRevisionReference(
this.repository.path,
GitRevision.uncommitted,
GitGraphRowType.Working,
)!,
},
}),
};
}
@ -2015,6 +2034,14 @@ export class GraphWebview extends WebviewBase {
}
@debug()
private openSCM(item?: GraphItemContext) {
const ref = this.getGraphItemRef(item, 'revision');
if (ref == null) return Promise.resolve();
return executeCoreCommand(CoreCommands.ShowSCM);
}
@debug()
private openCommitOnRemote(item?: GraphItemContext, clipboard?: boolean) {
const ref = this.getGraphItemRef(item, 'revision');
if (ref == null) return Promise.resolve();
@ -2126,6 +2153,14 @@ export class GraphWebview extends WebviewBase {
}
@debug()
private saveStash(item?: GraphItemContext) {
const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve();
return GitActions.Stash.push(ref.repoPath);
}
@debug()
private applyStash(item?: GraphItemContext) {
const ref = this.getGraphItemRef(item, 'stash');
if (ref == null) return Promise.resolve();

Loading…
取消
儲存