Require the user to confirm setting the username
Once the username has been set, it cannot be edited. This can cause problems for users who accidentally set the wrong username. Add a confirmation dialog that warns the user that setting the username is permanent. Only set the username when the user confirms. Bug: Issue 2654 Change-Id: Id8fb7f8e3d984205a60363863fd2ec925ceae105
This commit is contained in:
@@ -62,6 +62,8 @@ public interface AccountConstants extends Constants {
|
||||
String userName();
|
||||
String password();
|
||||
String buttonSetUserName();
|
||||
String confirmSetUserNameTitle();
|
||||
String confirmSetUserName();
|
||||
String buttonChangeUserName();
|
||||
String buttonClearPassword();
|
||||
String buttonGeneratePassword();
|
||||
|
||||
@@ -42,6 +42,8 @@ buttonAddSshKey = Add
|
||||
userName = Username
|
||||
password = Password
|
||||
buttonSetUserName = Select Username
|
||||
confirmSetUserNameTitle = Confirm Setting the Username
|
||||
confirmSetUserName Setting the Username is permanent. Are you sure?
|
||||
buttonChangeUserName = Change Username
|
||||
buttonClearPassword = Clear Password
|
||||
buttonGeneratePassword = Generate Password
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.client.account;
|
||||
|
||||
import com.google.gerrit.client.ConfirmationCallback;
|
||||
import com.google.gerrit.client.ConfirmationDialog;
|
||||
import com.google.gerrit.client.ErrorDialog;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
@@ -31,6 +33,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwtexpui.clippy.client.CopyableLabel;
|
||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
||||
import com.google.gwtjsonrpc.common.VoidResult;
|
||||
|
||||
class UsernameField extends Composite {
|
||||
@@ -59,7 +62,7 @@ class UsernameField extends Composite {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
|
||||
doSetUserName();
|
||||
confirmSetUserName();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -70,7 +73,7 @@ class UsernameField extends Composite {
|
||||
setUserName.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(final ClickEvent event) {
|
||||
doSetUserName();
|
||||
confirmSetUserName();
|
||||
}
|
||||
});
|
||||
new OnEditEnabler(setUserName, userNameTxt);
|
||||
@@ -86,6 +89,18 @@ class UsernameField extends Composite {
|
||||
return Gerrit.getConfig().canEdit(Account.FieldName.USER_NAME);
|
||||
}
|
||||
|
||||
private void confirmSetUserName() {
|
||||
new ConfirmationDialog(
|
||||
Util.C.confirmSetUserNameTitle(),
|
||||
new SafeHtmlBuilder().append(Util.C.confirmSetUserName()),
|
||||
new ConfirmationCallback() {
|
||||
@Override
|
||||
public void onOk() {
|
||||
doSetUserName();
|
||||
}
|
||||
}).center();
|
||||
}
|
||||
|
||||
private void doSetUserName() {
|
||||
if (!canEditUserName()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user