Skip to content

Commit f22e273

Browse files
committed
feat: handle disable net new scans
1 parent ef5bde3 commit f22e273

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ static String getPlural(long count) {
108108
* @return
109109
*/
110110
abstract void enableDelta();
111+
112+
/**
113+
* Disable the net new issues scans.
114+
*
115+
* @return
116+
*/
117+
abstract void disableDelta();
111118
}

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,15 @@ public void enableDelta() {
283283
String project = node.getText().toString();
284284
String projectPath = node.getPath().toString();
285285
String baseBranch = getBaseBranch(projectPath.toString());
286+
String[] localBranches = getLocalBranches(projectPath).toArray(String[]::new);
286287

287288
item.setText(String.format("Click to choose base branch for: %s [ current: %s ]", project, baseBranch));
288289

289290
Listener selectionListener = new Listener() {
290291
@Override
291292
public void handleEvent(Event event) {
292293
if (event.item == item) {
293-
showPopup(event.display, item);
294+
baseBranchDialog(event.display, projectPath, localBranches);
294295
}
295296
}
296297
};
@@ -303,25 +304,16 @@ public void handleEvent(Event event) {
303304
}
304305
}
305306

306-
private void showPopup(Display display, TreeItem item) {
307+
private void baseBranchDialog(Display display, String projectPath, String[] localBranches) {
307308
Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
308309
shell.setText("Choose base branch for net-new issues scanning");
309310
shell.setLayout(new GridLayout(1, false));
310-
311-
if (!(item.getData() instanceof ContentRootNode))
312-
return;
313-
314-
ContentRootNode node = (ContentRootNode) item.getData();
315-
Path project = node.getPath();
316-
317311
Label label = new Label(shell, SWT.NONE);
318-
label.setText("Base Branch for: " + project);
312+
label.setText("Base Branch for: " + projectPath);
319313
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
320314

321-
List<String> dropdownItems = getLocalBranches(project.toString());
322-
323315
Combo dropdown = new Combo(shell, SWT.DROP_DOWN);
324-
dropdown.setItems(dropdownItems.toArray(new String[0]));
316+
dropdown.setItems(localBranches);
325317
dropdown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
326318

327319
Button okButton = new Button(shell, SWT.PUSH);
@@ -382,8 +374,11 @@ public void disableDelta() {
382374
TreeItem item = entry.getKey();
383375
Listener listener = entry.getValue();
384376

377+
ContentRootNode node = (ContentRootNode) item.getData();
378+
String project = node.getText().toString();
379+
385380
// Revert text to original
386-
item.setText("Project name");
381+
item.setText(project);
387382

388383
// Remove listener from the item's parent
389384
item.getParent().removeListener(SWT.Selection, listener);

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaNewIssuesHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ public FilterDeltaNewIssuesHandler() {
2323
public Object execute(ExecutionEvent event) throws ExecutionException {
2424
super.execute(event);
2525

26-
SnykStartup.getView().enableDelta();
26+
// new DeltaFilter(TreeFilterManager.getInstance(), Preferences.getInstance(), preferenceKey).applyFilter();
27+
28+
boolean booleanPref = Preferences.getInstance().getBooleanPref(this.preferenceKey);
29+
30+
if (booleanPref) {
31+
SnykStartup.getView().enableDelta();
32+
} else {
33+
SnykStartup.getView().disableDelta();
34+
}
2735

2836
return null;
2937
}

0 commit comments

Comments
 (0)