Merge "Suggest parent for 'create-project' in the UI."
This commit is contained in:
@@ -31,6 +31,7 @@ public interface ProjectAdminService extends RemoteJsonService {
|
|||||||
void visibleProjects(AsyncCallback<ProjectList> callback);
|
void visibleProjects(AsyncCallback<ProjectList> callback);
|
||||||
|
|
||||||
void visibleProjectDetails(AsyncCallback<List<ProjectDetail>> callback);
|
void visibleProjectDetails(AsyncCallback<List<ProjectDetail>> callback);
|
||||||
|
void suggestParentCandidates(AsyncCallback<List<Project>> callback);
|
||||||
|
|
||||||
void projectDetail(Project.NameKey projectName,
|
void projectDetail(Project.NameKey projectName,
|
||||||
AsyncCallback<ProjectDetail> callback);
|
AsyncCallback<ProjectDetail> callback);
|
||||||
|
@@ -48,6 +48,7 @@ public interface AdminConstants extends Constants {
|
|||||||
String descriptionNotifications();
|
String descriptionNotifications();
|
||||||
String buttonSaveGroupOptions();
|
String buttonSaveGroupOptions();
|
||||||
String suggestedGroupLabel();
|
String suggestedGroupLabel();
|
||||||
|
String parentSuggestions();
|
||||||
|
|
||||||
String headingGroupUUID();
|
String headingGroupUUID();
|
||||||
String headingOwner();
|
String headingOwner();
|
||||||
|
@@ -26,6 +26,7 @@ isVisibleToAll = Make group visible to all registered users.
|
|||||||
buttonSaveGroupOptions = Save Group Options
|
buttonSaveGroupOptions = Save Group Options
|
||||||
suggestedGroupLabel = group
|
suggestedGroupLabel = group
|
||||||
headingParentProjectName = Rights Inherit From
|
headingParentProjectName = Rights Inherit From
|
||||||
|
parentSuggestions = Parent Suggestion
|
||||||
columnProjectName = Project Name
|
columnProjectName = Project Name
|
||||||
|
|
||||||
emailOnlyAuthors = Authors
|
emailOnlyAuthors = Authors
|
||||||
|
@@ -20,6 +20,7 @@ import com.google.gerrit.client.Gerrit;
|
|||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.ui.HintTextBox;
|
import com.google.gerrit.client.ui.HintTextBox;
|
||||||
import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
|
import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
|
||||||
|
import com.google.gerrit.client.ui.ProjectsTable;
|
||||||
import com.google.gerrit.client.ui.Screen;
|
import com.google.gerrit.client.ui.Screen;
|
||||||
import com.google.gerrit.reviewdb.Project;
|
import com.google.gerrit.reviewdb.Project;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
@@ -28,6 +29,7 @@ import com.google.gwt.event.dom.client.KeyCodes;
|
|||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||||
import com.google.gwt.user.client.History;
|
import com.google.gwt.user.client.History;
|
||||||
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.CheckBox;
|
import com.google.gwt.user.client.ui.CheckBox;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
@@ -36,6 +38,8 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
|||||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||||
import com.google.gwtjsonrpc.client.VoidResult;
|
import com.google.gwtjsonrpc.client.VoidResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CreateProjectScreen extends Screen {
|
public class CreateProjectScreen extends Screen {
|
||||||
private NpTextBox project;
|
private NpTextBox project;
|
||||||
private Button create;
|
private Button create;
|
||||||
@@ -43,6 +47,7 @@ public class CreateProjectScreen extends Screen {
|
|||||||
private SuggestBox sugestParent;
|
private SuggestBox sugestParent;
|
||||||
private CheckBox emptyCommit;
|
private CheckBox emptyCommit;
|
||||||
private CheckBox permissionsOnly;
|
private CheckBox permissionsOnly;
|
||||||
|
private ProjectsTable suggestedParentsTab;
|
||||||
|
|
||||||
public CreateProjectScreen() {
|
public CreateProjectScreen() {
|
||||||
super();
|
super();
|
||||||
@@ -59,7 +64,6 @@ public class CreateProjectScreen extends Screen {
|
|||||||
protected void onInitUI() {
|
protected void onInitUI() {
|
||||||
super.onInitUI();
|
super.onInitUI();
|
||||||
setPageTitle(Util.C.createProjectTitle());
|
setPageTitle(Util.C.createProjectTitle());
|
||||||
|
|
||||||
addCreateProjectPanel();
|
addCreateProjectPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +82,12 @@ public class CreateProjectScreen extends Screen {
|
|||||||
fp.add(emptyCommit);
|
fp.add(emptyCommit);
|
||||||
fp.add(permissionsOnly);
|
fp.add(permissionsOnly);
|
||||||
fp.add(create);
|
fp.add(create);
|
||||||
add(fp);
|
VerticalPanel vp=new VerticalPanel();
|
||||||
|
vp.add(fp);
|
||||||
|
initSuggestedParents();
|
||||||
|
vp.add(suggestedParentsTab);
|
||||||
|
add(vp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCreateTxt() {
|
private void initCreateTxt() {
|
||||||
@@ -111,6 +120,44 @@ public class CreateProjectScreen extends Screen {
|
|||||||
parent.setVisibleLength(50);
|
parent.setVisibleLength(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initSuggestedParents() {
|
||||||
|
suggestedParentsTab = new ProjectsTable() {
|
||||||
|
{
|
||||||
|
table.setText(0, 1, Util.C.parentSuggestions());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void populate(final int row, final Project k) {
|
||||||
|
final Anchor projectLink = new Anchor(k.getName());
|
||||||
|
projectLink.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
sugestParent.setText(getRowItem(row).getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
table.setWidget(row, 1, projectLink);
|
||||||
|
table.setText(row, 2, k.getDescription());
|
||||||
|
|
||||||
|
setRowItem(row, k);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
suggestedParentsTab.setVisible(false);
|
||||||
|
|
||||||
|
Util.PROJECT_SVC
|
||||||
|
.suggestParentCandidates(new GerritCallback<List<Project>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<Project> result) {
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
suggestedParentsTab.setVisible(true);
|
||||||
|
suggestedParentsTab.display(result);
|
||||||
|
suggestedParentsTab.finishDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void addGrid(final VerticalPanel fp) {
|
private void addGrid(final VerticalPanel fp) {
|
||||||
final Grid grid = new Grid(2, 2);
|
final Grid grid = new Grid(2, 2);
|
||||||
grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
|
grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
|
||||||
|
@@ -42,6 +42,7 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
|||||||
private final ProjectAccessFactory.Factory projectAccessFactory;
|
private final ProjectAccessFactory.Factory projectAccessFactory;
|
||||||
private final CreateProjectHandler.Factory createProjectHandlerFactory;
|
private final CreateProjectHandler.Factory createProjectHandlerFactory;
|
||||||
private final ProjectDetailFactory.Factory projectDetailFactory;
|
private final ProjectDetailFactory.Factory projectDetailFactory;
|
||||||
|
private final SuggestParentCandidatesHandler.Factory suggestParentCandidatesHandlerFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ProjectAdminServiceImpl(final AddBranch.Factory addBranchFactory,
|
ProjectAdminServiceImpl(final AddBranch.Factory addBranchFactory,
|
||||||
@@ -53,6 +54,7 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
|||||||
final VisibleProjectDetails.Factory visibleProjectDetailsFactory,
|
final VisibleProjectDetails.Factory visibleProjectDetailsFactory,
|
||||||
final ProjectAccessFactory.Factory projectAccessFactory,
|
final ProjectAccessFactory.Factory projectAccessFactory,
|
||||||
final ProjectDetailFactory.Factory projectDetailFactory,
|
final ProjectDetailFactory.Factory projectDetailFactory,
|
||||||
|
final SuggestParentCandidatesHandler.Factory parentCandidatesFactory,
|
||||||
final CreateProjectHandler.Factory createNewProjectFactory) {
|
final CreateProjectHandler.Factory createNewProjectFactory) {
|
||||||
this.addBranchFactory = addBranchFactory;
|
this.addBranchFactory = addBranchFactory;
|
||||||
this.changeProjectAccessFactory = changeProjectAccessFactory;
|
this.changeProjectAccessFactory = changeProjectAccessFactory;
|
||||||
@@ -64,6 +66,7 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
|||||||
this.projectAccessFactory = projectAccessFactory;
|
this.projectAccessFactory = projectAccessFactory;
|
||||||
this.projectDetailFactory = projectDetailFactory;
|
this.projectDetailFactory = projectDetailFactory;
|
||||||
this.createProjectHandlerFactory = createNewProjectFactory;
|
this.createProjectHandlerFactory = createNewProjectFactory;
|
||||||
|
this.suggestParentCandidatesHandlerFactory = parentCandidatesFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,6 +79,11 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
|||||||
visibleProjectDetailsFactory.create().to(callback);
|
visibleProjectDetailsFactory.create().to(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void suggestParentCandidates(AsyncCallback<List<Project>> callback) {
|
||||||
|
suggestParentCandidatesHandlerFactory.create().to(callback);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void projectDetail(final Project.NameKey projectName,
|
public void projectDetail(final Project.NameKey projectName,
|
||||||
final AsyncCallback<ProjectDetail> callback) {
|
final AsyncCallback<ProjectDetail> callback) {
|
||||||
|
@@ -38,6 +38,7 @@ public class ProjectModule extends RpcServletModule {
|
|||||||
factory(VisibleProjectDetails.Factory.class);
|
factory(VisibleProjectDetails.Factory.class);
|
||||||
factory(ProjectAccessFactory.Factory.class);
|
factory(ProjectAccessFactory.Factory.class);
|
||||||
factory(ProjectDetailFactory.Factory.class);
|
factory(ProjectDetailFactory.Factory.class);
|
||||||
|
factory(SuggestParentCandidatesHandler.Factory.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
rpc(ProjectAdminServiceImpl.class);
|
rpc(ProjectAdminServiceImpl.class);
|
||||||
|
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2011 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License
|
||||||
|
|
||||||
|
package com.google.gerrit.httpd.rpc.project;
|
||||||
|
|
||||||
|
import com.google.gerrit.httpd.rpc.Handler;
|
||||||
|
import com.google.gerrit.reviewdb.Project;
|
||||||
|
import com.google.gerrit.server.project.SuggestParentCandidates;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SuggestParentCandidatesHandler extends Handler<List<Project>> {
|
||||||
|
interface Factory {
|
||||||
|
SuggestParentCandidatesHandler create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final SuggestParentCandidates suggestParentCandidates;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SuggestParentCandidatesHandler(final SuggestParentCandidates suggestParentCandidates) {
|
||||||
|
this.suggestParentCandidates = suggestParentCandidates;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Project> call() throws Exception {
|
||||||
|
return suggestParentCandidates.getProjects();
|
||||||
|
}
|
||||||
|
}
|
@@ -53,7 +53,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||||||
import com.google.gerrit.server.project.CreateProject;
|
import com.google.gerrit.server.project.CreateProject;
|
||||||
import com.google.gerrit.server.project.PerRequestProjectControlCache;
|
import com.google.gerrit.server.project.PerRequestProjectControlCache;
|
||||||
import com.google.gerrit.server.project.ProjectControl;
|
import com.google.gerrit.server.project.ProjectControl;
|
||||||
import com.google.gerrit.server.project.RetrieveParentCandidates;
|
import com.google.gerrit.server.project.SuggestParentCandidates;
|
||||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||||
import com.google.gerrit.server.query.change.ChangeQueryRewriter;
|
import com.google.gerrit.server.query.change.ChangeQueryRewriter;
|
||||||
import com.google.inject.servlet.RequestScoped;
|
import com.google.inject.servlet.RequestScoped;
|
||||||
@@ -108,6 +108,6 @@ public class GerritRequestModule extends FactoryModule {
|
|||||||
factory(GroupMembers.Factory.class);
|
factory(GroupMembers.Factory.class);
|
||||||
factory(CreateProject.Factory.class);
|
factory(CreateProject.Factory.class);
|
||||||
factory(Submit.Factory.class);
|
factory(Submit.Factory.class);
|
||||||
factory(RetrieveParentCandidates.Factory.class);
|
factory(SuggestParentCandidates.Factory.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,12 +19,15 @@ import com.google.gerrit.server.config.AllProjectsName;
|
|||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public class RetrieveParentCandidates {
|
public class SuggestParentCandidates {
|
||||||
public interface Factory {
|
public interface Factory {
|
||||||
RetrieveParentCandidates create();
|
SuggestParentCandidates create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ProjectControl.Factory projectControlFactory;
|
private final ProjectControl.Factory projectControlFactory;
|
||||||
@@ -32,32 +35,47 @@ public class RetrieveParentCandidates {
|
|||||||
private final AllProjectsName allProject;
|
private final AllProjectsName allProject;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RetrieveParentCandidates(final ProjectControl.Factory projectControlFactory,
|
SuggestParentCandidates(final ProjectControl.Factory projectControlFactory,
|
||||||
final ProjectCache projectCache, final AllProjectsName allProject) {
|
final ProjectCache projectCache, final AllProjectsName allProject) {
|
||||||
this.projectControlFactory = projectControlFactory;
|
this.projectControlFactory = projectControlFactory;
|
||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
this.allProject = allProject;
|
this.allProject = allProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Project.NameKey> get() throws OrmException {
|
public List<Project.NameKey> getNameKeys() throws OrmException,
|
||||||
final Set<Project.NameKey> r = new TreeSet<Project.NameKey>();
|
NoSuchProjectException {
|
||||||
|
List<Project> pList = getProjects();
|
||||||
|
final List<Project.NameKey> nameKeys =
|
||||||
|
new ArrayList<Project.NameKey>(pList.size());
|
||||||
|
for (Project p : pList) {
|
||||||
|
nameKeys.add(p.getNameKey());
|
||||||
|
}
|
||||||
|
return nameKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Project> getProjects() throws OrmException,
|
||||||
|
NoSuchProjectException {
|
||||||
|
Set<Project> projects = new TreeSet<Project>(new Comparator<Project>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Project o1, Project o2) {
|
||||||
|
return o1.getName().compareTo(o2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
for (Project.NameKey p : projectCache.all()) {
|
for (Project.NameKey p : projectCache.all()) {
|
||||||
try {
|
try {
|
||||||
final ProjectControl project = projectControlFactory.controlFor(p);
|
final ProjectControl control = projectControlFactory.controlFor(p);
|
||||||
final Project.NameKey parent = project.getProject().getParent();
|
final Project.NameKey parentK = control.getProject().getParent();
|
||||||
|
if (parentK != null) {
|
||||||
if (parent != null) {
|
ProjectControl pControl = projectControlFactory.controlFor(parentK);
|
||||||
ProjectControl c = projectControlFactory.controlFor(parent);
|
if (pControl.isVisible() || pControl.isOwner()) {
|
||||||
if (c.isVisible() || c.isOwner()) {
|
projects.add(pControl.getProject());
|
||||||
r.add(parent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NoSuchProjectException e) {
|
} catch (NoSuchProjectException e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.add(allProject);
|
projects.add(projectControlFactory.controlFor(allProject).getProject());
|
||||||
return r;
|
return new ArrayList<Project>(projects);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -22,7 +22,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
|||||||
import com.google.gerrit.server.project.CreateProject;
|
import com.google.gerrit.server.project.CreateProject;
|
||||||
import com.google.gerrit.server.project.CreateProjectArgs;
|
import com.google.gerrit.server.project.CreateProjectArgs;
|
||||||
import com.google.gerrit.server.project.ProjectControl;
|
import com.google.gerrit.server.project.ProjectControl;
|
||||||
import com.google.gerrit.server.project.RetrieveParentCandidates;
|
import com.google.gerrit.server.project.SuggestParentCandidates;
|
||||||
import com.google.gerrit.sshd.BaseCommand;
|
import com.google.gerrit.sshd.BaseCommand;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ import org.kohsuke.args4j.Option;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/** Create a new project. **/
|
/** Create a new project. **/
|
||||||
final class CreateProjectCommand extends BaseCommand {
|
final class CreateProjectCommand extends BaseCommand {
|
||||||
@@ -104,7 +103,7 @@ final class CreateProjectCommand extends BaseCommand {
|
|||||||
private CreateProject.Factory CreateProjectFactory;
|
private CreateProject.Factory CreateProjectFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RetrieveParentCandidates.Factory retrieveParentCandidatesFactory;
|
private SuggestParentCandidates.Factory suggestParentCandidatesFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(final Environment env) {
|
public void start(final Environment env) {
|
||||||
@@ -143,8 +142,8 @@ final class CreateProjectCommand extends BaseCommand {
|
|||||||
CreateProjectFactory.create(args);
|
CreateProjectFactory.create(args);
|
||||||
createProject.createProject();
|
createProject.createProject();
|
||||||
} else {
|
} else {
|
||||||
Set<Project.NameKey> parentCandidates =
|
List<Project.NameKey> parentCandidates =
|
||||||
retrieveParentCandidatesFactory.create().get();
|
suggestParentCandidatesFactory.create().getNameKeys();
|
||||||
|
|
||||||
for (Project.NameKey parent : parentCandidates) {
|
for (Project.NameKey parent : parentCandidates) {
|
||||||
p.print(parent + "\n");
|
p.print(parent + "\n");
|
||||||
|
Reference in New Issue
Block a user