From 21a4dbd0474e08ba978289558ce70843730df313 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 13 May 2014 11:36:55 +0900 Subject: [PATCH 1/3] 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 --- .../client/account/AccountConstants.java | 2 ++ .../account/AccountConstants.properties | 2 ++ .../gerrit/client/account/UsernameField.java | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java index d26ee7df59..5875937ff6 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java @@ -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(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties index 633af29431..38be2d091e 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties @@ -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 diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/UsernameField.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/UsernameField.java index 0666bb3b6a..bf4d75c09b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/UsernameField.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/UsernameField.java @@ -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; From 712dcde2414849a032cad1982e83c76961398471 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 13 May 2014 14:13:21 +0900 Subject: [PATCH 2/3] Remove unused "Change Username" string constant Change-Id: Ic6680cdd47f42138723e800eb1bebe3f9b81591a --- .../java/com/google/gerrit/client/account/AccountConstants.java | 1 - .../com/google/gerrit/client/account/AccountConstants.properties | 1 - 2 files changed, 2 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java index 5875937ff6..b0a61609f7 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.java @@ -64,7 +64,6 @@ public interface AccountConstants extends Constants { String buttonSetUserName(); String confirmSetUserNameTitle(); String confirmSetUserName(); - String buttonChangeUserName(); String buttonClearPassword(); String buttonGeneratePassword(); String linkObtainPassword(); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties index 38be2d091e..787a367610 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/AccountConstants.properties @@ -44,7 +44,6 @@ 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 linkObtainPassword = Obtain Password From 13fab3e23cf6fcaf848c5a3b336a2c19516a7e23 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 13 May 2014 13:45:45 +0900 Subject: [PATCH 3/3] Copy label approvals when cherry-picking change to same branch When a change is cherry-picked to the same branch, it does not create a new change but creates a new patch set on the existing change. In this case, the labels should be copied if configured to do so. Bug: Issue 2652 Change-Id: I761fd1f2d7ccec9bf527cf42eb58ecab0a5db1ce --- .../java/com/google/gerrit/server/change/CherryPickChange.java | 1 + 1 file changed, 1 insertion(+) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java index 391544944c..3ae46025b4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/CherryPickChange.java @@ -206,6 +206,7 @@ public class CherryPickChange { .setMessage("Uploaded patch set " + newPatchSetId.get() + ".") .setDraft(current.isDraft()) .setUploader(uploader.getAccountId()) + .setCopyLabels(true) .insert(); return change.getId(); }