Move form for group creation to own screen
Move the form for the group creation from the GroupListScreen to an own new CreateGroupScreen and add a link to this screen at the beginning of the GroupListScreen. The link to the CreateGroupScreen is only visible if the user has the permission to create new groups. This is consistent with how projects can be created in the WebUI. For the project creation there is also a link at the beginning of the ProjectListScreen to the CreateProjectScreen. Moving the group creation form to an own screen has the advantage that the user doesn't need to scroll down to the very end of the GroupListScreen to find the group creation form. This is annoying if there is a large number of groups. Because of the needed scrolling often users also do not find the group creation form. Change-Id: I474827d843af7470bb154889da3f58bfb7405d1a Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
parent
88531176ec
commit
39ddfd7578
@ -38,6 +38,7 @@ public class PageLinks {
|
||||
|
||||
public static final String MINE = "/";
|
||||
public static final String ADMIN_GROUPS = "/admin/groups/";
|
||||
public static final String ADMIN_CREATE_GROUP = "/admin/create-group/";
|
||||
public static final String ADMIN_PROJECTS = "/admin/projects/";
|
||||
public static final String ADMIN_CREATE_PROJECT = "/admin/create-project/";
|
||||
public static final String ADMIN_PLUGINS = "/admin/plugins/";
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_CREATE_GROUP;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_CREATE_PROJECT;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_GROUPS;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
|
||||
@ -47,6 +48,7 @@ import com.google.gerrit.client.account.ValidateEmailScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupInfoScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupMembersScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupScreen;
|
||||
import com.google.gerrit.client.admin.CreateGroupScreen;
|
||||
import com.google.gerrit.client.admin.CreateProjectScreen;
|
||||
import com.google.gerrit.client.admin.GroupListScreen;
|
||||
import com.google.gerrit.client.admin.PluginListScreen;
|
||||
@ -631,6 +633,10 @@ public class Dispatcher {
|
||||
|| matchExact("/admin/create-project", token)) {
|
||||
Gerrit.display(token, new CreateProjectScreen());
|
||||
|
||||
} else if (matchExact(ADMIN_CREATE_GROUP, token)
|
||||
|| matchExact("/admin/create-group", token)) {
|
||||
Gerrit.display(token, new CreateGroupScreen());
|
||||
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ public interface GerritCss extends CssResource {
|
||||
String contributorAgreementLegal();
|
||||
String contributorAgreementShortDescription();
|
||||
String coverMessage();
|
||||
String createGroupLink();
|
||||
String createProjectLink();
|
||||
String createProjectPanel();
|
||||
String dataCell();
|
||||
|
@ -98,6 +98,7 @@ public interface AdminConstants extends Constants {
|
||||
String groupListOpen();
|
||||
|
||||
String groupListTitle();
|
||||
String createGroupTitle();
|
||||
String groupTabGeneral();
|
||||
String groupTabMembers();
|
||||
String projectListTitle();
|
||||
|
@ -78,6 +78,7 @@ groupListNext = Next group
|
||||
groupListOpen = Open group
|
||||
|
||||
groupListTitle = Groups
|
||||
createGroupTitle = Create Group
|
||||
groupTabGeneral = General
|
||||
groupTabMembers = Members
|
||||
projectListTitle = Projects
|
||||
|
@ -0,0 +1,121 @@
|
||||
// Copyright (C) 2012 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.client.admin;
|
||||
|
||||
import static com.google.gerrit.common.data.GlobalCapability.CREATE_GROUP;
|
||||
|
||||
import com.google.gerrit.client.Dispatcher;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.NotFoundScreen;
|
||||
import com.google.gerrit.client.account.AccountCapabilities;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.client.ui.SmallHeading;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||
|
||||
public class CreateGroupScreen extends Screen {
|
||||
|
||||
private NpTextBox addTxt;
|
||||
private Button addNew;
|
||||
|
||||
public CreateGroupScreen() {
|
||||
super();
|
||||
setRequiresSignIn(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad() {
|
||||
super.onLoad();
|
||||
AccountCapabilities.all(new GerritCallback<AccountCapabilities>() {
|
||||
@Override
|
||||
public void onSuccess(AccountCapabilities ac) {
|
||||
if (ac.canPerform(CREATE_GROUP)) {
|
||||
display();
|
||||
} else {
|
||||
Gerrit.display(PageLinks.ADMIN_CREATE_GROUP, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
}, CREATE_GROUP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitUI() {
|
||||
super.onInitUI();
|
||||
setPageTitle(Util.C.createGroupTitle());
|
||||
addCreateGroupPanel();
|
||||
}
|
||||
|
||||
private void addCreateGroupPanel() {
|
||||
VerticalPanel addPanel = new VerticalPanel();
|
||||
addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
|
||||
addPanel.add(new SmallHeading(Util.C.headingCreateGroup()));
|
||||
|
||||
addTxt = new NpTextBox();
|
||||
addTxt.setVisibleLength(60);
|
||||
addTxt.addKeyPressHandler(new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
|
||||
doCreateGroup();
|
||||
}
|
||||
}
|
||||
});
|
||||
addPanel.add(addTxt);
|
||||
|
||||
addNew = new Button(Util.C.buttonCreateGroup());
|
||||
addNew.setEnabled(false);
|
||||
addNew.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(final ClickEvent event) {
|
||||
doCreateGroup();
|
||||
}
|
||||
});
|
||||
addPanel.add(addNew);
|
||||
add(addPanel);
|
||||
|
||||
new OnEditEnabler(addNew, addTxt);
|
||||
}
|
||||
|
||||
private void doCreateGroup() {
|
||||
final String newName = addTxt.getText();
|
||||
if (newName == null || newName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
addNew.setEnabled(false);
|
||||
Util.GROUP_SVC.createGroup(newName, new GerritCallback<AccountGroup.Id>() {
|
||||
public void onSuccess(final AccountGroup.Id result) {
|
||||
History.newItem(Dispatcher.toGroup(result, AccountGroupScreen.MEMBERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
super.onFailure(caught);
|
||||
addNew.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -14,54 +14,26 @@
|
||||
|
||||
package com.google.gerrit.client.admin;
|
||||
|
||||
import static com.google.gerrit.common.data.GlobalCapability.CREATE_GROUP;
|
||||
|
||||
import com.google.gerrit.client.Dispatcher;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.account.AccountCapabilities;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
import com.google.gerrit.client.ui.AccountScreen;
|
||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||
import com.google.gerrit.client.ui.SmallHeading;
|
||||
import com.google.gerrit.client.ui.Hyperlink;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.common.data.GroupList;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gwt.event.dom.client.BlurEvent;
|
||||
import com.google.gwt.event.dom.client.BlurHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.FocusEvent;
|
||||
import com.google.gwt.event.dom.client.FocusHandler;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||
|
||||
public class GroupListScreen extends AccountScreen {
|
||||
private VerticalPanel createGroupLinkPanel;
|
||||
private GroupTable groups;
|
||||
|
||||
private VerticalPanel addPanel;
|
||||
private NpTextBox addTxt;
|
||||
private Button addNew;
|
||||
|
||||
@Override
|
||||
protected void onLoad() {
|
||||
super.onLoad();
|
||||
addPanel.setVisible(false);
|
||||
AccountCapabilities.all(new GerritCallback<AccountCapabilities>() {
|
||||
@Override
|
||||
public void onSuccess(AccountCapabilities ac) {
|
||||
addPanel.setVisible(ac.canPerform(CREATE_GROUP));
|
||||
}
|
||||
}, CREATE_GROUP);
|
||||
Util.GROUP_SVC
|
||||
.visibleGroups(new ScreenLoadCallback<GroupList>(this) {
|
||||
@Override
|
||||
protected void preDisplay(GroupList result) {
|
||||
createGroupLinkPanel.setVisible(result.isCanCreateGroup());
|
||||
groups.display(result.getGroups());
|
||||
groups.finishDisplay();
|
||||
}
|
||||
@ -73,56 +45,14 @@ public class GroupListScreen extends AccountScreen {
|
||||
super.onInitUI();
|
||||
setPageTitle(Util.C.groupListTitle());
|
||||
|
||||
createGroupLinkPanel = new VerticalPanel();
|
||||
createGroupLinkPanel.setStyleName(Gerrit.RESOURCES.css().createGroupLink());
|
||||
createGroupLinkPanel.add(new Hyperlink(Util.C.headingCreateGroup(),
|
||||
PageLinks.ADMIN_CREATE_GROUP));
|
||||
add(createGroupLinkPanel);
|
||||
|
||||
groups = new GroupTable(true /* hyperlink to admin */, PageLinks.ADMIN_GROUPS);
|
||||
add(groups);
|
||||
|
||||
addPanel = new VerticalPanel();
|
||||
addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
|
||||
addPanel.add(new SmallHeading(Util.C.headingCreateGroup()));
|
||||
|
||||
addTxt = new NpTextBox();
|
||||
addTxt.setVisibleLength(60);
|
||||
addTxt.addKeyPressHandler(new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
|
||||
doCreateGroup();
|
||||
}
|
||||
}
|
||||
});
|
||||
addPanel.add(addTxt);
|
||||
|
||||
addNew = new Button(Util.C.buttonCreateGroup());
|
||||
addNew.setEnabled(false);
|
||||
addNew.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(final ClickEvent event) {
|
||||
doCreateGroup();
|
||||
}
|
||||
});
|
||||
addNew.addFocusHandler(new FocusHandler() {
|
||||
@Override
|
||||
public void onFocus(FocusEvent event) {
|
||||
// unregister the keys for the 'groups' table so that pressing ENTER
|
||||
// when the 'addNew' button has the focus triggers the button (if the
|
||||
// keys for the 'groups' table would not be unregistered the 'addNew'
|
||||
// button would not be triggered on ENTER but the group which is
|
||||
// selected in the 'groups' table would be opened)
|
||||
groups.setRegisterKeys(false);
|
||||
}
|
||||
});
|
||||
addNew.addBlurHandler(new BlurHandler() {
|
||||
@Override
|
||||
public void onBlur(BlurEvent event) {
|
||||
// re-register the keys for the 'groups' table when the 'addNew' button
|
||||
// gets blurred
|
||||
groups.setRegisterKeys(true);
|
||||
}
|
||||
});
|
||||
addPanel.add(addNew);
|
||||
add(addPanel);
|
||||
|
||||
new OnEditEnabler(addNew, addTxt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,24 +60,4 @@ public class GroupListScreen extends AccountScreen {
|
||||
super.registerKeys();
|
||||
groups.setRegisterKeys(true);
|
||||
}
|
||||
|
||||
private void doCreateGroup() {
|
||||
final String newName = addTxt.getText();
|
||||
if (newName == null || newName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
addNew.setEnabled(false);
|
||||
Util.GROUP_SVC.createGroup(newName, new GerritCallback<AccountGroup.Id>() {
|
||||
public void onSuccess(final AccountGroup.Id result) {
|
||||
History.newItem(Dispatcher.toGroup(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
super.onFailure(caught);
|
||||
addNew.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1148,6 +1148,10 @@ a:hover.downloadLink {
|
||||
padding: 5px 5px 5px 5px;
|
||||
}
|
||||
|
||||
.createGroupLink {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.createProjectLink {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user