Use REST DELETE API for deleting reviewers
Pushes more of the error message generation to the server side. Because the DELETE request returns no content, we need to make a second RPC to refresh the approval table after the delete succeeds. Just removing the row from the table is not sufficient since the list of needed labels may have changed. Change-Id: I1d31c9d6c29d268994ce6df3f59310231324ec0e
This commit is contained in:
parent
0a807ab7d9
commit
7609714b2c
@ -35,6 +35,7 @@ import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
@ -440,29 +441,23 @@ public class ApprovalTable extends Composite {
|
||||
fmt.addStyleName(row, col - 1, Gerrit.RESOURCES.css().rightmost());
|
||||
}
|
||||
|
||||
private void doRemove(final ApprovalDetail ad, final PushButton remove) {
|
||||
remove.setEnabled(false);
|
||||
PatchUtil.DETAIL_SVC.removeReviewer(changeId, ad.getAccount(),
|
||||
new GerritCallback<ReviewerResult>() {
|
||||
private void reload() {
|
||||
Util.DETAIL_SVC.changeDetail(changeId,
|
||||
new GerritCallback<ChangeDetail>() {
|
||||
@Override
|
||||
public void onSuccess(ReviewerResult result) {
|
||||
if (result.getErrors().isEmpty()) {
|
||||
final ChangeDetail r = result.getChange();
|
||||
display(r);
|
||||
} else {
|
||||
final ReviewerResult.Error resultError =
|
||||
result.getErrors().get(0);
|
||||
String message;
|
||||
switch (resultError.getType()) {
|
||||
case REMOVE_NOT_PERMITTED:
|
||||
message = Util.C.approvalTableRemoveNotPermitted();
|
||||
break;
|
||||
case COULD_NOT_REMOVE:
|
||||
default:
|
||||
message = Util.C.approvalTableCouldNotRemove();
|
||||
}
|
||||
new ErrorDialog(message + " " + resultError.getName()).center();
|
||||
}
|
||||
public void onSuccess(ChangeDetail result) {
|
||||
display(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doRemove(ApprovalDetail ad, final PushButton remove) {
|
||||
remove.setEnabled(false);
|
||||
ChangeApi.reviewer(changeId.get(), ad.getAccount().get()).delete(
|
||||
new GerritCallback<JavaScriptObject>() {
|
||||
@Override
|
||||
public void onSuccess(JavaScriptObject result) {
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,6 +65,14 @@ public class ChangeApi {
|
||||
return change(id.getParentKey().get()).view("revisions").id(id.get());
|
||||
}
|
||||
|
||||
public static RestApi reviewer(int id, int reviewer) {
|
||||
return change(id).view("reviewers").id(reviewer);
|
||||
}
|
||||
|
||||
public static RestApi reviewer(int id, String reviewer) {
|
||||
return change(id).view("reviewers").id(reviewer);
|
||||
}
|
||||
|
||||
/** Submit a specific revision of a change. */
|
||||
public static void submit(int id, String commit, AsyncCallback<SubmitInfo> cb) {
|
||||
SubmitInput in = SubmitInput.create();
|
||||
|
Loading…
Reference in New Issue
Block a user