ChangeScreen: Use submit type from ChangeInfo
Avoids an extra request to /revisions/current/submit_type. Change-Id: Iefc1531f3b2b64a8ecf58007d8f2e47df0771ca9
This commit is contained in:
@@ -19,6 +19,7 @@ import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -139,6 +140,15 @@ public class ChangeInfo extends JavaScriptObject {
|
||||
public final native boolean _more_changes()
|
||||
/*-{ return this._more_changes ? true : false; }-*/;
|
||||
|
||||
public final SubmitType submitType() {
|
||||
String submitType = _submitType();
|
||||
if (submitType == null) {
|
||||
return null;
|
||||
}
|
||||
return SubmitType.valueOf(submitType);
|
||||
}
|
||||
private final native String _submitType() /*-{ return this.submit_type; }-*/;
|
||||
|
||||
public final boolean submittable() {
|
||||
init();
|
||||
return _submittable();
|
||||
|
||||
@@ -45,7 +45,6 @@ import com.google.gerrit.client.projects.ConfigInfoCache.Entry;
|
||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.client.rpc.RestApi;
|
||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
@@ -1055,33 +1054,16 @@ public class ChangeScreen extends Screen {
|
||||
}));
|
||||
}
|
||||
|
||||
private void loadSubmitType(final Change.Status status, final boolean canSubmit) {
|
||||
if (canSubmit) {
|
||||
if (status == Change.Status.NEW) {
|
||||
statusText.setInnerText(Util.C.readyToSubmit());
|
||||
}
|
||||
}
|
||||
ChangeApi.revision(changeId.get(), revision)
|
||||
.view("submit_type")
|
||||
.get(new AsyncCallback<NativeString>() {
|
||||
@Override
|
||||
public void onSuccess(NativeString result) {
|
||||
if (canSubmit) {
|
||||
if (status == Change.Status.NEW) {
|
||||
private void renderSubmitType(Change.Status status, boolean canSubmit,
|
||||
SubmitType submitType) {
|
||||
if (canSubmit && status == Change.Status.NEW) {
|
||||
statusText.setInnerText(changeInfo.mergeable()
|
||||
? Util.C.readyToSubmit()
|
||||
: Util.C.mergeConflict());
|
||||
}
|
||||
}
|
||||
setVisible(notMergeable, !changeInfo.mergeable());
|
||||
|
||||
renderSubmitType(result.asString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
submitActionText.setInnerText(
|
||||
com.google.gerrit.client.admin.Util.toLongString(submitType));
|
||||
}
|
||||
|
||||
private RevisionInfo resolveRevisionToDisplay(ChangeInfo info) {
|
||||
@@ -1243,7 +1225,7 @@ public class ChangeScreen extends Screen {
|
||||
|
||||
if (current && info.status().isOpen()) {
|
||||
quickApprove.set(info, revision, replyAction);
|
||||
loadSubmitType(info.status(), isSubmittable(info));
|
||||
renderSubmitType(info.status(), isSubmittable(info), info.submitType());
|
||||
} else {
|
||||
quickApprove.setVisible(false);
|
||||
}
|
||||
@@ -1348,16 +1330,6 @@ public class ChangeScreen extends Screen {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void renderSubmitType(String action) {
|
||||
try {
|
||||
SubmitType type = SubmitType.valueOf(action);
|
||||
submitActionText.setInnerText(
|
||||
com.google.gerrit.client.admin.Util.toLongString(type));
|
||||
} catch (IllegalArgumentException e) {
|
||||
submitActionText.setInnerText(action);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderActionTextDate(ChangeInfo info) {
|
||||
String action;
|
||||
if (info.created().equals(info.updated())) {
|
||||
|
||||
Reference in New Issue
Block a user