mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 02:58:32 -05:00
Adds new GitLens custom view
This commit is contained in:
35
src/views/remotesNode.ts
Normal file
35
src/views/remotesNode.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
import { Arrays, Iterables } from '../system';
|
||||
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { RemoteNode } from './remoteNode';
|
||||
|
||||
export class RemotesNode extends ExplorerNode {
|
||||
|
||||
readonly resourceType: ResourceType = 'gitlens:remotes';
|
||||
|
||||
constructor(uri: GitUri, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<ExplorerNode[]> {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.uri.repoPath!), r => r.url, r => !!r.provider);
|
||||
if (remotes === undefined) return [];
|
||||
|
||||
remotes.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return [...Iterables.map(remotes, r => new RemoteNode(r, this.uri, this.context, this.git))];
|
||||
}
|
||||
|
||||
getTreeItem(): TreeItem {
|
||||
const item = new TreeItem(`Remotes`, TreeItemCollapsibleState.Collapsed);
|
||||
item.contextValue = this.resourceType;
|
||||
|
||||
item.iconPath = {
|
||||
dark: this.context.asAbsolutePath('images/dark/icon-remote.svg'),
|
||||
light: this.context.asAbsolutePath('images/light/icon-remote.svg')
|
||||
};
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user