Skip to content

Commit 1672cc9

Browse files
committed
Adds Visual History button to Graph header
1 parent d5e8bef commit 1672cc9

File tree

8 files changed

+52
-31
lines changed

8 files changed

+52
-31
lines changed

src/constants.commands.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ type InternalGraphWebviewCommands =
3434
| 'gitlens.graph.abortPausedOperation'
3535
| 'gitlens.graph.continuePausedOperation'
3636
| 'gitlens.graph.openRebaseEditor'
37-
| 'gitlens.graph.skipPausedOperation';
37+
| 'gitlens.graph.skipPausedOperation'
38+
| 'gitlens.visualizeHistory.repo:graph';
3839

3940
type InternalHomeWebviewCommands =
41+
| 'gitlens.ai.explainWip:home'
42+
| 'gitlens.ai.explainBranch:home'
4043
| 'gitlens.home.changeBranchMergeTarget'
4144
| 'gitlens.home.deleteBranchOrWorktree'
4245
| 'gitlens.home.pushBranch'
@@ -50,8 +53,6 @@ type InternalHomeWebviewCommands =
5053
| 'gitlens.home.switchToBranch'
5154
| 'gitlens.home.fetch'
5255
| 'gitlens.home.openInGraph'
53-
| 'gitlens.home.visualizeHistory.repo:home'
54-
| 'gitlens.home.visualizeHistory.branch:home'
5556
| 'gitlens.home.createBranch'
5657
| 'gitlens.home.mergeIntoCurrent'
5758
| 'gitlens.home.rebaseCurrentOnto'
@@ -60,10 +61,10 @@ type InternalHomeWebviewCommands =
6061
| 'gitlens.home.skipPausedOperation'
6162
| 'gitlens.home.continuePausedOperation'
6263
| 'gitlens.home.abortPausedOperation'
63-
| 'gitlens.ai.explainWip:home'
64-
| 'gitlens.ai.explainBranch:home'
6564
| 'gitlens.home.openRebaseEditor'
66-
| 'gitlens.home.enableAi';
65+
| 'gitlens.home.enableAi'
66+
| 'gitlens.visualizeHistory.repo:home'
67+
| 'gitlens.visualizeHistory.branch:home';
6768

6869
type InternalHomeWebviewViewCommands =
6970
| 'gitlens.views.home.account.resync'
@@ -126,8 +127,6 @@ type InternalGlCommands =
126127
| 'gitlens.openWalkthrough'
127128
| 'gitlens.refreshHover'
128129
| 'gitlens.visualizeHistory'
129-
| 'gitlens.visualizeHistory.repo:home'
130-
| 'gitlens.visualizeHistory.branch:home'
131130
| InternalGraphWebviewCommands
132131
| InternalHomeWebviewCommands
133132
| InternalHomeWebviewViewCommands
@@ -201,6 +200,8 @@ type FilterCommands<Prefix extends string, U, Suffix extends string = ''> = U ex
201200
: never
202201
: never;
203202

203+
export type PlusCommands = FilterCommands<'gitlens.plus.', GlCommands>;
204+
204205
export type TreeViewCommands =
205206
| FilterCommands<`gitlens.views.${TreeViewTypes}`, GlCommands>
206207
| FilterCommands<`gitlens.`, GlCommands, ':views'>;

src/system/webview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import type { PlusCommands, WebviewCommands, WebviewViewCommands } from '../constants.commands';
12
import type { WebviewIds, WebviewViewIds } from '../constants.views';
23

34
export function createWebviewCommandLink<T>(
4-
command: `${WebviewIds | WebviewViewIds}.${string}` | `gitlens.plus.${string}`,
5+
command: WebviewCommands | WebviewViewCommands | PlusCommands,
56
webviewId: WebviewIds | WebviewViewIds,
67
webviewInstanceId: string | undefined,
78
args?: T,

src/webviews/apps/plus/graph/graph-header.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,29 @@ export class GlGraphHeader extends SignalWatcher(LitElement) {
841841
to help you focus and keep your team unblocked
842842
</span>
843843
</gl-tooltip>
844+
<gl-tooltip placement="bottom">
845+
<a
846+
href=${createWebviewCommandLink(
847+
'gitlens.visualizeHistory.repo:graph',
848+
this.hostState.webviewId,
849+
this.hostState.webviewInstanceId,
850+
)}
851+
class="action-button"
852+
aria-label=${`Open Visual History`}
853+
>
854+
<span>
855+
<code-icon
856+
class="action-button__icon"
857+
icon=${'graph-scatter'}
858+
aria-hidden="true"
859+
></code-icon>
860+
</span>
861+
</a>
862+
<span slot="content">
863+
<strong>Visual History</strong> — visualize the evolution of a repository, branch,
864+
folder, or file and identify when the most impactful changes were made and by whom
865+
</span>
866+
</gl-tooltip>
844867
<gl-tooltip placement="bottom">
845868
<a
846869
href=${'command:gitlens.views.home.focus'}

src/webviews/apps/plus/home/components/active-work.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
157157
class="section-heading-action"
158158
appearance="toolbar"
159159
tooltip="Visualize Repo History"
160-
href=${createCommandLink('gitlens.home.visualizeHistory.repo:home', {
160+
href=${createCommandLink('gitlens.visualizeHistory.repo:home', {
161161
type: 'repo',
162162
repoPath: this._activeOverviewState.state!.repository.path,
163163
} satisfies OpenInTimelineParams)}

src/webviews/apps/plus/home/components/branch-card.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { css, html, LitElement, nothing } from 'lit';
44
import { customElement, property, state } from 'lit/decorators.js';
55
import { classMap } from 'lit/directives/class-map.js';
66
import { when } from 'lit/directives/when.js';
7-
import type { GlCommands } from '../../../../../constants.commands';
8-
import type { WebviewIds, WebviewViewIds } from '../../../../../constants.views';
7+
import type { GlCommands, PlusCommands, WebviewCommands, WebviewViewCommands } from '../../../../../constants.commands';
98
import type { LaunchpadCommandArgs } from '../../../../../plus/launchpad/launchpad';
109
import {
1110
actionGroupMap,
@@ -702,7 +701,7 @@ export abstract class GlBranchCardBase extends GlElement {
702701
}
703702

704703
protected createWebviewCommandLink<T>(
705-
command: `${WebviewIds | WebviewViewIds}.${string}` | `gitlens.plus.${string}`,
704+
command: WebviewCommands | WebviewViewCommands | PlusCommands,
706705
args?: T | any,
707706
): string {
708707
return createWebviewCommandLink<T>(
@@ -1066,7 +1065,7 @@ export class GlBranchCard extends GlBranchCardBase {
10661065
html` <action-item
10671066
label="Visualize Branch History"
10681067
icon="graph-scatter"
1069-
href=${createCommandLink('gitlens.home.visualizeHistory.branch:home', {
1068+
href=${createCommandLink('gitlens.visualizeHistory.branch:home', {
10701069
type: 'branch',
10711070
repoPath: this.repo,
10721071
branchId: this.branch.id,

src/webviews/home/homeWebview.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
347347
registerCommand('gitlens.home.switchToBranch', this.switchToBranch, this),
348348
registerCommand('gitlens.home.fetch', this.fetch, this),
349349
registerCommand('gitlens.home.openInGraph', this.openInGraph, this),
350-
registerCommand('gitlens.home.visualizeHistory.repo:home', this.openInTimeline, this),
351-
registerCommand('gitlens.home.visualizeHistory.branch:home', this.openInTimeline, this),
350+
registerCommand('gitlens.visualizeHistory.repo:home', this.openInTimeline, this),
351+
registerCommand('gitlens.visualizeHistory.branch:home', this.openInTimeline, this),
352352
registerCommand('gitlens.home.createBranch', this.createBranch, this),
353353
registerCommand('gitlens.home.mergeIntoCurrent', this.mergeIntoCurrent, this),
354354
registerCommand('gitlens.home.rebaseCurrentOnto', this.rebaseCurrentOnto, this),
@@ -490,7 +490,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
490490
if (repo == null) return;
491491

492492
if (params?.type === 'repo') {
493-
void executeCommand<TimelineCommandArgs | Uri>('gitlens.visualizeHistory.repo:home', repo.uri);
493+
void executeCommand<TimelineCommandArgs>('gitlens.visualizeHistory', { type: 'repo', uri: repo.uri });
494494
return;
495495
}
496496

@@ -499,7 +499,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
499499

500500
const branch = repoInfo?.branches.find(b => b.id === params.branchId);
501501
if (branch != null) {
502-
void executeCommand<TimelineCommandArgs>('gitlens.visualizeHistory.branch:home', {
502+
void executeCommand<TimelineCommandArgs>('gitlens.visualizeHistory', {
503503
type: 'repo',
504504
uri: repo.uri,
505505
head: getReferenceFromBranch(branch),

src/webviews/plus/graph/graphWebview.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ import type { IpcCallMessageType, IpcMessage, IpcNotification } from '../../prot
136136
import type { WebviewHost, WebviewProvider, WebviewShowingArgs } from '../../webviewProvider';
137137
import type { WebviewPanelShowCommandArgs, WebviewShowOptions } from '../../webviewsController';
138138
import { isSerializedState } from '../../webviewsController';
139+
import type { TimelineCommandArgs } from '../timeline/registration';
139140
import {
140141
formatRepositories,
141142
hasGitReference,
@@ -701,6 +702,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
701702
this.host.registerWebviewCommand('gitlens.graph.skipPausedOperation', this.skipPausedOperation),
702703

703704
this.host.registerWebviewCommand('gitlens.ai.generateChangelogFrom:graph', this.generateChangelogFrom),
705+
this.host.registerWebviewCommand('gitlens.visualizeHistory.repo:graph', this.visualizeHistoryRepo),
704706
);
705707

706708
return commands;
@@ -4093,6 +4095,14 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
40934095
return Promise.resolve();
40944096
}
40954097

4098+
@log()
4099+
private visualizeHistoryRepo() {
4100+
void executeCommand<TimelineCommandArgs | undefined>(
4101+
'gitlens.visualizeHistory',
4102+
this.repository != null ? { type: 'repo', uri: this.repository.uri } : undefined,
4103+
);
4104+
}
4105+
40964106
private getCommitFromGraphItemRef(item?: GraphItemContext): Promise<GitCommit | undefined> {
40974107
let ref: GitRevisionReference | GitStashReference | undefined = this.getGraphItemRef(item, 'revision');
40984108
if (ref != null) return this.container.git.commits(ref.repoPath).getCommit(ref.ref);

src/webviews/plus/timeline/registration.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,6 @@ export function registerTimelineWebviewCommands<T>(
103103
return show(uri ? { type: 'folder', uri: uri } : undefined);
104104
}),
105105

106-
registerCommand('gitlens.visualizeHistory.repo:home', (...args: unknown[]) => {
107-
return show(
108-
args[0] instanceof Uri
109-
? { type: 'repo', uri: args[0] }
110-
: isTimelineScope(args[0])
111-
? args[0]
112-
: undefined,
113-
);
114-
}),
115-
registerCommand('gitlens.visualizeHistory.branch:home', (...args: unknown[]) => {
116-
return show(isTimelineScope(args[0]) ? args[0] : undefined);
117-
}),
118-
119106
registerCommand(`${panels.id}.refresh`, () => void panels.getActiveInstance()?.refresh(true)),
120107
registerCommand(
121108
`${panels.id}.split`,

0 commit comments

Comments
 (0)