Skip to content

Commit 6b9e9dd

Browse files
committed
feature: Improve support view CF-1651
1 parent b4a0706 commit 6b9e9dd

5 files changed

Lines changed: 80 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,14 @@
9696
},
9797
{
9898
"id": "codacy:support",
99-
"name": "Chat with us",
99+
"name": "Help and Feedback",
100100
"icon": "$(question)",
101101
"collapsed": false,
102102
"initialSize": 1
103103
}
104104
]
105105
},
106106
"viewsWelcome": [
107-
{
108-
"view": "codacy:support",
109-
"contents": "Do you need help or do you have any questions?\n[Open support chat](https://codacy.zendesk.com/hc/en-us/requests/new)\nEnjoying the experience? Please consider [leaving a review](https://marketplace.visualstudio.com/items?itemName=codacy-app.codacy&ssr=false#review-details)"
110-
},
111107
{
112108
"view": "codacy:status",
113109
"contents": "No project is open. Open a project to use the Codacy extension."

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IssueDetailsProvider, seeIssueDetailsCommand } from './views/IssueDetai
1414
import { PullRequestsTree } from './views/PullRequestsTree'
1515
import { PullRequestNode } from './views/nodes/PullRequestNode'
1616
import { BranchIssuesTree } from './views/BranchIssuesTree'
17+
import { SupportTree } from './views/SupportTree'
1718
import { Account } from './codacy/Account'
1819
import Telemetry from './common/telemetry'
1920
import { decorateWithCoverage } from './views/coverage'
@@ -184,6 +185,7 @@ export async function activate(context: vscode.ExtensionContext) {
184185
context.subscriptions.push(statusBar)
185186
context.subscriptions.push(new PullRequestsTree(context, codacyCloud))
186187
context.subscriptions.push(new BranchIssuesTree(context, codacyCloud))
188+
context.subscriptions.push(new SupportTree(context))
187189

188190
// initialize the problems diagnostic collection with status bar reference
189191
context.subscriptions.push(new ProblemsDiagnosticCollection(codacyCloud, statusBar))

src/views/SupportTree.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}

src/views/nodes/SupportTreeNode.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as vscode from 'vscode'
2+
3+
export class SupportTreeNode extends vscode.TreeItem {
4+
constructor(
5+
label: string,
6+
icon: string,
7+
public readonly url?: string,
8+
public readonly commandName?: string
9+
) {
10+
super(label, vscode.TreeItemCollapsibleState.None)
11+
12+
this.iconPath = new vscode.ThemeIcon(icon)
13+
14+
if (url) {
15+
this.command = {
16+
command: 'vscode.open',
17+
title: 'Open',
18+
arguments: [vscode.Uri.parse(url)],
19+
}
20+
} else if (commandName) {
21+
this.command = {
22+
command: commandName,
23+
title: 'Open',
24+
arguments: [],
25+
}
26+
}
27+
}
28+
}

src/views/nodes/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export * from './PullRequestCoverageNode'
77
export * from './PullRequestAuthorNode'
88
export * from './PullRequestBranchNode'
99
export * from './BranchIssuesTreeNode'
10+
export * from './SupportTreeNode'

0 commit comments

Comments
 (0)