mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-13 11:38:40 -05:00
extract stash explorer
This commit is contained in:
43
src/views/gitStashExplorer.ts
Normal file
43
src/views/gitStashExplorer.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
import { Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
|
||||
import { ExplorerNode, StashNode } from './gitExplorerNodes';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { StashCommitNode } from './stashCommitNode';
|
||||
|
||||
export * from './gitExplorerNodes';
|
||||
|
||||
export class GitStashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
private _node: ExplorerNode;
|
||||
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
|
||||
public get onDidChangeTreeData(): Event<StashCommitNode> {
|
||||
return this._onDidChangeTreeData.event;
|
||||
}
|
||||
|
||||
constructor(private context: ExtensionContext, private git: GitService) {
|
||||
const editor = window.activeTextEditor;
|
||||
|
||||
const uri = (editor !== undefined && editor.document !== undefined)
|
||||
? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
|
||||
: new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||
|
||||
this._node = new StashNode(uri, this.context, this.git);
|
||||
}
|
||||
|
||||
async getTreeItem(node: ExplorerNode): Promise<TreeItem> {
|
||||
return node.getTreeItem();
|
||||
}
|
||||
|
||||
async getChildren(node?: ExplorerNode): Promise<ExplorerNode[]> {
|
||||
if (node === undefined) return this._node.getChildren();
|
||||
return node.getChildren();
|
||||
}
|
||||
|
||||
update(uri: GitUri) {
|
||||
this._node = new StashNode(uri, this.context, this.git);
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this._onDidChangeTreeData.fire();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import { CommitNode } from './commitNode';
|
||||
import { GlyphChars } from '../constants';
|
||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||
import { GitBranch, GitService, GitUri } from '../gitService';
|
||||
import { StashNode } from './stashNode';
|
||||
|
||||
export class RepositoryNode extends ExplorerNode {
|
||||
|
||||
@@ -19,7 +18,6 @@ export class RepositoryNode extends ExplorerNode {
|
||||
async getChildren(): Promise<ExplorerNode[]> {
|
||||
return [
|
||||
new StatusNode(this.uri, this.context, this.git),
|
||||
new StashNode(this.uri, this.context, this.git),
|
||||
new BranchesNode(this.uri, this.context, this.git)
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user