Browse Source

Updates view title & title descriptions

main
Eric Amodio 4 years ago
parent
commit
466b785785
13 changed files with 81 additions and 49 deletions
  1. +1
    -1
      src/views/branchesView.ts
  2. +1
    -1
      src/views/contributorsView.ts
  3. +14
    -2
      src/views/fileHistoryView.ts
  4. +7
    -6
      src/views/historyView.ts
  5. +13
    -1
      src/views/lineHistoryView.ts
  6. +9
    -8
      src/views/nodes/fileHistoryNode.ts
  7. +4
    -0
      src/views/nodes/fileHistoryTrackerNode.ts
  8. +9
    -8
      src/views/nodes/lineHistoryNode.ts
  9. +4
    -0
      src/views/nodes/lineHistoryTrackerNode.ts
  10. +1
    -1
      src/views/remotesView.ts
  11. +1
    -1
      src/views/stashesView.ts
  12. +1
    -1
      src/views/tagsView.ts
  13. +16
    -19
      src/views/viewBase.ts

+ 1
- 1
src/views/branchesView.ts View File

@ -139,7 +139,7 @@ export class BranchesViewNode extends ViewNode {
const [child] = this.children;
const branches = await child.repo.getBranches({ filter: b => !b.remote });
this.view.description = branches.length === 0 ? undefined : `(${branches.length})`;
this.view.title = `Branches (${branches.length})`;
return child.getChildren();
}

+ 1
- 1
src/views/contributorsView.ts View File

@ -105,7 +105,7 @@ export class ContributorsViewNode extends ViewNode {
const [child] = this.children;
const contributors = await child.repo.getContributors();
this.view.description = contributors.length === 0 ? undefined : `(${contributors.length})`;
this.view.title = `Contributors (${contributors.length})`;
return child.getChildren();
}

+ 14
- 2
src/views/fileHistoryView.ts View File

@ -7,6 +7,8 @@ import { GitUri } from '../git/gitUri';
import { FileHistoryTrackerNode, LineHistoryTrackerNode } from './nodes';
import { ViewBase } from './viewBase';
const pinnedSuffix = ' (pinned)';
export class FileHistoryView extends ViewBase<FileHistoryTrackerNode | LineHistoryTrackerNode, FileHistoryViewConfig> {
protected readonly configKey = 'fileHistory';
@ -129,7 +131,7 @@ export class FileHistoryView extends ViewBase
void setCommandContext(CommandContext.ViewsFileHistoryCursorFollowing, enabled);
this.title = this._followCursor ? 'Line History' : 'File History';
this.titleContext = this._followCursor ? this.titleContext : undefined;
// this.titleContext = this._followCursor ? this.titleContext : undefined;
const root = this.ensureRoot(true);
root.setEditorFollowing(this._followEditor);
@ -142,7 +144,17 @@ export class FileHistoryView extends ViewBase
this._followEditor = enabled;
void setCommandContext(CommandContext.ViewsFileHistoryEditorFollowing, enabled);
this._root?.setEditorFollowing(enabled);
this.description = enabled ? '' : ' (pinned)';
if (this.titleDescription?.endsWith(pinnedSuffix)) {
if (enabled) {
this.titleDescription = this.titleDescription.substr(
0,
this.titleDescription.length - pinnedSuffix.length,
);
}
} else if (!enabled) {
this.titleDescription += pinnedSuffix;
}
}
private setRenameFollowing(enabled: boolean) {

+ 7
- 6
src/views/historyView.ts View File

@ -9,7 +9,6 @@ import {
window,
} from 'vscode';
import { configuration, HistoryViewConfig, ViewFilesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import {
GitLogCommit,
@ -157,11 +156,13 @@ export class HistoryViewNode extends ViewNode {
const [child] = this.children;
const branch = await child.repo.getBranch();
const status = branch?.getTrackingStatus();
this.view.title =
branch != null
? `${branch.name} Branch ${status ? ` ${GlyphChars.Dot} ${status}` : ''}`
: 'Current Branch';
if (branch != null) {
this.view.title = `${branch.name} Branch`;
this.view.titleDescription = branch?.getTrackingStatus();
} else {
this.view.title = 'Current Branch';
this.view.titleDescription = undefined;
}
return child.getChildren();
}

+ 13
- 1
src/views/lineHistoryView.ts View File

@ -6,6 +6,8 @@ import { Container } from '../container';
import { LineHistoryTrackerNode } from './nodes';
import { ViewBase } from './viewBase';
const pinnedSuffix = ' (pinned)';
export class LineHistoryView extends ViewBase<LineHistoryTrackerNode, LineHistoryViewConfig> {
protected readonly configKey = 'lineHistory';
@ -92,7 +94,17 @@ export class LineHistoryView extends ViewBase
private setEditorFollowing(enabled: boolean) {
void setCommandContext(CommandContext.ViewsLineHistoryEditorFollowing, enabled);
this._root?.setEditorFollowing(enabled);
this.description = enabled ? '' : ' (pinned)';
if (this.titleDescription?.endsWith(pinnedSuffix)) {
if (enabled) {
this.titleDescription = this.titleDescription.substr(
0,
this.titleDescription.length - pinnedSuffix.length,
);
}
} else if (!enabled) {
this.titleDescription += pinnedSuffix;
}
}
private setRenameFollowing(enabled: boolean) {

+ 9
- 8
src/views/nodes/fileHistoryNode.ts View File

@ -1,6 +1,9 @@
'use strict';
import { Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitFileNode } from './commitFileNode';
import { MessageNode, ShowMoreNode } from './common';
import { Container } from '../../container';
import { FileHistoryTrackerNode } from './fileHistoryTrackerNode';
import {
GitLog,
GitRevision,
@ -9,14 +12,12 @@ import {
RepositoryFileSystemChangeEvent,
} from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { insertDateMarkers } from './helpers';
import { Logger } from '../../logger';
import { RepositoryNode } from './repositoryNode';
import { debug, gate, Iterables } from '../../system';
import { View } from '../viewBase';
import { CommitFileNode } from './commitFileNode';
import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { ContextValues, PageableViewNode, SubscribeableViewNode, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class FileHistoryNode extends SubscribeableViewNode implements PageableViewNode {
static key = ':history:file';
@ -77,11 +78,11 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
}
}
this.view.titleContext = `${this.uri.fileName}${
this.view.titleDescription = `${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
}${this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
void this.ensureSubscription();
@ -104,11 +105,11 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}`;
this.view.titleContext = `${this.uri.fileName}${
this.view.titleDescription = `${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
}${this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
void this.ensureSubscription();

+ 4
- 0
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -65,6 +65,10 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
return item;
}
get followingEditor(): boolean {
return this.canSubscribe;
}
@gate()
@log()
async changeBase() {

+ 9
- 8
src/views/nodes/lineHistoryNode.ts View File

@ -1,5 +1,7 @@
'use strict';
import { Disposable, Selection, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitFileNode } from './commitFileNode';
import { MessageNode, ShowMoreNode } from './common';
import { Container } from '../../container';
import {
GitCommitType,
@ -12,14 +14,13 @@ import {
RepositoryFileSystemChangeEvent,
} from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { insertDateMarkers } from './helpers';
import { Logger } from '../../logger';
import { LineHistoryTrackerNode } from './lineHistoryTrackerNode';
import { RepositoryNode } from './repositoryNode';
import { debug, gate, Iterables } from '../../system';
import { View } from '../viewBase';
import { CommitFileNode } from './commitFileNode';
import { MessageNode, ShowMoreNode } from './common';
import { insertDateMarkers } from './helpers';
import { ContextValues, PageableViewNode, SubscribeableViewNode, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class LineHistoryNode extends SubscribeableViewNode implements PageableViewNode {
static key = ':history:line';
@ -201,11 +202,11 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
const lines = this.selection.isSingleLine
? `:${this.selection.start.line + 1}`
: `:${this.selection.start.line + 1}-${this.selection.end.line + 1}`;
this.view.titleContext = `${this.uri.fileName}${lines}${
this.view.titleDescription = `${this.uri.fileName}${lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
}${this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
void this.ensureSubscription();
@ -229,11 +230,11 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
item.description = this.uri.directory;
item.tooltip = `History of ${this.uri.fileName}${lines}\n${this.uri.directory}/${
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}`;
}${this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
void this.ensureSubscription();
this.view.titleContext = `${this.uri.fileName}${lines}${
this.view.titleDescription = `${this.uri.fileName}${lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''

+ 4
- 0
src/views/nodes/lineHistoryTrackerNode.ts View File

@ -71,6 +71,10 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
return item;
}
get followingEditor(): boolean {
return this.canSubscribe;
}
@gate()
@log()
async changeBase() {

+ 1
- 1
src/views/remotesView.ts View File

@ -132,7 +132,7 @@ export class RemotesViewNode extends ViewNode {
const [child] = this.children;
const remotes = await child.repo.getRemotes();
this.view.description = remotes.length === 0 ? undefined : `(${remotes.length})`;
this.view.title = `Remotes (${remotes.length})`;
return child.getChildren();
}

+ 1
- 1
src/views/stashesView.ts View File

@ -105,7 +105,7 @@ export class StashesViewNode extends ViewNode {
const [child] = this.children;
const stash = await child.repo.getStash();
this.view.description = stash == null ? undefined : `(${stash.commits.size})`;
this.view.title = `Stashes (${stash?.commits.size ?? 0})`;
return child.getChildren();
}

+ 1
- 1
src/views/tagsView.ts View File

@ -123,7 +123,7 @@ export class TagsViewNode extends ViewNode {
const [child] = this.children;
const tags = await child.repo.getTags();
this.view.description = tags.length === 0 ? undefined : `(${tags.length})`;
this.view.title = `Tags (${tags.length})`;
return child.getChildren();
}

+ 16
- 19
src/views/viewBase.ts View File

@ -37,7 +37,6 @@ import {
ViewsConfigKeys,
viewsConfigKeys,
} from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { ContributorsView } from './contributorsView';
import { FileHistoryView } from './fileHistoryView';
@ -50,6 +49,7 @@ import { SearchView } from './searchView';
import { StashesView } from './stashesView';
import { debug, Functions, log, Promises, Strings } from '../system';
import { TagsView } from './tagsView';
import { GlyphChars } from '../constants';
export type View =
| BranchesView
@ -170,21 +170,12 @@ export abstract class ViewBase<
this.updateTitle();
}
private _titleContext: string | undefined;
get titleContext(): string | undefined {
return this._titleContext;
private _titleDescription: string | undefined;
get titleDescription(): string | undefined {
return this._titleDescription;
}
set titleContext(value: string | undefined) {
this._titleContext = value;
this.updateTitle();
}
private _description: string | undefined;
get description(): string | undefined {
return this._description;
}
set description(value: string | undefined) {
this._description = value;
set titleDescription(value: string | undefined) {
this._titleDescription = value;
this.updateTitle();
}
@ -201,10 +192,13 @@ export abstract class ViewBase<
private updateTitleCore() {
if (this._tree == null) return;
this._tree.title = `${this.title}${this.titleContext ? ` ${GlyphChars.Dot} ${this.titleContext}` : ''}${
this.description ? ` ${this.description}` : ''
}`;
if (this._tree.visible) {
this._tree.title = `${this.title}${
this.titleDescription ? ` ${GlyphChars.Dot} ${this.titleDescription}` : ''
}`;
} else {
this._tree.title = this.title;
}
}
getQualifiedCommand(command: string) {
@ -270,6 +264,9 @@ export abstract class ViewBase<
}
protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent) {
if (this.titleDescription) {
this.updateTitleCore();
}
this._onDidChangeVisibility.fire(e);
}

Loading…
Cancel
Save