Skip to content

Commit

Permalink
Add feedback to SSH Key Form. #1226
Browse files Browse the repository at this point in the history
if key is empty of can not be parsed, form did provide any feedback to
user before
  • Loading branch information
Martin Spielmann committed May 21, 2017
1 parent 51b9b7f commit c3e317a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gitblit/wicket/pages/BasePage.java
Expand Up @@ -251,7 +251,7 @@ protected void setupPage(String repositoryName, String pageName) {
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)) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -123,6 +124,9 @@ public void onClick(AjaxRequestTarget target) {
"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;
Expand All @@ -134,6 +138,8 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
String data = keyData.getObject();
if (StringUtils.isEmpty(data)) {
// do not submit empty key
error(getString("gb.addSshKeyErrorEmpty"));
target.addComponent(getPage().get("feedback"));
return;
}

Expand All @@ -142,6 +148,8 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
key.getPublicKey();
} catch (Exception e) {
// failed to parse the key
error(getString("gb.addSshKeyErrorFormat"));
target.addComponent(getPage().get("feedback"));
return;
}

Expand Down

0 comments on commit c3e317a

Please sign in to comment.