Browse Source

Adds push, pull, fetch, swtich commands to graph

Adds "Copy" command to many items on the graph
main
Eric Amodio 2 years ago
parent
commit
79cde8f4ca
3 changed files with 113 additions and 55 deletions
  1. +75
    -40
      package.json
  2. +2
    -2
      src/constants.ts
  3. +36
    -13
      src/plus/webviews/graph/graphWebview.ts

+ 75
- 40
package.json View File

@ -4074,12 +4074,6 @@
"icon": "$(gitlens-graph)"
},
{
"command": "gitlens.refreshGraphPage",
"title": "Refresh",
"category": "GitLens",
"icon": "$(refresh)"
},
{
"command": "gitlens.showSettingsPage",
"title": "Open Settings",
"category": "GitLens",
@ -6293,6 +6287,36 @@
"category": "GitLens"
},
{
"command": "gitlens.graph.push",
"title": "Push",
"category": "GitLens",
"icon": "$(arrow-up)"
},
{
"command": "gitlens.graph.pull",
"title": "Pull",
"category": "GitLens",
"icon": "$(arrow-down)"
},
{
"command": "gitlens.graph.fetch",
"title": "Fetch",
"category": "GitLens",
"icon": "$(sync)"
},
{
"command": "gitlens.graph.switchToAnotherBranch",
"title": "Switch to Another Branch...",
"category": "GitLens",
"icon": "$(gitlens-switch)"
},
{
"command": "gitlens.graph.refresh",
"title": "Refresh",
"category": "GitLens",
"icon": "$(refresh)"
},
{
"command": "gitlens.graph.copyRemoteBranchUrl",
"title": "Copy Remote Branch Url",
"category": "GitLens",
@ -6337,12 +6361,6 @@
"category": "GitLens"
},
{
"command": "gitlens.graph.switchToAnotherBranch",
"title": "Switch to Another Branch...",
"category": "GitLens",
"icon": "$(gitlens-switch)"
},
{
"command": "gitlens.graph.switchToBranch",
"title": "Switch to Branch...",
"category": "GitLens",
@ -6489,12 +6507,6 @@
"icon": "$(globe)"
},
{
"command": "gitlens.graph.copyRemotePullRequestUrl",
"title": "Copy Pull Request Url",
"category": "GitLens",
"icon": "$(copy)"
},
{
"command": "gitlens.graph.compareAncestryWithWorking",
"title": "Compare Ancestry with Working Tree",
"category": "GitLens"
@ -6817,10 +6829,6 @@
"when": "false"
},
{
"command": "gitlens.refreshGraphPage",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#views",
"when": "false"
},
@ -8357,6 +8365,26 @@
"when": "false"
},
{
"command": "gitlens.graph.push",
"when": "false"
},
{
"command": "gitlens.graph.pull",
"when": "false"
},
{
"command": "gitlens.graph.fetch",
"when": "false"
},
{
"command": "gitlens.graph.switchToAnotherBranch",
"when": "false"
},
{
"command": "gitlens.graph.refresh",
"when": "false"
},
{
"command": "gitlens.graph.copyRemoteBranchUrl",
"when": "false"
},
@ -8389,10 +8417,6 @@
"when": "false"
},
{
"command": "gitlens.graph.switchToAnotherBranch",
"when": "false"
},
{
"command": "gitlens.graph.switchToBranch",
"when": "false"
},
@ -8497,10 +8521,6 @@
"when": "false"
},
{
"command": "gitlens.graph.copyRemotePullRequestUrl",
"when": "false"
},
{
"command": "gitlens.graph.compareAncestryWithWorking",
"when": "false"
},
@ -8757,13 +8777,33 @@
"group": "navigation@-99"
},
{
"command": "gitlens.refreshGraphPage",
"when": "gitlens:graphPage:focused",
"command": "gitlens.graph.push",
"when": "gitlens:graph:focused && gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
"group": "navigation@-103"
},
{
"command": "gitlens.graph.pull",
"when": "gitlens:graph:focused && gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
"group": "navigation@-102"
},
{
"command": "gitlens.graph.fetch",
"when": "gitlens:graph:focused && gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
"group": "navigation@-101"
},
{
"command": "gitlens.graph.switchToAnotherBranch",
"when": "gitlens:graph:focused && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
"group": "navigation@-100"
},
{
"command": "gitlens.graph.refresh",
"when": "gitlens:graph:focused",
"group": "navigation@-99"
},
{
"command": "gitlens.showSettingsPage#commit-graph",
"when": "gitlens:graphPage:focused",
"when": "gitlens:graph:focused",
"group": "navigation@-98"
}
],
@ -11164,15 +11204,10 @@
},
{
"command": "gitlens.graph.openPullRequestOnRemote",
"when": "webviewItem =~ /gitlens:graph:pullrequest\\b/",
"when": "webviewItem =~ /gitlens:pullrequest\\b/",
"group": "1_gitlens_actions@1"
},
{
"command": "gitlens.graph.copyRemotePullRequestUrl",
"when": "webviewItem =~ /gitlens:graph:pullrequest\\b/",
"group": "7_gitlens_cutcopypaste@1"
},
{
"command": "gitlens.graph.compareWithUpstream",
"when": "!gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+tracking\\b)/",
"group": "4_gitlens_compare@1"
@ -11199,7 +11234,7 @@
},
{
"command": "gitlens.graph.copy",
"when": "webviewItem =~ /gitlens:contributor\\b/",
"when": "webviewItem =~ /gitlens:(branch|commit|contributor|pullrequest|stash|tag)\\b/",
"group": "7_gitlens_cutcopypaste@1"
},
{

+ 2
- 2
src/constants.ts View File

@ -152,7 +152,7 @@ export const enum Commands {
PlusStartPreviewTrial = 'gitlens.plus.startPreviewTrial',
PlusValidate = 'gitlens.plus.validate',
QuickOpenFileHistory = 'gitlens.quickOpenFileHistory',
RefreshGraphPage = 'gitlens.refreshGraphPage',
RefreshGraph = 'gitlens.graph.refresh',
RefreshHover = 'gitlens.refreshHover',
RefreshTimelinePage = 'gitlens.refreshTimelinePage',
ResetAvatarCache = 'gitlens.resetAvatarCache',
@ -250,7 +250,7 @@ export const enum ContextKeys {
DisabledToggleCodeLens = 'gitlens:disabledToggleCodeLens',
Disabled = 'gitlens:disabled',
Enabled = 'gitlens:enabled',
GraphPageFocused = 'gitlens:graphPage:focused',
GraphFocused = 'gitlens:graph:focused',
HasConnectedRemotes = 'gitlens:hasConnectedRemotes',
HasRemotes = 'gitlens:hasRemotes',
HasRichRemotes = 'gitlens:hasRichRemotes',

+ 36
- 13
src/plus/webviews/graph/graphWebview.ts View File

@ -312,7 +312,13 @@ export class GraphWebview extends WebviewBase {
protected override registerCommands(): Disposable[] {
return [
registerCommand(Commands.RefreshGraphPage, () => this.refresh(true)),
registerCommand(Commands.RefreshGraph, () => this.refresh(true)),
registerCommand('gitlens.graph.push', this.push, this),
registerCommand('gitlens.graph.pull', this.pull, this),
registerCommand('gitlens.graph.fetch', this.fetch, this),
registerCommand('gitlens.graph.switchToAnotherBranch', this.switchToAnother, this),
registerCommand('gitlens.graph.createBranch', this.createBranch, this),
registerCommand('gitlens.graph.deleteBranch', this.deleteBranch, this),
registerCommand('gitlens.graph.copyRemoteBranchUrl', item => this.openBranchOnRemote(item, true), this),
@ -322,7 +328,6 @@ export class GraphWebview extends WebviewBase {
registerCommand('gitlens.graph.rebaseOntoUpstream', this.rebaseToRemote, this),
registerCommand('gitlens.graph.renameBranch', this.renameBranch, this),
registerCommand('gitlens.graph.switchToAnotherBranch', this.switchToAnother, this),
registerCommand('gitlens.graph.switchToBranch', this.switchTo, this),
registerCommand('gitlens.graph.hideLocalBranch', this.hideRef, this),
@ -353,11 +358,6 @@ export class GraphWebview extends WebviewBase {
registerCommand('gitlens.graph.createPullRequest', this.createPullRequest, this),
registerCommand('gitlens.graph.openPullRequestOnRemote', this.openPullRequestOnRemote, this),
registerCommand(
'gitlens.graph.copyRemotePullRequestUrl',
item => this.openPullRequestOnRemote(item, true),
this,
),
registerCommand('gitlens.graph.compareWithUpstream', this.compareWithUpstream, this),
registerCommand('gitlens.graph.compareWithHead', this.compareHeadWith, this),
@ -436,7 +436,7 @@ export class GraphWebview extends WebviewBase {
protected override onFocusChanged(focused: boolean): void {
if (focused) {
// If we are becoming focused, delay it a bit to give the UI time to update
setTimeout(() => void setContext(ContextKeys.GraphPageFocused, focused), 0);
setTimeout(() => void setContext(ContextKeys.GraphFocused, focused), 0);
if (this.selection != null) {
void GitActions.Commit.showDetailsView(this.selection[0], {
@ -449,7 +449,7 @@ export class GraphWebview extends WebviewBase {
return;
}
void setContext(ContextKeys.GraphPageFocused, focused);
void setContext(ContextKeys.GraphFocused, focused);
}
protected override onVisibilityChanged(visible: boolean): void {
@ -669,7 +669,7 @@ export class GraphWebview extends WebviewBase {
state: pr.state,
url: pr.url,
context: serializeWebviewItemContext<GraphItemContext>({
webviewItem: 'gitlens:graph:pullrequest',
webviewItem: 'gitlens:pullrequest',
webviewItemValue: {
type: 'pullrequest',
id: pr.id,
@ -1469,6 +1469,21 @@ export class GraphWebview extends WebviewBase {
}
@debug()
private fetch() {
void GitActions.fetch(this.repository);
}
@debug()
private pull() {
void GitActions.pull(this.repository);
}
@debug()
private push() {
void GitActions.push(this.repository);
}
@debug()
private createBranch(item: GraphItemContext) {
if (isGraphItemRefContext(item)) {
const { ref } = item.webviewItemValue;
@ -1563,9 +1578,17 @@ export class GraphWebview extends WebviewBase {
@debug()
private async copy(item: GraphItemContext) {
if (isGraphItemTypedContext(item, 'contributor')) {
if (isGraphItemRefContext(item)) {
const { ref } = item.webviewItemValue;
await env.clipboard.writeText(
ref.refType === 'revision' && ref.message ? `${ref.name}: ${ref.message}` : ref.name,
);
} else if (isGraphItemTypedContext(item, 'contributor')) {
const { name, email } = item.webviewItemValue;
await env.clipboard.writeText(`${name}${email ? ` <${email}>` : ''}`);
} else if (isGraphItemTypedContext(item, 'pullrequest')) {
const { url } = item.webviewItemValue;
await env.clipboard.writeText(url);
}
return Promise.resolve();
@ -1707,13 +1730,13 @@ export class GraphWebview extends WebviewBase {
}
@debug()
private switchToAnother(item: GraphItemContext) {
private switchToAnother(item: GraphItemContext | unknown) {
if (isGraphItemRefContext(item)) {
const { ref } = item.webviewItemValue;
return GitActions.switchTo(ref.repoPath);
}
return Promise.resolve();
return GitActions.switchTo(this._repository);
}
@debug()

Loading…
Cancel
Save