Use account suggestion to suggest assignees

At the moment the assignee suggestion wrongly uses the reviewer
suggestion REST endpoint to suggest assignees. Using the reviewer
suggestion REST endpoint is wrong because it excludes the change owner
and current reviewers from being suggested. This is correct for the
reviewer suggestion, since existing reviewers don't need to be added
as reviewers again. For the assignee suggestion this is unfortunate
since the change owner and the existing reviewers are the most likely
candidates to which the change should be assigned.

Also the reviewer suggestion does recommend reviewers based on
previous activity or other criteria from plugins. These
recommendations don't apply to assignees, and hence the reviewer
suggestion REST endpoint shouldn't be used to suggest assignees.

Bug: Issue 4886
Change-Id: I550ae6b02760fdb9ca5f3364021139e0109df2f1
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-11-04 10:59:35 +01:00
parent 5c84a7d02a
commit 133be1e46a
3 changed files with 10 additions and 19 deletions

View File

@@ -98,7 +98,6 @@ public class Assignee extends Composite {
this.changeId = info.legacyId();
this.canEdit = info.hasActions() && info.actions().containsKey("assignee");
setAssignee(info.assignee());
assigneeSuggestOracle.setChange(changeId);
editAssigneeIcon.setVisible(canEdit);
if (!canEdit) {
show.setTitle(null);

View File

@@ -14,13 +14,12 @@
package com.google.gerrit.client.change;
import com.google.gerrit.client.change.ReviewerSuggestOracle.RestReviewerSuggestion;
import com.google.gerrit.client.change.ReviewerSuggestOracle.SuggestReviewerInfo;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.account.AccountApi;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.AccountSuggestOracle.AccountSuggestion;
import com.google.gerrit.client.ui.SuggestAfterTypingNCharsOracle;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gwt.core.client.JsArray;
import java.util.ArrayList;
@@ -29,22 +28,15 @@ import java.util.List;
/** REST API based suggestion Oracle for assignee */
public class AssigneeSuggestOracle extends SuggestAfterTypingNCharsOracle {
private Change.Id changeId;
public void setChange(Change.Id changeId) {
this.changeId = changeId;
}
@Override
protected void _onRequestSuggestions(Request req, Callback cb) {
ChangeApi
.suggestReviewers(changeId.get(), req.getQuery(), req.getLimit(), true)
.get(new GerritCallback<JsArray<SuggestReviewerInfo>>() {
AccountApi.suggest(req.getQuery(), req.getLimit(),
new GerritCallback<JsArray<AccountInfo>>() {
@Override
public void onSuccess(JsArray<SuggestReviewerInfo> result) {
List<RestReviewerSuggestion> r = new ArrayList<>(result.length());
for (SuggestReviewerInfo reviewer : Natives.asList(result)) {
r.add(new RestReviewerSuggestion(reviewer, req.getQuery()));
public void onSuccess(JsArray<AccountInfo> result) {
List<AccountSuggestion> r = new ArrayList<>(result.length());
for (AccountInfo reviewer : Natives.asList(result)) {
r.add(new AccountSuggestion(reviewer, req.getQuery()));
}
cb.onSuggestionsReady(req, new Response(r));
}

View File

@@ -45,7 +45,7 @@ public class AccountSuggestOracle extends SuggestAfterTypingNCharsOracle {
public static class AccountSuggestion implements SuggestOracle.Suggestion {
private final String suggestion;
AccountSuggestion(AccountInfo info, String query) {
public AccountSuggestion(AccountInfo info, String query) {
this.suggestion = format(info, query);
}