Browse Source

Changes commit results to look like search results

main
Eric Amodio 6 years ago
parent
commit
8a3b5d1f44
2 changed files with 22 additions and 27 deletions
  1. +11
    -25
      src/views/nodes/commitResultsNode.ts
  2. +11
    -2
      src/views/nodes/explorerNode.ts

+ 11
- 25
src/views/nodes/commitResultsNode.ts View File

@ -1,42 +1,28 @@
'use strict';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { CommitFormatter, GitLogCommit } from '../../gitService';
import { Strings } from '../../system';
import { GitLogCommit } from '../../gitService';
import { ResultsExplorer } from '../resultsExplorer';
import { CommitNode } from './commitNode';
import { Explorer, ExplorerNode, MessageNode, ResourceType } from './explorerNode';
import { ExplorerNode, ResourceType } from './explorerNode';
export class CommitResultsNode extends ExplorerNode {
constructor(
public readonly commit: GitLogCommit,
private readonly explorer: Explorer,
private readonly contextValue: ResourceType = ResourceType.Results
private readonly explorer: ResultsExplorer
) {
super(commit.toGitUri());
}
async getChildren(): Promise<ExplorerNode[]> {
const children = await new CommitNode(this.commit, this.explorer).getChildren();
children.splice(
0,
0,
new MessageNode(
CommitFormatter.fromTemplate('${message}', this.commit, { truncateMessageAtNewLine: true }),
CommitFormatter.fromTemplate('${message}', this.commit)
)
);
return children;
getChildren(): ExplorerNode[] {
return [new CommitNode(this.commit, this.explorer)];
}
async getTreeItem(): Promise<TreeItem> {
const label = CommitFormatter.fromTemplate(
`Commit \${sha} ${Strings.pad(GlyphChars.Dash, 1, 1)} \${authorAgoOrDate}`,
this.commit,
Container.config.defaultDateFormat
getTreeItem(): TreeItem {
const item = new TreeItem(
`1 result for commits with an id matching '${this.commit.shortSha}'`,
TreeItemCollapsibleState.Expanded
);
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
item.contextValue = this.contextValue;
item.contextValue = ResourceType.Results;
return item;
}
}

+ 11
- 2
src/views/nodes/explorerNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import { Command, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Command, Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitUri } from '../../gitService';
@ -117,7 +117,15 @@ export abstract class ExplorerRefNode extends ExplorerNode {
export class MessageNode extends ExplorerNode {
constructor(
private readonly message: string,
private readonly tooltip?: string
private readonly tooltip?: string,
private readonly iconPath?:
| string
| Uri
| {
light: string | Uri;
dark: string | Uri;
}
| ThemeIcon
) {
super(new GitUri());
}
@ -130,6 +138,7 @@ export class MessageNode extends ExplorerNode {
const item = new TreeItem(this.message, TreeItemCollapsibleState.None);
item.contextValue = ResourceType.Message;
item.tooltip = this.tooltip;
item.iconPath = this.iconPath;
return item;
}
}

Loading…
Cancel
Save