Skip to content

Commit c3e317a

Browse files
author
Martin Spielmann
committed
Add feedback to SSH Key Form. #1226
if key is empty of can not be parsed, form did provide any feedback to user before
1 parent 51b9b7f commit c3e317a

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/main/java/com/gitblit/wicket/GitBlitWebApp.properties

+2
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ gb.emailAddressDescription = The primary email address for receiving notificatio
739739
gb.sshKeys = SSH Keys
740740
gb.sshKeysDescription = SSH public key authentication is a secure alternative to password authentication
741741
gb.addSshKey = Add SSH Key
742+
gb.addSshKeyErrorEmpty = SSH public key empty. Please provide a valid SSH public key
743+
gb.addSshKeyErrorFormat = Not a valid SSH public key format. Please provide a valid SSH public key
742744
gb.key = Key
743745
gb.comment = Comment
744746
gb.sshKeyCommentDescription = Enter an optional comment. If blank, the comment will be extracted from the key data.

src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties

+2
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,8 @@ gb.emailAddressDescription = Die prim\u00e4re Emailadresse f\u00fcr den Empfang
736736
gb.sshKeys = SSH Keys
737737
gb.sshKeysDescription = SSH Public Key Authentifizierung ist eine sichere Alternative zur Authentifizierung mit Passwort
738738
gb.addSshKey = SSH Key hinzuf\u00fcgen
739+
gb.addSshKeyErrorEmpty = SSH Public Key leer. Bitte geben Sie einen g\u00fltigen SSH Public Key an
740+
gb.addSshKeyErrorFormat = SSH Public Key Format ungültig. Bitte geben Sie einen g\u00fltigen SSH Public Key an
739741
gb.key = Key
740742
gb.comment = Kommentar
741743
gb.sshKeyCommentDescription = Geben Sie optional einen Kommentar ein. Falls Sie dies nicht tun, wird der Kommentar aus dem Key extrahiert.

src/main/java/com/gitblit/wicket/pages/BasePage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ protected void setupPage(String repositoryName, String pageName) {
251251
add(rootLink);
252252

253253
// Feedback panel for info, warning, and non-fatal error messages
254-
add(new FeedbackPanel("feedback"));
254+
add(new FeedbackPanel("feedback").setOutputMarkupId(true));
255255

256256
add(new Label("gbVersion", "v" + Constants.getVersion()));
257257
if (app().settings().getBoolean(Keys.web.aggressiveHeapManagement, false)) {

src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
2525
import org.apache.wicket.markup.html.basic.Label;
2626
import org.apache.wicket.markup.html.form.Form;
27+
import org.apache.wicket.markup.html.panel.FeedbackPanel;
2728
import org.apache.wicket.markup.repeater.Item;
2829
import org.apache.wicket.markup.repeater.data.DataView;
2930
import org.apache.wicket.markup.repeater.data.ListDataProvider;
@@ -123,6 +124,9 @@ public void onClick(AjaxRequestTarget target) {
123124
"span5",
124125
keyComment));
125126

127+
// final FeedbackPanel feedback = new FeedbackPanel("feedback");
128+
// feedback.setOutputMarkupId(true);
129+
// addKeyForm.add(feedback);
126130
addKeyForm.add(new AjaxButton("addKeyButton") {
127131

128132
private static final long serialVersionUID = 1L;
@@ -134,6 +138,8 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
134138
String data = keyData.getObject();
135139
if (StringUtils.isEmpty(data)) {
136140
// do not submit empty key
141+
error(getString("gb.addSshKeyErrorEmpty"));
142+
target.addComponent(getPage().get("feedback"));
137143
return;
138144
}
139145

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

0 commit comments

Comments
 (0)