Skip to content

Commit accd883

Browse files
committed
fix: hook up browswerfunctions for enable/disable delta
1 parent 4974699 commit accd883

3 files changed

Lines changed: 39 additions & 11 deletions

File tree

plugin/src/main/java/io/snyk/eclipse/plugin/html/BaseHtmlProvider.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public String getNoDescriptionHtml() {
7575
a {
7676
color: var(--link-color)
7777
}
78-
78+
7979
div {
8080
padding: 20px
8181
}
@@ -94,6 +94,13 @@ public String getNoDescriptionHtml() {
9494
return html;
9595
}
9696

97+
public String replaceCssVariables(String html, String ideScript) {
98+
html = replaceCssVariables(html);
99+
html = html.replace("${ideScript}", ideScript);
100+
101+
return html;
102+
}
103+
97104
public String replaceCssVariables(String html) {
98105
// Build the CSS with the nonce
99106
String nonce = getNonce();
@@ -106,8 +113,11 @@ public String replaceCssVariables(String html) {
106113
// Replace CSS variables with actual color values
107114
html = html.replace("var(--text-color)",
108115
getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR", "#000000"));
109-
html = html.replace("var(--ide-background-color)",
110-
getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END", "#FFFFFF"));
116+
117+
// html = html.replace("var(--ide-background-color)",
118+
// getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "#FFFFFF"));
119+
html = html.replace("var(--ide-background-color)", "#2F2F2F");
120+
111121
html = html.replace("var(--background-color)",
112122
getColorAsHex("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END", "#FFFFFF"));
113123
html = html.replace("var(--code-background-color)",
@@ -126,7 +136,6 @@ public String replaceCssVariables(String html) {
126136
html = html.replace("${headerEnd}", "");
127137
html = html.replace("${nonce}", nonce);
128138
html = html.replace("ideNonce", nonce);
129-
html = html.replace("${ideScript}", "");
130139

131140
return html;
132141
}

plugin/src/main/java/io/snyk/eclipse/plugin/html/StaticPageHtmlProvider.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ public String getInitHtml() {
149149
return replaceCssVariables(html);
150150
}
151151

152-
//TODO update this when we got new design from Andy
152+
// TODO update this when we got new design from Andy
153153
public String getSummaryInitHtml() {
154+
154155
var html = """
155156
<!DOCTYPE html>
156157
<html lang="en">
157158
<body>
158159
<div class="container">
159160
<h3 class="summary-header">SUMMARY</h3>
160-
<button type="button" onclick="window.showAllIssuesTab()">All issues</button>
161-
<button type="button" onclick="window.showDeltaIssuesTab()">Delta issues</button>
162-
<div class="summary-row">
161+
<div class="snx-header">
162+
<div class="summary-row">
163163
<span class="icon">⚠️</span>
164164
<span class="text">312 issues found in your project</span>
165165
</div>
@@ -175,7 +175,26 @@ public String getSummaryInitHtml() {
175175
return replaceCssVariables(html);
176176
}
177177

178+
public String ideScript() {
179+
return """
180+
<script>
181+
document.addEventListener('DOMContentLoaded', function() {
182+
const totalIssuesRadio = document.getElementById('totalIssues');
183+
const newIssuesRadio = document.getElementById('newIssues');
184+
185+
totalIssuesRadio.addEventListener('change', function() {
186+
window.totalIssues();
187+
});
188+
189+
newIssuesRadio.addEventListener('change', function() {
190+
window.newIssues();
191+
});
192+
});
193+
</script>
194+
""";
195+
}
196+
178197
public String getFormattedSummaryHtml(String summary) {
179-
return replaceCssVariables(summary);
198+
return replaceCssVariables(summary, ideScript());
180199
}
181200
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public SummaryBrowserHandler(Browser browser) {
1818

1919
public void initialize() {
2020

21-
new BrowserFunction(browser, "showAllIssuesTab") {
21+
new BrowserFunction(browser, "totalIssues") {
2222
@Override
2323
public Object function(Object[] arguments) {
2424
Preferences.getInstance().store(Preferences.ENABLE_DELTA, Boolean.FALSE.toString());
@@ -28,7 +28,7 @@ public Object function(Object[] arguments) {
2828
}
2929
};
3030

31-
new BrowserFunction(browser, "showDeltaIssuesTab") {
31+
new BrowserFunction(browser, "newIssues") {
3232
@Override
3333
public Object function(Object[] arguments) {
3434
Preferences.getInstance().store(Preferences.ENABLE_DELTA, Boolean.TRUE.toString());

0 commit comments

Comments
 (0)