From: Martin Spielmann Date: Sun, 21 May 2017 22:29:08 +0000 (+0200) Subject: Add feedback to SSH Key Form. #1226 X-Git-Tag: r1.9.0~51^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c3e317a28899915036517c3a05a2b883796f633d;p=gitblit.git Add feedback to SSH Key Form. #1226 if key is empty of can not be parsed, form did provide any feedback to user before --- diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index c46bd63d..d8a58943 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -739,6 +739,8 @@ gb.emailAddressDescription = The primary email address for receiving notificatio gb.sshKeys = SSH Keys gb.sshKeysDescription = SSH public key authentication is a secure alternative to password authentication gb.addSshKey = Add SSH Key +gb.addSshKeyErrorEmpty = SSH public key empty. Please provide a valid SSH public key +gb.addSshKeyErrorFormat = Not a valid SSH public key format. Please provide a valid SSH public key gb.key = Key gb.comment = Comment gb.sshKeyCommentDescription = Enter an optional comment. If blank, the comment will be extracted from the key data. diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties index 9599f7eb..3f873cc1 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties @@ -736,6 +736,8 @@ gb.emailAddressDescription = Die prim\u00e4re Emailadresse f\u00fcr den Empfang gb.sshKeys = SSH Keys gb.sshKeysDescription = SSH Public Key Authentifizierung ist eine sichere Alternative zur Authentifizierung mit Passwort gb.addSshKey = SSH Key hinzuf\u00fcgen +gb.addSshKeyErrorEmpty = SSH Public Key leer. Bitte geben Sie einen g\u00fltigen SSH Public Key an +gb.addSshKeyErrorFormat = SSH Public Key Format ungültig. Bitte geben Sie einen g\u00fltigen SSH Public Key an gb.key = Key gb.comment = Kommentar gb.sshKeyCommentDescription = Geben Sie optional einen Kommentar ein. Falls Sie dies nicht tun, wird der Kommentar aus dem Key extrahiert. diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java index 0d99f5e5..bb97ee8c 100644 --- a/src/main/java/com/gitblit/wicket/pages/BasePage.java +++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java @@ -251,7 +251,7 @@ public abstract class BasePage extends SessionPage { add(rootLink); // Feedback panel for info, warning, and non-fatal error messages - add(new FeedbackPanel("feedback")); + add(new FeedbackPanel("feedback").setOutputMarkupId(true)); add(new Label("gbVersion", "v" + Constants.getVersion())); if (app().settings().getBoolean(Keys.web.aggressiveHeapManagement, false)) { diff --git a/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java b/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java index 4b878763..629c58eb 100644 --- a/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java @@ -24,6 +24,7 @@ import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.ajax.markup.html.form.AjaxButton; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; @@ -123,6 +124,9 @@ public class SshKeysPanel extends BasePanel { "span5", keyComment)); +// final FeedbackPanel feedback = new FeedbackPanel("feedback"); +// feedback.setOutputMarkupId(true); +// addKeyForm.add(feedback); addKeyForm.add(new AjaxButton("addKeyButton") { private static final long serialVersionUID = 1L; @@ -134,6 +138,8 @@ public class SshKeysPanel extends BasePanel { String data = keyData.getObject(); if (StringUtils.isEmpty(data)) { // do not submit empty key + error(getString("gb.addSshKeyErrorEmpty")); + target.addComponent(getPage().get("feedback")); return; } @@ -142,6 +148,8 @@ public class SshKeysPanel extends BasePanel { key.getPublicKey(); } catch (Exception e) { // failed to parse the key + error(getString("gb.addSshKeyErrorFormat")); + target.addComponent(getPage().get("feedback")); return; }