Adapt WebUI to use REST for suggesting branches for cherry-pick

Adapt the cherry-pick dialog to use the REST endpoint for listing
branches to suggest branch names to the user.

The old RPC to list branches is deleted since it is not used anymore.

Change-Id: I13a6894d4a5f1e3cdb6e8e2682992a742d7660a4
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-06-07 14:08:49 +02:00
committed by David Pursehouse
parent e327e536d7
commit b5f15620b0
3 changed files with 14 additions and 25 deletions

View File

@@ -50,7 +50,4 @@ public interface ProjectAdminService extends RemoteJsonService {
void reviewProjectAccess(Project.NameKey projectName, String baseRevision,
String message, List<AccessSection> sections,
AsyncCallback<Change.Id> callback);
void listBranches(Project.NameKey projectName,
AsyncCallback<ListBranchesResult> callback);
}

View File

@@ -15,10 +15,12 @@
package com.google.gerrit.client.ui;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.projects.BranchInfo;
import com.google.gerrit.client.projects.ProjectApi;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.common.data.ListBranchesResult;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
@@ -30,16 +32,16 @@ import java.util.List;
public abstract class CherryPickDialog extends ActionDialog {
private SuggestBox newBranch;
private List<Branch> branches;
private List<BranchInfo> branches;
public CherryPickDialog(final FocusWidget enableOnFailure, Project.NameKey project) {
super(enableOnFailure, true, Util.C.cherryPickTitle(), Util.C
.cherryPickCommitMessage());
com.google.gerrit.client.account.Util.PROJECT_SVC.listBranches(project,
new GerritCallback<ListBranchesResult>() {
ProjectApi.getBranches(project,
new GerritCallback<JsArray<BranchInfo>>() {
@Override
public void onSuccess(ListBranchesResult result) {
branches = result.getBranches();
public void onSuccess(JsArray<BranchInfo> result) {
branches = Natives.asList(result);
}
});
@@ -48,8 +50,8 @@ public abstract class CherryPickDialog extends ActionDialog {
protected void onRequestSuggestions(Request request, Callback done) {
LinkedList<BranchSuggestion> suggestions =
new LinkedList<BranchSuggestion>();
for (final Branch b : branches) {
if (b.getName().indexOf(request.getQuery()) >= 0) {
for (final BranchInfo b : branches) {
if (b.ref().indexOf(request.getQuery()) >= 0) {
suggestions.add(new BranchSuggestion(b));
}
}
@@ -75,15 +77,15 @@ public abstract class CherryPickDialog extends ActionDialog {
}
class BranchSuggestion implements Suggestion {
private Branch branch;
private BranchInfo branch;
public BranchSuggestion(Branch branch) {
public BranchSuggestion(BranchInfo branch) {
this.branch = branch;
}
@Override
public String getDisplayString() {
return branch.getName();
return branch.ref();
}
@Override

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.httpd.rpc.project;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.ListBranchesResult;
import com.google.gerrit.common.data.ProjectAccess;
import com.google.gerrit.common.data.ProjectAdminService;
import com.google.gerrit.common.data.ProjectDetail;
@@ -32,7 +31,6 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
private final ChangeProjectAccess.Factory changeProjectAccessFactory;
private final ReviewProjectAccess.Factory reviewProjectAccessFactory;
private final ChangeProjectSettings.Factory changeProjectSettingsFactory;
private final ListBranches.Factory listBranchesFactory;
private final VisibleProjectDetails.Factory visibleProjectDetailsFactory;
private final ProjectAccessFactory.Factory projectAccessFactory;
private final ProjectDetailFactory.Factory projectDetailFactory;
@@ -41,14 +39,12 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
ProjectAdminServiceImpl(final ChangeProjectAccess.Factory changeProjectAccessFactory,
final ReviewProjectAccess.Factory reviewProjectAccessFactory,
final ChangeProjectSettings.Factory changeProjectSettingsFactory,
final ListBranches.Factory listBranchesFactory,
final VisibleProjectDetails.Factory visibleProjectDetailsFactory,
final ProjectAccessFactory.Factory projectAccessFactory,
final ProjectDetailFactory.Factory projectDetailFactory) {
this.changeProjectAccessFactory = changeProjectAccessFactory;
this.reviewProjectAccessFactory = reviewProjectAccessFactory;
this.changeProjectSettingsFactory = changeProjectSettingsFactory;
this.listBranchesFactory = listBranchesFactory;
this.visibleProjectDetailsFactory = visibleProjectDetailsFactory;
this.projectAccessFactory = projectAccessFactory;
this.projectDetailFactory = projectDetailFactory;
@@ -97,10 +93,4 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
AsyncCallback<Change.Id> cb) {
reviewProjectAccessFactory.create(projectName, getBase(baseRevision), sections, msg).to(cb);
}
@Override
public void listBranches(final Project.NameKey projectName,
final AsyncCallback<ListBranchesResult> callback) {
listBranchesFactory.create(projectName).to(callback);
}
}