Skip to content

Commit 14be52d

Browse files
committed
fix: added oss filter
1 parent ef58e01 commit 14be52d

8 files changed

Lines changed: 85 additions & 28 deletions

File tree

plugin/plugin.xml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
id="io.snyk.eclipse.plugin.commands.snykFilterFixableIssues"
146146
name="AI Fixable">
147147
</command>
148+
<command
149+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterOssFixableIssuesHandler"
150+
id="io.snyk.eclipse.plugin.commands.snykFilterOssFixableIssues"
151+
name="Fixable">
152+
</command>
148153
<command
149154
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableAllAiFixHandler"
150155
id="io.snyk.eclipse.plugin.snykShowAllSeverities"
@@ -354,19 +359,19 @@
354359
style="push"
355360
tooltip="Show Only Net New Issues">
356361
</command>
357-
<separator
358-
name="io.snyk.eclipse.plugin.separator.allIssues"
359-
visible="true">
360-
</separator>
361-
<command
362-
commandId="io.snyk.eclipse.plugin.command.snykShowAllIssuesStatus"
363-
icon="icons/enabled.png"
364-
style="push"
365-
tooltip="Show all issues">
366-
</command>
367362
</menu>
368363
<menu
369-
id="io.snyk.eclipse.plugin.views.snyktoolview.filtersMenu"
364+
id="io.snyk.eclipse.plugin.views.snyktoolview.filtersAiFixMenu"
365+
label="Open Source Fixability">
366+
<command
367+
commandId="io.snyk.eclipse.plugin.commands.snykFilterOssFixableIssues"
368+
icon="icons/enabled.png"
369+
style="push"
370+
tooltip="Show only issues with Open Source Upgrade suggestions">
371+
</command>
372+
</menu>
373+
<menu
374+
id="io.snyk.eclipse.plugin.views.snyktoolview.filtersOssMenu"
370375
label="Code AI Fixability">
371376
<command
372377
commandId="io.snyk.eclipse.plugin.commands.snykFilterFixableIssues"

plugin/src/main/java/io/snyk/eclipse/plugin/properties/preferences/Preferences.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
5454
public static final String FILTER_IGNORES_SHOW_OPEN_ISSUES = "FILTER_IGNORES_OPEN_ISSUES";
5555
public static final String FILTER_IGNORES_SHOW_IGNORED_ISSUES = "FILTER_IGNORES_IGNORED_ISSUES";
5656
public static final String FILTER_FIXABLE_ISSUES = "FILTER_FIXABLE_ISSUES";
57+
public static final String FILTER_OSS_FIXABLE_ISSUES = "FILTER_OSS_FIXABLE_ISSUES";
5758

5859
// Feature flags
5960
public static final String IS_GLOBAL_IGNORES_FEATURE_ENABLED = "IS_GLOBAL_IGNORES_FEATURE_ENABLED";
@@ -68,6 +69,7 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
6869
public static final String DEFAULT_ENDPOINT = "https://api.snyk.io";
6970
public static final String DEVICE_ID = "deviceId";
7071
public static final String RELEASE_CHANNEL = "releaseChannel";
72+
7173

7274
private final PreferenceStore store;
7375

@@ -112,7 +114,10 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
112114
if (getPref(FILTER_FIXABLE_ISSUES) == null) {
113115
store(FILTER_FIXABLE_ISSUES, "false");
114116
}
115-
117+
if (getPref(FILTER_OSS_FIXABLE_ISSUES) == null) {
118+
store(FILTER_OSS_FIXABLE_ISSUES, "false");
119+
}
120+
116121
if (getPref(SEND_ERROR_REPORTS) == null) {
117122
store(SEND_ERROR_REPORTS, "true");
118123
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/TreeFilterManager.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,9 @@ public synchronized static TreeFilterManager getInstance() {
1919
return filterManager;
2020
}
2121
filterManager = new TreeFilterManager();
22-
setupFilters();
2322
return filterManager;
2423
}
2524

26-
private static void setupFilters() {
27-
String filterFixableIssues = Preferences.FILTER_FIXABLE_ISSUES;
28-
boolean booleanPref = Preferences.getInstance().getBooleanPref(Preferences.FILTER_FIXABLE_ISSUES);
29-
30-
TreeFilterManager filterManager = TreeFilterManager.getInstance();
31-
32-
if (booleanPref) {
33-
filterManager.addTreeFilter(filterFixableIssues, issue -> issue.hasFix());
34-
}
35-
}
36-
3725
private TreeFilterManager() {
3826
treeView = SnykStartup.getView().getTreeViewer();
3927
filter = new TreeViewerFilter();

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/FixableFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public FixableFilter(TreeFilterManager filterManager, Preferences preferences, S
1717

1818
@Override
1919
public void applyFilter() {
20-
boolean booleanPref = this.preferences.getBooleanPref(Preferences.FILTER_FIXABLE_ISSUES);
20+
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey);
2121

2222
if (booleanPref) {
2323
this.filterManager.addTreeFilter(this.preferenceKey, issue -> issue.hasFix());

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/IgnoresFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ public IgnoresFilter(TreeFilterManager filterManager, Preferences preferences, S
1616

1717
@Override
1818
public void applyFilter() {
19-
boolean booleanPref = this.preferences.getBooleanPref(Preferences.FILTER_FIXABLE_ISSUES);
19+
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey);
2020

2121
if (booleanPref) {
2222
filterManager.removeTreeFilter(preferenceKey);
2323
} else {
24-
filterManager.addTreeFilter(preferenceKey, issue -> issue.isIgnored());
24+
filterManager.addTreeFilter(preferenceKey, issue -> !issue.isIgnored());
2525
}
2626

2727
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.snyk.eclipse.plugin.views.snyktoolview.filters;
2+
3+
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
4+
import io.snyk.eclipse.plugin.views.snyktoolview.TreeFilterManager;
5+
6+
public class OssFixableFilter implements BaseFilter {
7+
private TreeFilterManager filterManager;
8+
private Preferences preferences;
9+
private String preferenceKey;
10+
11+
public OssFixableFilter(TreeFilterManager filterManager, Preferences preferences, String preferenceKey) {
12+
this.filterManager = filterManager;
13+
this.preferences = preferences;
14+
this.preferenceKey = preferenceKey;
15+
16+
}
17+
18+
@Override
19+
public void applyFilter() {
20+
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey);
21+
22+
if (booleanPref) {
23+
this.filterManager.addTreeFilter(this.preferenceKey, issue -> issue.hasFix());
24+
} else {
25+
this.filterManager.removeTreeFilter(this.preferenceKey);
26+
}
27+
28+
}
29+
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/filters/SeverityCriticalFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public SeverityCriticalFilter(TreeFilterManager filterManager, Preferences prefe
1717

1818
@Override
1919
public void applyFilter() {
20-
boolean booleanPref = this.preferences.getBooleanPref(preferenceKey);
20+
boolean booleanPref = this.preferences.getBooleanPref(this.preferenceKey);
2121

2222
if (booleanPref) {
2323
this.filterManager.removeTreeFilter(this.preferenceKey);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.snyk.eclipse.plugin.views.snyktoolview.handlers;
2+
3+
import org.eclipse.core.commands.ExecutionEvent;
4+
import org.eclipse.core.commands.ExecutionException;
5+
import org.eclipse.ui.commands.IElementUpdater;
6+
7+
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
8+
import io.snyk.eclipse.plugin.utils.SnykIcons;
9+
import io.snyk.eclipse.plugin.views.snyktoolview.TreeFilterManager;
10+
import io.snyk.eclipse.plugin.views.snyktoolview.filters.OssFixableFilter;
11+
12+
public class FilterOssFixableIssuesHandler extends BaseHandler implements IElementUpdater {
13+
14+
public FilterOssFixableIssuesHandler() {
15+
super();
16+
17+
iconEnabled = SnykIcons.ENABLED;
18+
iconDisabled = SnykIcons.DISABLED;
19+
preferenceKey = Preferences.FILTER_OSS_FIXABLE_ISSUES;
20+
}
21+
22+
@Override
23+
public Object execute(ExecutionEvent event) throws ExecutionException {
24+
super.execute(event);
25+
26+
new OssFixableFilter(TreeFilterManager.getInstance(), Preferences.getInstance(), preferenceKey).applyFilter();
27+
28+
return null;
29+
}
30+
}

0 commit comments

Comments
 (0)