Browse Source

Adds originalTitle prop to base

main
Eric Amodio 2 years ago
parent
commit
d7fa870ab3
3 changed files with 8 additions and 7 deletions
  1. +1
    -3
      src/plus/webviews/graph/graphWebview.ts
  2. +1
    -3
      src/plus/webviews/timeline/timelineWebview.ts
  3. +6
    -1
      src/webviews/webviewBase.ts

+ 1
- 3
src/plus/webviews/graph/graphWebview.ts View File

@ -43,7 +43,6 @@ export class GraphWebview extends WebviewWithConfigBase {
private selectedRepository?: Repository; private selectedRepository?: Repository;
private currentLog?: GitLog; private currentLog?: GitLog;
private repoDisposable: Disposable | undefined; private repoDisposable: Disposable | undefined;
private defaultTitle?: string;
private previewBanner?: boolean; private previewBanner?: boolean;
constructor(container: Container) { constructor(container: Container) {
@ -55,7 +54,6 @@ export class GraphWebview extends WebviewWithConfigBase {
'Commit Graph', 'Commit Graph',
Commands.ShowGraphPage, Commands.ShowGraphPage,
); );
this.defaultTitle = this.title;
this.disposables.push({ dispose: () => void this.repoDisposable?.dispose() }); this.disposables.push({ dispose: () => void this.repoDisposable?.dispose() });
} }
@ -325,7 +323,7 @@ export class GraphWebview extends WebviewWithConfigBase {
} }
if (this.selectedRepository !== undefined) { if (this.selectedRepository !== undefined) {
this.title = `${this.defaultTitle}: ${this.selectedRepository.formattedName}`;
this.title = `${this.originalTitle}: ${this.selectedRepository.formattedName}`;
} }
const [commitsAndLog, remotes, tags, branches, stashCommits] = await Promise.all([ const [commitsAndLog, remotes, tags, branches, stashCommits] = await Promise.all([

+ 1
- 3
src/plus/webviews/timeline/timelineWebview.ts View File

@ -42,7 +42,6 @@ export class TimelineWebview extends WebviewBase {
private _context: Context; private _context: Context;
/** The context the webview should have */ /** The context the webview should have */
private _pendingContext: Partial<Context> | undefined; private _pendingContext: Partial<Context> | undefined;
private _originalTitle: string;
constructor(container: Container) { constructor(container: Container) {
super( super(
@ -53,7 +52,6 @@ export class TimelineWebview extends WebviewBase {
'Visual File History', 'Visual File History',
Commands.ShowTimelinePage, Commands.ShowTimelinePage,
); );
this._originalTitle = this.title;
this._context = { this._context = {
uri: undefined, uri: undefined,
period: defaultPeriod, period: defaultPeriod,
@ -235,7 +233,7 @@ export class TimelineWebview extends WebviewBase {
const repoPath = gitUri.repoPath!; const repoPath = gitUri.repoPath!;
const title = gitUri.relativePath; const title = gitUri.relativePath;
this.title = `${this._originalTitle}: ${gitUri.fileName}`;
this.title = `${this.originalTitle}: ${gitUri.fileName}`;
const [currentUser, log] = await Promise.all([ const [currentUser, log] = await Promise.all([
this.container.git.getCurrentUser(repoPath), this.container.git.getCurrentUser(repoPath),

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

@ -35,7 +35,7 @@ export abstract class WebviewBase implements Disposable {
title: string, title: string,
showCommand: Commands, showCommand: Commands,
) { ) {
this._title = title;
this._originalTitle = this._title = title;
this.disposables.push(registerCommand(showCommand, this.onShowCommand, this)); this.disposables.push(registerCommand(showCommand, this.onShowCommand, this));
} }
@ -44,6 +44,11 @@ export abstract class WebviewBase implements Disposable {
this._disposablePanel?.dispose(); this._disposablePanel?.dispose();
} }
private _originalTitle: string | undefined;
get originalTitle(): string | undefined {
return this._originalTitle;
}
private _title: string; private _title: string;
get title(): string { get title(): string {
return this._panel?.title ?? this._title; return this._panel?.title ?? this._title;

Loading…
Cancel
Save