Skip to content

Commit 92e41bc

Browse files
authored
feat: add open gh button to the Finding details panel (#103)
* feat: add "Open Remote Issue" button to Finding Details panel title * fix: readme
1 parent 6e40cad commit 92e41bc

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ You can fill detailed information about a finding by clicking on it in the _List
9292

9393
### GitHub/Gitlab Issues
9494

95-
You can create a GitHub/Gitlab issue with the detailed findings information by clicking on the corresponding `Open Remote Issue` button in the _List of Findings_ panel. A browser window in will open prompting you to open the issue with the prefilled information from the _Finding Details_ panel.
95+
You can create a GitHub/Gitlab issue with the detailed findings information by clicking on the corresponding `Open Remote Issue` button in the _List of Findings_ panel or the same button in the _Finding Details_ view. A browser window will open prompting you to open the issue with the prefilled information from the _Finding Details_ panel.
9696

9797
![Open Remote Issue](media/readme/gifs/create_gh_issue.gif)
9898

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
"title": "Open Remote Issue",
7878
"icon": "$(github)"
7979
},
80+
{
81+
"command": "weAudit.openGithubIssueFromDetails",
82+
"title": "Open Remote Issue",
83+
"icon": "$(github)"
84+
},
8085
{
8186
"command": "weAudit.copyEntryPermalink",
8287
"title": "Copy Audit Permalink",
@@ -377,6 +382,11 @@
377382
"command": "weAudit.prevGitConfig",
378383
"when": "view == gitConfig",
379384
"group": "navigation@0"
385+
},
386+
{
387+
"command": "weAudit.openGithubIssueFromDetails",
388+
"when": "view == findingDetails && weAudit.findingDetailsHasEntry",
389+
"group": "navigation"
380390
}
381391
],
382392
"view/item/context": [

src/codeMarker.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,6 +4318,14 @@ export class AuditMarker {
43184318
const entry = treeView.selection[0];
43194319
this.showEntryInFindingDetails(entry);
43204320
});
4321+
4322+
vscode.commands.registerCommand("weAudit.openGithubIssueFromDetails", () => {
4323+
const entry = this.getCurrentlySelectedFullEntry();
4324+
if (entry === undefined) {
4325+
return;
4326+
}
4327+
treeDataProvider.openGithubIssue(entry);
4328+
});
43214329
}
43224330

43234331
private showEntryInFindingDetails(entry: TreeEntry): void {
@@ -4339,6 +4347,28 @@ export class AuditMarker {
43394347
vscode.commands.executeCommand("weAudit.setWebviewFindingDetails", entry.details, entry.label);
43404348
}
43414349

4350+
/**
4351+
* Returns the currently selected tree entry as a FullEntry, ignoring grouping and location-only nodes.
4352+
*/
4353+
private getCurrentlySelectedFullEntry(): FullEntry | undefined {
4354+
if (treeView.selection.length === 0) {
4355+
return;
4356+
}
4357+
4358+
let entry = treeView.selection[0];
4359+
if (isPathOrganizerEntry(entry)) {
4360+
return;
4361+
}
4362+
if (isLocationEntry(entry)) {
4363+
entry = entry.parentEntry;
4364+
}
4365+
if (!isEntry(entry)) {
4366+
return;
4367+
}
4368+
4369+
return entry;
4370+
}
4371+
43424372
/**
43434373
* Selectively reload configurations: if the treeViewMode configuration changed, reload only that.
43444374
* Otherwise, reload all decoration configurations.

src/panels/findingDetailsPanel.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class FindingDetailsProvider implements vscode.WebviewViewProvider {
6969
recommendation: entry.recommendation,
7070
title: title,
7171
});
72+
73+
// Set context to show the "Open Remote Issue" button in the view title
74+
// https://code.visualstudio.com/api/references/when-clause-contexts#add-a-custom-when-clause-context
75+
vscode.commands.executeCommand("setContext", "weAudit.findingDetailsHasEntry", true);
7276
}
7377
}
7478

@@ -80,6 +84,10 @@ class FindingDetailsProvider implements vscode.WebviewViewProvider {
8084
this._view.webview.postMessage({
8185
command: "hide-finding-details",
8286
});
87+
88+
// Set context to show the "Open Remote Issue" button in the view title
89+
// https://code.visualstudio.com/api/references/when-clause-contexts#add-a-custom-when-clause-context
90+
vscode.commands.executeCommand("setContext", "weAudit.findingDetailsHasEntry", false);
8391
}
8492
}
8593

0 commit comments

Comments
 (0)