From 7d9aa2a7c1a33815511c7459428ca1ad9e6f33a7 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 26 Mar 2023 01:32:11 -0400 Subject: [PATCH] Adds experimental support to show the Graph in a view - Controlled by the `gitlens.graph.experimental.location` setting --- CHANGELOG.md | 7 + package.json | 340 ++++++++++++--------- src/commands/showView.ts | 5 +- src/config.ts | 1 + src/constants.ts | 16 +- src/container.ts | 24 +- src/plus/webviews/graph/graphWebview.ts | 2 +- src/plus/webviews/graph/registration.ts | 54 ++-- src/plus/webviews/graph/statusbar.ts | 2 +- src/views/commitsView.ts | 2 +- src/webviews/apps/commitDetails/commitDetails.html | 2 +- src/webviews/apps/plus/graph/GraphWrapper.tsx | 123 ++++---- src/webviews/apps/plus/graph/graph.html | 6 +- src/webviews/apps/plus/graph/graph.scss | 27 +- .../apps/settings/partials/commit-graph.html | 2 +- src/webviews/webviewsController.ts | 18 ++ 16 files changed, 374 insertions(+), 257 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c005d8e..1189ffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Added + +- Adds experimental support to show the _Commit Graph_ in the side bar, secondary side bar, or panel + - Adds a `gitlens.graph.experimental.location` setting to specify the location in which the _Commit Graph_ will be shown + - `tab` - Shows the _Commit Graph_ in a tab in the editor area + - `view` - Shows the _Commit Graph_ in the side bar and can be dragged and dropped into any side bar, secondary side bar, or panel locations + ### Changed - Changes _Open Associated Pull Request_ command to support opening associated pull requests with the current branch or the HEAD commit if no branch association was found — closes [#2559](https://github.com/gitkraken/vscode-gitlens/issues/2559) diff --git a/package.json b/package.json index 7af24c6..010d980 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,20 @@ "onCommand:gitlens.plus.manage", "onCommand:gitlens.plus.purchase", "onCommand:gitlens.getStarted", - "onCommand:gitlens.showGraphPage", + "onCommand:gitlens.showBranchesView", + "onCommand:gitlens.showCommitDetailsView", + "onCommand:gitlens.showCommitsView", + "onCommand:gitlens.showContributorsView", + "onCommand:gitlens.showFileHistoryView", "onCommand:gitlens.showFocusPage", + "onCommand:gitlens.showGraph", + "onCommand:gitlens.showGraphPage", + "onCommand:gitlens.showGraphView", + "onCommand:gitlens.showHomeView", + "onCommand:gitlens.showLineHistoryView", + "onCommand:gitlens.showRemotesView", + "onCommand:gitlens.showRepositoriesView", + "onCommand:gitlens.showSearchAndCompareView", "onCommand:gitlens.showSettingsPage", "onCommand:gitlens.showSettingsPage#views", "onCommand:gitlens.showSettingsPage#autolinks", @@ -92,20 +104,10 @@ "onCommand:gitlens.showSettingsPage#tags-view", "onCommand:gitlens.showSettingsPage#worktrees-view", "onCommand:gitlens.showSettingsPage#commit-graph", - "onCommand:gitlens.showWelcomePage", - "onCommand:gitlens.showBranchesView", - "onCommand:gitlens.showCommitDetailsView", - "onCommand:gitlens.showCommitsView", - "onCommand:gitlens.showContributorsView", - "onCommand:gitlens.showFileHistoryView", - "onCommand:gitlens.showHomeView", - "onCommand:gitlens.showLineHistoryView", - "onCommand:gitlens.showRemotesView", - "onCommand:gitlens.showRepositoriesView", - "onCommand:gitlens.showSearchAndCompareView", "onCommand:gitlens.showStashesView", "onCommand:gitlens.showTagsView", "onCommand:gitlens.showTimelineView", + "onCommand:gitlens.showWelcomePage", "onCommand:gitlens.showWorktreesView", "onCommand:gitlens.compareWith", "onCommand:gitlens.compareHeadWith", @@ -2380,7 +2382,22 @@ "default": true, "markdownDescription": "Specifies whether to show the _Commit Graph_ in the status bar", "scope": "window", - "order": 100 + "order": 50 + }, + "gitlens.graph.experimental.location": { + "type": "string", + "default": "tab", + "enum": [ + "tab", + "view" + ], + "enumDescriptions": [ + "Shows the Commit Graph in an editor tab", + "Shows the Commit Graph in a view (side bar, panel, etc)" + ], + "markdownDescription": "Specifies the location in which the _Commit Graph_ will be shown", + "scope": "window", + "order": 99 }, "gitlens.graph.experimental.minimap.enabled": { "type": "boolean", @@ -4503,22 +4520,84 @@ "category": "GitLens" }, { + "command": "gitlens.showBranchesView", + "title": "Show Branches View", + "category": "GitLens" + }, + { + "command": "gitlens.showCommitDetailsView", + "title": "Show Commit Details View", + "category": "GitLens" + }, + { + "command": "gitlens.showCommitsView", + "title": "Show Commits View", + "category": "GitLens" + }, + { + "command": "gitlens.showContributorsView", + "title": "Show Contributors View", + "category": "GitLens" + }, + { + "command": "gitlens.showFileHistoryView", + "title": "Show File History View", + "category": "GitLens" + }, + { + "command": "gitlens.showFocusPage", + "title": "Show Focus View", + "category": "GitLens+", + "icon": "$(layers)" + }, + { + "command": "gitlens.showGraph", + "title": "Show Commit Graph", + "category": "GitLens+", + "icon": "$(gitlens-graph)" + }, + { "command": "gitlens.showGraphPage", "title": "Show Commit Graph", "category": "GitLens+", "icon": "$(gitlens-graph)" }, { + "command": "gitlens.showGraphView", + "title": "Show Commit Graph View", + "category": "GitLens+", + "icon": "$(gitlens-graph)" + }, + { + "command": "gitlens.showHomeView", + "title": "Show Home View", + "category": "GitLens" + }, + { "command": "gitlens.showInCommitGraph", "title": "Open in Commit Graph", "category": "GitLens+", "icon": "$(gitlens-graph)" }, { - "command": "gitlens.showFocusPage", - "title": "Show Focus View", - "category": "GitLens+", - "icon": "$(layers)" + "command": "gitlens.showLineHistoryView", + "title": "Show Line History View", + "category": "GitLens" + }, + { + "command": "gitlens.showRemotesView", + "title": "Show Remotes View", + "category": "GitLens" + }, + { + "command": "gitlens.showRepositoriesView", + "title": "Show Repositories View", + "category": "GitLens" + }, + { + "command": "gitlens.showSearchAndCompareView", + "title": "Show Search And Compare Commits View", + "category": "GitLens" }, { "command": "gitlens.showSettingsPage", @@ -4617,67 +4696,6 @@ "icon": "$(gitlens-history)" }, { - "command": "gitlens.refreshTimelinePage", - "title": "Refresh", - "category": "GitLens", - "icon": "$(refresh)" - }, - { - "command": "gitlens.showWelcomePage", - "title": "Welcome (Quick Setup)", - "category": "GitLens" - }, - { - "command": "gitlens.showBranchesView", - "title": "Show Branches View", - "category": "GitLens" - }, - { - "command": "gitlens.showCommitDetailsView", - "title": "Show Commit Details View", - "category": "GitLens" - }, - { - "command": "gitlens.showCommitsView", - "title": "Show Commits View", - "category": "GitLens" - }, - { - "command": "gitlens.showContributorsView", - "title": "Show Contributors View", - "category": "GitLens" - }, - { - "command": "gitlens.showFileHistoryView", - "title": "Show File History View", - "category": "GitLens" - }, - { - "command": "gitlens.showHomeView", - "title": "Show Home View", - "category": "GitLens" - }, - { - "command": "gitlens.showLineHistoryView", - "title": "Show Line History View", - "category": "GitLens" - }, - { - "command": "gitlens.showRemotesView", - "title": "Show Remotes View", - "category": "GitLens" - }, - { - "command": "gitlens.showRepositoriesView", - "title": "Show Repositories View", - "category": "GitLens" - }, - { - "command": "gitlens.showSearchAndCompareView", - "title": "Show Search And Compare Commits View", - "category": "GitLens" - }, - { "command": "gitlens.showStashesView", "title": "Show Stashes View", "category": "GitLens" @@ -4693,6 +4711,11 @@ "category": "GitLens+" }, { + "command": "gitlens.showWelcomePage", + "title": "Welcome (Quick Setup)", + "category": "GitLens" + }, + { "command": "gitlens.showWorktreesView", "title": "Show Worktrees View", "category": "GitLens+" @@ -6845,6 +6868,12 @@ "category": "GitLens" }, { + "command": "gitlens.focus.refresh", + "title": "Refresh", + "category": "GitLens", + "icon": "$(refresh)" + }, + { "command": "gitlens.graph.push", "title": "Push", "category": "GitLens", @@ -6903,12 +6932,6 @@ "icon": "$(copy)" }, { - "command": "gitlens.focus.refresh", - "title": "Refresh", - "category": "GitLens", - "icon": "$(refresh)" - }, - { "command": "gitlens.graph.copyRemoteBranchUrl", "title": "Copy Remote Branch URL", "category": "GitLens", @@ -7203,6 +7226,12 @@ "command": "gitlens.graph.columnChangesOff", "title": "Hide Changes", "category": "GitLens" + }, + { + "command": "gitlens.timeline.refresh", + "title": "Refresh", + "category": "GitLens", + "icon": "$(refresh)" } ], "icons": { @@ -7463,7 +7492,47 @@ "when": "gitlens:plus" }, { + "command": "gitlens.timeline.refresh", + "when": "false" + }, + { + "command": "gitlens.showBranchesView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showCommitDetailsView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showCommitsView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showContributorsView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showFileHistoryView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showFocusPage", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showGraph", + "when": "false" + }, + { "command": "gitlens.showGraphPage", + "when": "gitlens:enabled && config.gitlens.graph.experimental.location == tab" + }, + { + "command": "gitlens.showGraphView", + "when": "gitlens:enabled && config.gitlens.graph.experimental.location == view" + }, + { + "command": "gitlens.showHomeView", "when": "gitlens:enabled" }, { @@ -7471,7 +7540,19 @@ "when": "false" }, { - "command": "gitlens.showFocusPage", + "command": "gitlens.showLineHistoryView", + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" + }, + { + "command": "gitlens.showRemotesView", + "when": "gitlens:enabled" + }, + { + "command": "gitlens.showRepositoriesView", + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" + }, + { + "command": "gitlens.showSearchAndCompareView", "when": "gitlens:enabled" }, { @@ -7527,54 +7608,6 @@ "when": "false" }, { - "command": "gitlens.showTimelinePage", - "when": "gitlens:enabled && gitlens:activeFileStatus =~ /tracked/" - }, - { - "command": "gitlens.refreshTimelinePage", - "when": "false" - }, - { - "command": "gitlens.showBranchesView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showCommitDetailsView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showCommitsView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showContributorsView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showFileHistoryView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showHomeView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showLineHistoryView", - "when": "gitlens:enabled && !gitlens:hasVirtualFolders" - }, - { - "command": "gitlens.showRemotesView", - "when": "gitlens:enabled" - }, - { - "command": "gitlens.showRepositoriesView", - "when": "gitlens:enabled && !gitlens:hasVirtualFolders" - }, - { - "command": "gitlens.showSearchAndCompareView", - "when": "gitlens:enabled" - }, - { "command": "gitlens.showStashesView", "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, @@ -7583,6 +7616,10 @@ "when": "gitlens:enabled" }, { + "command": "gitlens.showTimelinePage", + "when": "gitlens:enabled && gitlens:activeFileStatus =~ /tracked/" + }, + { "command": "gitlens.showTimelineView", "when": "gitlens:enabled" }, @@ -9503,7 +9540,7 @@ "group": "navigation@100" }, { - "command": "gitlens.refreshTimelinePage", + "command": "gitlens.timeline.refresh", "when": "gitlens:webview:timeline:active", "group": "navigation@-99" }, @@ -9659,14 +9696,14 @@ ], "scm/sourceControl": [ { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "gitlens:enabled && config.gitlens.menus.scm.graph && gitlens:plus:enabled && scmProvider == git && scmProviderRootUri not in gitlens:plus:disallowedRepos", "group": "6_gitlens@1" } ], "scm/title": [ { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "gitlens:enabled && config.gitlens.menus.scmRepositoryInline.graph && gitlens:plus:enabled && scmProvider == git && scmProviderRootUri not in gitlens:plus:disallowedRepos", "group": "navigation@-1000" }, @@ -9676,7 +9713,7 @@ "group": "2_z_gitlens@1" }, { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "gitlens:enabled && config.gitlens.menus.scmRepository.graph && gitlens:plus:enabled && scmProvider == git && scmProviderRootUri not in gitlens:plus:disallowedRepos", "group": "2_z_gitlens@2" } @@ -9852,7 +9889,7 @@ "group": "navigation@10" }, { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "view =~ /^gitlens\\.views\\.commits/ && gitlens:plus:enabled", "group": "navigation@11" }, @@ -9922,7 +9959,7 @@ "group": "5_gitlens@2" }, { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "view =~ /^gitlens\\.views\\.commits/ && gitlens:plus:enabled", "group": "8_gitlens_toggles@0" }, @@ -10412,6 +10449,16 @@ "group": "5_gitlens@3" }, { + "command": "gitlens.graph.refresh", + "when": "view =~ /^gitlens\\.views\\.graph/", + "group": "navigation@-99" + }, + { + "command": "gitlens.showSettingsPage#commit-graph", + "when": "view =~ /^gitlens\\.views\\.graph/", + "group": "navigation@-98" + }, + { "command": "gitlens.showSettingsPage#branches-view", "when": "view =~ /^gitlens\\.views\\.branches/", "group": "9_gitlens@1" @@ -11286,7 +11333,7 @@ "group": "inline@99" }, { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "viewItem =~ /gitlens:repo-folder\\b/ && gitlens:plus:enabled", "group": "inline@100" }, @@ -11322,7 +11369,7 @@ "alt": "gitlens.copyRemoteRepositoryUrl" }, { - "command": "gitlens.showGraphPage", + "command": "gitlens.showGraph", "when": "viewItem =~ /gitlens:repo-folder\\b/ && gitlens:plus:enabled", "group": "3_gitlens_explore@1" }, @@ -13056,6 +13103,15 @@ "initialSize": 5 }, { + "type": "webview", + "id": "gitlens.views.graph", + "name": "Commit Graph", + "when": "!gitlens:disabled && gitlens:plus:enabled && config.gitlens.graph.experimental.location == view", + "contextualTitle": "GitLens", + "icon": "$(gitlens-graph)", + "visibility": "hidden" + }, + { "id": "gitlens.views.contributors", "name": "Contributors", "when": "!gitlens:disabled", @@ -13296,7 +13352,7 @@ { "id": "gitlens.plus.commitGraph", "title": "Commit Graph (new)", - "description": "The Commit Graph helps you to easily visualize branch structure and commit history.\n\n[Open Commit Graph](command:gitlens.showGraphPage)", + "description": "The Commit Graph helps you to easily visualize branch structure and commit history.\n\n[Open Commit Graph](command:gitlens.showGraph)", "media": { "markdown": "walkthroughs/plus/commit-graph.md" } diff --git a/src/commands/showView.ts b/src/commands/showView.ts index 53366c7..7f78a0a 100644 --- a/src/commands/showView.ts +++ b/src/commands/showView.ts @@ -13,6 +13,8 @@ export class ShowViewCommand extends Command { Commands.ShowCommitsView, Commands.ShowContributorsView, Commands.ShowFileHistoryView, + Commands.ShowGraphView, + Commands.ShowHomeView, Commands.ShowLineHistoryView, Commands.ShowRemotesView, Commands.ShowRepositoriesView, @@ -21,7 +23,6 @@ export class ShowViewCommand extends Command { Commands.ShowTagsView, Commands.ShowTimelineView, Commands.ShowWorktreesView, - Commands.ShowHomeView, ]); } @@ -43,6 +44,8 @@ export class ShowViewCommand extends Command { return this.container.fileHistoryView.show(); case Commands.ShowHomeView: return this.container.homeView.show(); + case Commands.ShowGraphView: + return this.container.graphView.show(); case Commands.ShowLineHistoryView: return this.container.lineHistoryView.show(); case Commands.ShowRemotesView: diff --git a/src/config.ts b/src/config.ts index 6e5f5f0..be36a5a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -417,6 +417,7 @@ export interface GraphConfig { defaultItemLimit: number; dimMergeCommits: boolean; experimental: { + location: 'tab' | 'view'; minimap: { enabled: boolean; additionalTypes: GraphMinimapTypes[]; diff --git a/src/constants.ts b/src/constants.ts index cd2274f..fe1e6d1 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -187,10 +187,10 @@ export const enum Commands { PlusStartPreviewTrial = 'gitlens.plus.startPreviewTrial', PlusValidate = 'gitlens.plus.validate', QuickOpenFileHistory = 'gitlens.quickOpenFileHistory', - RefreshGraph = 'gitlens.graph.refresh', RefreshFocus = 'gitlens.focus.refresh', + RefreshGraph = 'gitlens.graph.refresh', RefreshHover = 'gitlens.refreshHover', - RefreshTimelinePage = 'gitlens.refreshTimelinePage', + RefreshTimelinePage = 'gitlens.timeline.refresh', ResetAvatarCache = 'gitlens.resetAvatarCache', ResetOpenAIKey = 'gitlens.resetOpenAIKey', ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings', @@ -200,12 +200,17 @@ export const enum Commands { SearchCommitsInView = 'gitlens.views.searchAndCompare.searchCommits', SetViewsLayout = 'gitlens.setViewsLayout', ShowBranchesView = 'gitlens.showBranchesView', + ShowCommitDetailsView = 'gitlens.showCommitDetailsView', ShowCommitInView = 'gitlens.showCommitInView', ShowCommitsInView = 'gitlens.showCommitsInView', ShowCommitsView = 'gitlens.showCommitsView', ShowContributorsView = 'gitlens.showContributorsView', - ShowHomeView = 'gitlens.showHomeView', ShowFileHistoryView = 'gitlens.showFileHistoryView', + ShowFocusPage = 'gitlens.showFocusPage', + ShowGraph = 'gitlens.showGraph', + ShowGraphPage = 'gitlens.showGraphPage', + ShowGraphView = 'gitlens.showGraphView', + ShowHomeView = 'gitlens.showHomeView', ShowInCommitGraph = 'gitlens.showInCommitGraph', ShowInDetailsView = 'gitlens.showInDetailsView', ShowLastQuickPick = 'gitlens.showLastQuickPick', @@ -240,13 +245,10 @@ export const enum Commands { ShowSettingsPageAndJumpToAutolinks = 'gitlens.showSettingsPage#autolinks', ShowStashesView = 'gitlens.showStashesView', ShowTagsView = 'gitlens.showTagsView', - ShowWorktreesView = 'gitlens.showWorktreesView', - ShowCommitDetailsView = 'gitlens.showCommitDetailsView', ShowTimelinePage = 'gitlens.showTimelinePage', ShowTimelineView = 'gitlens.showTimelineView', - ShowGraphPage = 'gitlens.showGraphPage', ShowWelcomePage = 'gitlens.showWelcomePage', - ShowFocusPage = 'gitlens.showFocusPage', + ShowWorktreesView = 'gitlens.showWorktreesView', StashApply = 'gitlens.stashApply', StashSave = 'gitlens.stashSave', StashSaveFiles = 'gitlens.stashSaveFiles', diff --git a/src/container.ts b/src/container.ts index 4660afa..583a5a9 100644 --- a/src/container.ts +++ b/src/container.ts @@ -23,7 +23,11 @@ import { SubscriptionAuthenticationProvider } from './plus/subscription/authenti import { ServerConnection } from './plus/subscription/serverConnection'; import { SubscriptionService } from './plus/subscription/subscriptionService'; import { registerFocusWebviewPanel } from './plus/webviews/focus/registration'; -import { registerGraphWebviewCommands, registerGraphWebviewPanel } from './plus/webviews/graph/registration'; +import { + registerGraphWebviewCommands, + registerGraphWebviewPanel, + registerGraphWebviewView, +} from './plus/webviews/graph/registration'; import { GraphStatusBarController } from './plus/webviews/graph/statusbar'; import { registerTimelineWebviewPanel, registerTimelineWebviewView } from './plus/webviews/timeline/registration'; import { StatusBarController } from './statusbar/statusBarController'; @@ -212,8 +216,10 @@ export class Container { const graphWebviewPanel = registerGraphWebviewPanel(this._webviews); context.subscriptions.unshift(graphWebviewPanel); - context.subscriptions.unshift(registerGraphWebviewCommands(graphWebviewPanel)); - // context.subscriptions.unshift((this._graphView = registerGraphWebviewView(this._webviews))); + context.subscriptions.unshift(registerGraphWebviewCommands(this, graphWebviewPanel)); + if (configuration.get('graph.experimental.location') === 'view') { + context.subscriptions.unshift((this._graphView = registerGraphWebviewView(this._webviews))); + } context.subscriptions.unshift(new GraphStatusBarController(this)); const settingsWebviewPanel = registerSettingsWebviewPanel(this._webviews); @@ -431,10 +437,14 @@ export class Container { } } - // private readonly _graphView: WebviewViewProxy; - // get graphView() { - // return this._graphView; - // } + private _graphView: WebviewViewProxy | undefined; + get graphView() { + if (this._graphView == null) { + this.context.subscriptions.unshift((this._graphView = registerGraphWebviewView(this._webviews))); + } + + return this._graphView; + } private readonly _homeView: WebviewViewProxy; get homeView() { diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 8a2f148..9572b47 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -276,7 +276,7 @@ export class GraphWebviewProvider implements WebviewProvider { void this.onGetMoreRows({ id: id }, true); } } else if (this.container.git.repositoryCount > 1) { - const [contexts] = parseCommandContext(Commands.ShowGraphPage, undefined, ...args); + const [contexts] = parseCommandContext(Commands.ShowGraph, undefined, ...args); const context = Array.isArray(contexts) ? contexts[0] : contexts; if (context.type === 'scm' && context.scm.rootUri != null) { diff --git a/src/plus/webviews/graph/registration.ts b/src/plus/webviews/graph/registration.ts index f17ecc6..10b7d5f 100644 --- a/src/plus/webviews/graph/registration.ts +++ b/src/plus/webviews/graph/registration.ts @@ -1,6 +1,9 @@ +import { Disposable } from 'vscode'; import { Commands, ContextKeys } from '../../../constants'; +import type { Container } from '../../../container'; import type { Repository } from '../../../git/models/repository'; -import { registerCommand } from '../../../system/command'; +import { executeCommand, registerCommand } from '../../../system/command'; +import { configuration } from '../../../system/configuration'; import type { BranchNode } from '../../../views/nodes/branchNode'; import type { CommitFileNode } from '../../../views/nodes/commitFileNode'; import type { CommitNode } from '../../../views/nodes/commitNode'; @@ -21,6 +24,9 @@ export function registerGraphWebviewPanel(controller: WebviewsController) { retainContextWhenHidden: true, enableFindWidget: false, }, + canResolveWebviewProvider: function (_container, _id) { + return configuration.get('graph.experimental.location') === 'tab'; + }, resolveWebviewProvider: async function (container, id, host) { const { GraphWebviewProvider } = await import(/* webpackChunkName: "graph" */ './graphWebview'); return new GraphWebviewProvider(container, id, host); @@ -35,6 +41,9 @@ export function registerGraphWebviewView(controller: WebviewsController) { contextKeyPrefix: `${ContextKeys.WebviewViewPrefix}graph`, trackingFeature: 'graphView', plusFeature: true, + canResolveWebviewProvider: function (_container, _id) { + return configuration.get('graph.experimental.location') === 'view'; + }, resolveWebviewProvider: async function (container, id, host) { const { GraphWebviewProvider } = await import(/* webpackChunkName: "graph" */ './graphWebview'); return new GraphWebviewProvider(container, id, host); @@ -42,21 +51,32 @@ export function registerGraphWebviewView(controller: WebviewsController) { }); } -export function registerGraphWebviewCommands(webview: WebviewPanelProxy) { - return registerCommand( - Commands.ShowInCommitGraph, - ( - args: - | ShowInCommitGraphCommandArgs - | Repository - | BranchNode - | CommitNode - | CommitFileNode - | StashNode - | TagNode, - ) => { - const preserveFocus = 'preserveFocus' in args ? args.preserveFocus ?? false : false; - void webview.show({ preserveFocus: preserveFocus }, args); - }, +export function registerGraphWebviewCommands(container: Container, webview: WebviewPanelProxy) { + return Disposable.from( + registerCommand(Commands.ShowGraph, (...args: any[]) => + configuration.get('graph.experimental.location') === 'view' + ? executeCommand(Commands.ShowGraphView, ...args) + : executeCommand(Commands.ShowGraphPage, ...args), + ), + registerCommand( + Commands.ShowInCommitGraph, + ( + args: + | ShowInCommitGraphCommandArgs + | Repository + | BranchNode + | CommitNode + | CommitFileNode + | StashNode + | TagNode, + ) => { + const preserveFocus = 'preserveFocus' in args ? args.preserveFocus ?? false : false; + if (configuration.get('graph.experimental.location') === 'view') { + void container.graphView.show({ preserveFocus: preserveFocus }, args); + } else { + void webview.show({ preserveFocus: preserveFocus }, args); + } + }, + ), ); } diff --git a/src/plus/webviews/graph/statusbar.ts b/src/plus/webviews/graph/statusbar.ts index 4466091..c3236e8 100644 --- a/src/plus/webviews/graph/statusbar.ts +++ b/src/plus/webviews/graph/statusbar.ts @@ -46,7 +46,7 @@ export class GraphStatusBarController implements Disposable { if (this._statusBarItem == null) { this._statusBarItem = window.createStatusBarItem('gitlens.graph', StatusBarAlignment.Left, 10000 - 3); this._statusBarItem.name = 'GitLens Commit Graph'; - this._statusBarItem.command = Commands.ShowGraphPage; + this._statusBarItem.command = Commands.ShowGraph; this._statusBarItem.text = '$(gitlens-graph)'; this._statusBarItem.tooltip = new MarkdownString('Visualize commits on the Commit Graph ✨'); this._statusBarItem.accessibilityInformation = { diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index c238c43..c76e2da 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -146,7 +146,7 @@ export class CommitsViewNode extends RepositoriesSubscribeableNode
  • lines in the text editor
  • - commits in the Commit Graph, + commits in the Commit Graph, Visual File History, or Commits view
  • diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index 25a7f61..840d7dd 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -1092,74 +1092,71 @@ export function GraphWrapper({ {renderAlertContent()}
    -
    - + {repo && ( + <> + + + + + {branchName} - )} - - {repo && ( - <> - - - - - {branchName} - - - - - - - Fetch{' '} - {lastFetched && (Last fetched {fromNow(new Date(lastFetched))})} - - - )} -
    -
    - {state.debugging && ( - - {isLoading && } - {rows.length > 0 && ( - - showing {rows.length} item{rows.length ? 's' : ''} + + + + + + + Fetch + {lastFetched && ( + + (Last fetched {fromNow(new Date(lastFetched))}) )} - - )} - {renderAccountState()} - - - -
    + + + )} + {!state.debugging && ( + + {isLoading && } + {rows.length > 0 && ( + + showing {rows.length} item{rows.length ? 's' : ''} + + )} + + )} + {renderAccountState()} + + +
    {isAccessAllowed && (
    @@ -1267,7 +1264,7 @@ export function GraphWrapper({