|
| 1 | +import * as vscode from 'vscode' |
| 2 | +import { SupportTreeNode } from './nodes/SupportTreeNode' |
| 3 | + |
| 4 | +export class SupportTree extends vscode.Disposable implements vscode.TreeDataProvider<SupportTreeNode> { |
| 5 | + private _onDidChangeTreeData = new vscode.EventEmitter<SupportTreeNode | void>() |
| 6 | + readonly onDidChangeTreeData = this._onDidChangeTreeData.event |
| 7 | + private _view: vscode.TreeView<SupportTreeNode> |
| 8 | + |
| 9 | + constructor(private _context: vscode.ExtensionContext) { |
| 10 | + super(() => this.dispose()) |
| 11 | + |
| 12 | + // create the tree view |
| 13 | + this._view = vscode.window.createTreeView('codacy:support', { |
| 14 | + treeDataProvider: this, |
| 15 | + showCollapseAll: false, |
| 16 | + }) |
| 17 | + |
| 18 | + this._context.subscriptions.push(this._view) |
| 19 | + } |
| 20 | + |
| 21 | + getTreeItem(element: SupportTreeNode): vscode.TreeItem | Thenable<vscode.TreeItem> { |
| 22 | + return element |
| 23 | + } |
| 24 | + |
| 25 | + async getChildren(element?: SupportTreeNode | undefined): Promise<SupportTreeNode[]> { |
| 26 | + if (!element) { |
| 27 | + // root level - return all support items |
| 28 | + return [ |
| 29 | + new SupportTreeNode( |
| 30 | + 'Read documentation', |
| 31 | + 'book', |
| 32 | + 'https://docs.codacy.com/codacy-guardrails/codacy-guardrails-getting-started/' |
| 33 | + ), |
| 34 | + new SupportTreeNode('Contact support', 'mail', 'https://codacy.zendesk.com/hc/en-us/requests/new'), |
| 35 | + new SupportTreeNode('Give feedback', 'feedback', 'https://tally.so/r/meyROJ'), |
| 36 | + new SupportTreeNode( |
| 37 | + 'Review extension', |
| 38 | + 'star', |
| 39 | + 'https://marketplace.visualstudio.com/items?itemName=codacy-app.codacy&ssr=false#review-details' |
| 40 | + ), |
| 41 | + new SupportTreeNode('View extension logs', 'output', undefined, 'codacy.showOutput'), |
| 42 | + ] |
| 43 | + } else { |
| 44 | + // these are leaf nodes, no children |
| 45 | + return [] |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments