GWT UI: Fix Javascript error on unmarking private on a change
Due to another bug the "Unmark Private" button is shown twice on the change screen. One triggers a DELETE request, the other a POST request. When clicking on the "Unmark Private" button that triggers a POST request the following error occurred in the client:
SEVERE: (TypeError) : Cannot read property 'alert' of null
Class$S171: (TypeError) : Cannot read property 'alert' of null
at Unknown.$alert(gerrit_ui-0.js)
at Unknown.onSuccess_158(gerrit_ui-0.js)
at Unknown.onSuccess_159(gerrit_ui-0.js)
at Unknown.onSuccess_355(gerrit_ui-0.js)
at Unknown.onResponseReceived_1(gerrit_ui-0.js)
at Unknown.fireOnResponseReceived(gerrit_ui-0.js)
at Unknown.onReadyStateChange(gerrit_ui-0.js)
at Unknown.<anonymous>(gerrit_ui-0.js)
at Unknown.apply_9(gerrit_ui-0.js)
at Unknown.entry0(gerrit_ui-0.js)
at Unknown.<anonymous>(gerrit_ui-0.js)
Change-Id: I6f34e258113ee55952bd2d6e0f665622c56a162f
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/api/DefaultActions.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/api/DefaultActions.java
index 74668c1..234df60 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/api/DefaultActions.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/api/DefaultActions.java
@@ -41,6 +41,11 @@
@Override
public void onSuccess(JavaScriptObject in) {
UiResult result = asUiResult(in);
+ if (result == null) {
+ Gerrit.display(target);
+ return;
+ }
+
if (result.alert() != null) {
Window.alert(result.alert());
}