Skip to content

Commit 553c8d0

Browse files
feat: add login button to plugin welcome page
1 parent b5956ea commit 553c8d0

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

plugin/OSGI-INF/l10n/bundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ tooltip.showNetNewIssues=Show Only Net New Issues
5050
scanWorkspace.name=snykWorkspaceScan
5151
scanWorkspace.label=Snyk Test Workspace
5252

53-
snyk.trust.dialog.warning.text=When scanning project files for vulnerabilities, Snyk may automatically execute code such as invoking the package manager to get dependency information.<br><br>You should only scan projects you trust.<br><br>
53+
snyk.trust.dialog.warning.text=When scanning project files for vulnerabilities, Snyk may automatically execute code such as invoking the package manager to get dependency information.<br><br>You should only scan projects you trust.
5454

5555

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function navigateToIssue(e, target) {
4545
}
4646
}
4747
}
48+
4849
// Disable AIfix
4950
if(document.getElementById('ai-fix-wrapper') && document.getElementById('no-ai-fix-wrapper')){
5051
document.getElementById('ai-fix-wrapper').className = 'hidden';

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ public static StaticPageHtmlProvider getInstance() {
1919
return instance;
2020
}
2121

22+
2223
public String getInitHtml() {
2324
String snykWarningText = Platform.getResourceString(Platform.getBundle("io.snyk.eclipse.plugin"),
2425
"%snyk.trust.dialog.warning.text");
26+
String snykWarningMoreInfoLabel = Platform.getResourceString(Platform.getBundle("io.snyk.eclipse.plugin"),
27+
"%snyk.trust.dialog.warning.more.info.label");
2528

2629
Bundle bundle = Platform.getBundle("io.snyk.eclipse.plugin");
2730
String base64Image = ResourceUtils.getBase64Image(bundle, "logo_snyk.png");
@@ -60,15 +63,26 @@ public String getInitHtml() {
6063
<img src='data:image/png;base64,%s' alt='Snyk Logo'>
6164
<div>
6265
<p><strong>Welcome to Snyk for Eclipse</strong></p>
63-
<p>%s</p>
64-
By connecting your account with Snyk, you agree to<br>
65-
the Snyk <a href="https://snyk.io/policies/privacy/">Privacy Policy</a>,
66-
and the Snyk <a href="https://snyk.io/policies/terms-of-service/">Terms of Service</a>.
66+
<ol>
67+
<li align="left">Authenticate to Snyk.io</li>
68+
<li align="left">Analyze code for issues and vulnerabilities</li>
69+
<li align="left">Improve your code and upgrade dependencies</li>
70+
</ol>
71+
<p>
72+
<p>
73+
%s <a href="https://docs.snyk.io/ide-tools/jetbrains-plugins/folder-trust">%s</a>
74+
</p>
75+
<button type="button" onclick="window.initiateLogin()">Trust project and scan</button>
76+
<p>
77+
By connecting your account with Snyk, you agree to<br>
78+
the Snyk <a href="https://snyk.io/policies/privacy/">Privacy Policy</a>,
79+
and the Snyk <a href="https://snyk.io/policies/terms-of-service/">Terms of Service</a>.
80+
</p>
6781
</div>
6882
</div>
6983
</body>
7084
</html>
71-
""".formatted(base64Image, snykWarningText);
85+
""".formatted(base64Image, snykWarningText, snykWarningMoreInfoLabel);
7286
return replaceCssVariables(html);
7387
}
7488
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import org.apache.commons.lang3.StringUtils;
77
import org.eclipse.jface.viewers.TreeNode;
8+
import org.eclipse.jface.wizard.WizardDialog;
89
import org.eclipse.lsp4e.LSPEclipseUtils;
910
import org.eclipse.lsp4j.Location;
1011
import org.eclipse.lsp4j.Position;
@@ -17,13 +18,15 @@
1718
import org.eclipse.swt.browser.ProgressEvent;
1819
import org.eclipse.swt.program.Program;
1920
import org.eclipse.swt.widgets.Display;
21+
import org.eclipse.ui.PlatformUI;
2022

2123
import com.google.gson.Gson;
2224

2325
import io.snyk.eclipse.plugin.html.BaseHtmlProvider;
2426
import io.snyk.eclipse.plugin.html.HtmlProviderFactory;
2527
import io.snyk.eclipse.plugin.html.StaticPageHtmlProvider;
2628
import io.snyk.eclipse.plugin.utils.SnykLogger;
29+
import io.snyk.eclipse.plugin.wizards.SnykWizard;
2730

2831
@SuppressWarnings("restriction")
2932
public class BrowserHandler {
@@ -65,6 +68,18 @@ public Object function(Object[] arguments) {
6568
}
6669
};
6770

71+
new BrowserFunction(browser, "initiateLogin") {
72+
@Override
73+
public Object function(Object[] arguments) {
74+
SnykWizard wizard = new SnykWizard();
75+
WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(),wizard);
76+
77+
dialog.setBlockOnOpen(true);
78+
dialog.open();
79+
return null;
80+
}
81+
};
82+
6883
browser.addLocationListener(new LocationListener() {
6984
@Override
7085
public void changing(LocationEvent event) {
@@ -88,7 +103,9 @@ public void completed(ProgressEvent event) {
88103
}
89104
}
90105
});
106+
91107
initBrowserText();
108+
92109
}
93110

94111
private record ErrorMessage(String error, String path) {

0 commit comments

Comments
 (0)