-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: display branch selection in the tree node [IDE-446] #489
Changes from 6 commits
cd30e1b
f757c5c
4307560
2620908
0a7438b
97fbfaa
bda6578
b6dc508
bfaecb0
ac09779
8c9805c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import _, { flatten } from 'lodash'; | ||
import * as vscode from 'vscode'; // todo: invert dependency | ||
import { IConfiguration, IssueViewOptions } from '../../common/configuration/configuration'; | ||
import { Issue, IssueSeverity } from '../../common/languageServer/types'; | ||
import { Issue, IssueSeverity, ScanProduct } from '../../common/languageServer/types'; | ||
import { messages as commonMessages } from '../../common/messages/analysisMessages'; | ||
import { IContextService } from '../../common/services/contextService'; | ||
import { IProductService } from '../../common/services/productService'; | ||
import { IProductService, ProductService } from '../../common/services/productService'; | ||
import { AnalysisTreeNodeProvider } from '../../common/views/analysisTreeNodeProvider'; | ||
import { INodeIcon, InternalType, NODE_ICONS, TreeNode } from '../../common/views/treeNode'; | ||
import { IVSCodeLanguages } from '../../common/vscode/languages'; | ||
|
@@ -49,6 +49,8 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid | |
filteredIssues?: Issue<T>[], | ||
): Command; | ||
|
||
abstract setBaseBranchCommand(): Command; | ||
|
||
getRootChildren(): TreeNode[] { | ||
const nodes: TreeNode[] = []; | ||
|
||
|
@@ -94,6 +96,12 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid | |
}), | ||
this.getFixableIssuesNode(this.getFixableCount()), | ||
]; | ||
|
||
const isSnykCodeProduct = (this.productService as ProductService<T>).getSnykProductType() === ScanProduct.Code; | ||
if (isSnykCodeProduct) { | ||
topNodes.unshift(this.getBaseBranch()); | ||
} | ||
|
||
const noSeverityFiltersSelectedWarning = this.getNoSeverityFiltersSelectedTreeNode(); | ||
if (noSeverityFiltersSelectedWarning !== null) { | ||
topNodes.push(noSeverityFiltersSelectedWarning); | ||
|
@@ -109,6 +117,20 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid | |
return nodes; | ||
} | ||
|
||
getBaseBranch(): TreeNode | null { | ||
const deltaFindingsEnabled = this.configuration.getDeltaFindingsEnabled(); | ||
|
||
//TODO: get the actual base branch from Snyk Language Server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just ask a config setting, what's the base branch for the folder. LS sends a folderConfig notification for all known workspace folders when they are registered at LS. |
||
if (deltaFindingsEnabled) { | ||
return new TreeNode({ | ||
text: 'Base branch: main', | ||
icon: NODE_ICONS.pencil, | ||
command: this.setBaseBranchCommand(), | ||
}); | ||
} | ||
return null; | ||
} | ||
|
||
getFixableIssuesNode(_fixableIssueCount: number): TreeNode | null { | ||
return null; // optionally overridden by products | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -42,11 +42,13 @@ export default class CodeSecurityIssueTreeProvider extends IssueTreeProvider { | |||||
protected getIssueFoundText(nIssues: number, ignoredIssueCount: number): string { | ||||||
if (nIssues > 0) { | ||||||
let text; | ||||||
|
||||||
if (nIssues === 1) { | ||||||
text = `${nIssues} vulnerability found by Snyk`; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be issues, too?
Suggested change
|
||||||
} else { | ||||||
text = `✋ ${nIssues} vulnerabilities found by Snyk`; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
const isIgnoresEnabled = configuration.getFeatureFlag(FEATURE_FLAGS.consistentIgnores); | ||||||
if (isIgnoresEnabled) { | ||||||
text += `, ${ignoredIssueCount} ignored`; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will probably not stay like this, but use a setting