Browse Source

Adds show visual file history command

Adds show method to webview views
main
Eric Amodio 2 years ago
parent
commit
042ee28c71
8 changed files with 45 additions and 18 deletions
  1. +10
    -0
      package.json
  2. +6
    -4
      src/commands/showView.ts
  3. +1
    -0
      src/constants.ts
  4. +10
    -10
      src/container.ts
  5. +3
    -1
      src/views/viewBase.ts
  6. +1
    -1
      src/webviews/webviewBase.ts
  7. +13
    -1
      src/webviews/webviewViewBase.ts
  8. +1
    -1
      src/webviews/webviewWithConfigBase.ts

+ 10
- 0
package.json View File

@ -101,6 +101,7 @@
"onCommand:gitlens.showSearchAndCompareView",
"onCommand:gitlens.showStashesView",
"onCommand:gitlens.showTagsView",
"onCommand:gitlens.showTimelineView",
"onCommand:gitlens.showWorktreesView",
"onCommand:gitlens.compareWith",
"onCommand:gitlens.compareHeadWith",
@ -3786,6 +3787,11 @@
"category": "GitLens"
},
{
"command": "gitlens.showTimelineView",
"title": "Show Visual File History View",
"category": "GitLens"
},
{
"command": "gitlens.showWorktreesView",
"title": "Show Worktrees View",
"category": "GitLens"
@ -6023,6 +6029,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.showTimelineView",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showWorktreesView",
"when": "gitlens:enabled && !gitlens:hasVirtualFolders"
},

+ 6
- 4
src/commands/showView.ts View File

@ -1,6 +1,6 @@
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, executeCommand } from '../system/command';
import { command } from '../system/command';
import { Command, CommandContext } from './base';
@command()
@ -17,6 +17,7 @@ export class ShowViewCommand extends Command {
Commands.ShowSearchAndCompareView,
Commands.ShowStashesView,
Commands.ShowTagsView,
Commands.ShowTimelineView,
Commands.ShowWorktreesView,
Commands.ShowHomeView,
]);
@ -36,6 +37,8 @@ export class ShowViewCommand extends Command {
return this.container.contributorsView.show();
case Commands.ShowFileHistoryView:
return this.container.fileHistoryView.show();
case Commands.ShowHomeView:
return this.container.homeView.show();
case Commands.ShowLineHistoryView:
return this.container.lineHistoryView.show();
case Commands.ShowRemotesView:
@ -48,11 +51,10 @@ export class ShowViewCommand extends Command {
return this.container.stashesView.show();
case Commands.ShowTagsView:
return this.container.tagsView.show();
case Commands.ShowTimelineView:
return this.container.timelineView.show();
case Commands.ShowWorktreesView:
return this.container.worktreesView.show();
case Commands.ShowHomeView:
void (await executeCommand('gitlens.views.home.focus'));
break;
}
return Promise.resolve(undefined);

+ 1
- 0
src/constants.ts View File

@ -194,6 +194,7 @@ export const enum Commands {
ShowTagsView = 'gitlens.showTagsView',
ShowWorktreesView = 'gitlens.showWorktreesView',
ShowTimelinePage = 'gitlens.showTimelinePage',
ShowTimelineView = 'gitlens.showTimelineView',
ShowWelcomePage = 'gitlens.showWelcomePage',
StashApply = 'gitlens.stashApply',
StashSave = 'gitlens.stashSave',

+ 10
- 10
src/container.ts View File

@ -191,7 +191,7 @@ export class Container {
context.subscriptions.push((this._contributorsView = new ContributorsView(this)));
context.subscriptions.push((this._searchAndCompareView = new SearchAndCompareView(this)));
context.subscriptions.push((this._homeWebviewView = new HomeWebviewView(this)));
context.subscriptions.push((this._homeView = new HomeWebviewView(this)));
context.subscriptions.push((this._timelineView = new TimelineWebviewView(this)));
if (config.terminalLinks.enabled) {
@ -365,6 +365,15 @@ export class Container {
}
}
private _homeView: HomeWebviewView | undefined;
get homeView() {
if (this._homeView == null) {
this._context.subscriptions.push((this._homeView = new HomeWebviewView(this)));
}
return this._homeView;
}
@memoize()
get insiders() {
return this._context.extension.id.endsWith('-insiders');
@ -408,15 +417,6 @@ export class Container {
return this._rebaseEditor;
}
private _homeWebviewView: HomeWebviewView | undefined;
get homeWebviewView() {
if (this._homeWebviewView == null) {
this._context.subscriptions.push((this._homeWebviewView = new HomeWebviewView(this)));
}
return this._homeWebviewView;
}
private _remotesView: RemotesView | undefined;
get remotesView() {
if (this._remotesView == null) {

+ 3
- 1
src/views/viewBase.ts View File

@ -512,10 +512,12 @@ export abstract class ViewBase<
@log()
async show(options?: { preserveFocus?: boolean }) {
const cc = Logger.getCorrelationContext();
try {
void (await executeCommand(`${this.id}.focus`, options));
} catch (ex) {
Logger.error(ex);
Logger.error(ex, cc);
}
}

+ 1
- 1
src/webviews/webviewBase.ts View File

@ -50,7 +50,7 @@ export abstract class WebviewBase implements Disposable {
constructor(
protected readonly container: Container,
public readonly id: string,
public readonly id: `gitlens.${string}`,
private readonly fileName: string,
private readonly iconPath: string,
title: string,

+ 13
- 1
src/webviews/webviewViewBase.ts View File

@ -15,6 +15,7 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { executeCommand } from '../system/command';
import { log } from '../system/decorators/log';
import {
ExecuteCommandType,
IpcMessage,
@ -51,7 +52,7 @@ export abstract class WebviewViewBase implements WebviewViewProvider, Dis
constructor(
protected readonly container: Container,
public readonly id: string,
public readonly id: `gitlens.views.${string}`,
protected readonly fileName: string,
title: string,
) {
@ -88,6 +89,17 @@ export abstract class WebviewViewBase implements WebviewViewProvider, Dis
return this._view?.visible ?? false;
}
@log()
async show(options?: { preserveFocus?: boolean }) {
const cc = Logger.getCorrelationContext();
try {
void (await executeCommand(`${this.id}.focus`, options));
} catch (ex) {
Logger.error(ex, cc);
}
}
protected onReady?(): void;
protected onMessageReceived?(e: IpcMessage): void;
protected onVisibilityChanged?(visible: boolean): void;

+ 1
- 1
src/webviews/webviewWithConfigBase.ts View File

@ -28,7 +28,7 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
constructor(
container: Container,
id: string,
id: `gitlens.${string}`,
fileName: string,
iconPath: string,
title: string,

Loading…
Cancel
Save