diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/UiCommandDetail.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/UiCommandDetail.java index cd0118605f..557d05c4d1 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/UiCommandDetail.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/UiCommandDetail.java @@ -21,4 +21,5 @@ public class UiCommandDetail { public String label; public String title; public boolean enabled; + public String confirmationMessage; } diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/UiCommand.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/UiCommand.java index be58c1af49..c2eb395a5d 100644 --- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/UiCommand.java +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/UiCommand.java @@ -29,4 +29,5 @@ public interface UiCommand extends RestView { String getTitle(R resource); boolean isVisible(R resource); boolean isEnabled(R resource); + String getConfirmationMessage(R resource); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java index 7baff8a57f..db8881a739 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/PatchSetComplexDisclosurePanel.java @@ -13,6 +13,8 @@ // limitations under the License. package com.google.gerrit.client.changes; +import com.google.gerrit.client.ConfirmationCallback; +import com.google.gerrit.client.ConfirmationDialog; import com.google.gerrit.client.Dispatcher; import com.google.gerrit.client.ErrorDialog; import com.google.gerrit.client.FormatUtil; @@ -55,6 +57,7 @@ import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; import com.google.gwt.user.client.ui.InlineLabel; import com.google.gwt.user.client.ui.Panel; +import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder; import com.google.gwtjsonrpc.common.VoidResult; import java.util.HashSet; @@ -555,6 +558,24 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel b.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { + if (cmd.confirmationMessage != null && + !cmd.confirmationMessage.isEmpty()) { + ConfirmationDialog confirmationDialog = new ConfirmationDialog( + cmd.title, new SafeHtmlBuilder().append(cmd.confirmationMessage), + new ConfirmationCallback() { + @Override + public void onOk() { + postProcessCommand(cmd, b); + } + }); + confirmationDialog.center(); + } else { + postProcessCommand(cmd, b); + } + } + + private void postProcessCommand(final UiCommandDetail cmd, + final Button b) { b.setEnabled(false); AsyncCallback cb = new AsyncCallback() { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/extensions/webui/UiCommands.java b/gerrit-server/src/main/java/com/google/gerrit/server/extensions/webui/UiCommands.java index 0c9626b7b5..fee79ebfd2 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/extensions/webui/UiCommands.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/extensions/webui/UiCommands.java @@ -111,6 +111,7 @@ public class UiCommands { dsc.label = cmd.getLabel(resource); dsc.title = cmd.getTitle(resource); dsc.enabled = cmd.isEnabled(resource); + dsc.confirmationMessage = cmd.getConfirmationMessage(resource); return dsc; } }),