|
|
@ -1,4 +1,6 @@ |
|
|
|
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; |
|
|
|
import { GlyphChars } from '../../constants'; |
|
|
|
import { PremiumFeatures } from '../../git/gitProvider'; |
|
|
|
import { GitUri } from '../../git/gitUri'; |
|
|
|
import { Repository } from '../../git/models'; |
|
|
|
import { gate } from '../../system/decorators/gate'; |
|
|
@ -37,6 +39,9 @@ export class WorktreesNode extends ViewNode { |
|
|
|
|
|
|
|
async getChildren(): Promise<ViewNode[]> { |
|
|
|
if (this._children == null) { |
|
|
|
const access = await this.repo.access(PremiumFeatures.Worktrees); |
|
|
|
if (!access.allowed) return []; |
|
|
|
|
|
|
|
const worktrees = await this.repo.getWorktrees(); |
|
|
|
if (worktrees.length === 0) return [new MessageNode(this.view, this, 'No worktrees could be found.')]; |
|
|
|
|
|
|
@ -46,10 +51,18 @@ export class WorktreesNode extends ViewNode { |
|
|
|
return this._children; |
|
|
|
} |
|
|
|
|
|
|
|
getTreeItem(): TreeItem { |
|
|
|
const item = new TreeItem('Worktrees', TreeItemCollapsibleState.Collapsed); |
|
|
|
async getTreeItem(): Promise<TreeItem> { |
|
|
|
const access = await this.repo.access(PremiumFeatures.Worktrees); |
|
|
|
|
|
|
|
const item = new TreeItem( |
|
|
|
'Worktrees', |
|
|
|
access.allowed ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None, |
|
|
|
); |
|
|
|
item.id = this.id; |
|
|
|
item.contextValue = ContextValues.Worktrees; |
|
|
|
item.description = access.allowed |
|
|
|
? undefined |
|
|
|
: ` ${GlyphChars.Warning} Premium feature which requires an account`; |
|
|
|
// TODO@eamodio `folder` icon won't work here for some reason
|
|
|
|
item.iconPath = new ThemeIcon('folder-opened'); |
|
|
|
return item; |
|
|
|