Replace projects side menus with top menus

The top menus are submenus to the Project Menu and
they appear only when a project has been selected.

Change-Id: Ia520c43ba282d41cbd1bd6f1c880462d05f6df4a
This commit is contained in:
Martin Fick
2012-11-25 15:46:11 -07:00
parent 8e21b9e5be
commit fa058b5f72
7 changed files with 75 additions and 19 deletions

View File

@@ -19,6 +19,7 @@ import static com.google.gerrit.common.data.GlobalCapability.CREATE_PROJECT;
import static com.google.gerrit.common.data.GlobalCapability.CREATE_GROUP; import static com.google.gerrit.common.data.GlobalCapability.CREATE_GROUP;
import com.google.gerrit.client.account.AccountCapabilities; import com.google.gerrit.client.account.AccountCapabilities;
import com.google.gerrit.client.admin.ProjectScreen;
import com.google.gerrit.client.auth.openid.OpenIdSignInDialog; import com.google.gerrit.client.auth.openid.OpenIdSignInDialog;
import com.google.gerrit.client.auth.openid.OpenIdSsoPanel; import com.google.gerrit.client.auth.openid.OpenIdSsoPanel;
import com.google.gerrit.client.auth.userpass.UserPassSignInDialog; import com.google.gerrit.client.auth.userpass.UserPassSignInDialog;
@@ -26,6 +27,7 @@ import com.google.gerrit.client.changes.ChangeConstants;
import com.google.gerrit.client.changes.ChangeListScreen; import com.google.gerrit.client.changes.ChangeListScreen;
import com.google.gerrit.client.patches.PatchScreen; import com.google.gerrit.client.patches.PatchScreen;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.HidingMenuBar;
import com.google.gerrit.client.ui.LinkMenuBar; import com.google.gerrit.client.ui.LinkMenuBar;
import com.google.gerrit.client.ui.LinkMenuItem; import com.google.gerrit.client.ui.LinkMenuItem;
import com.google.gerrit.client.ui.MorphingTabPanel; import com.google.gerrit.client.ui.MorphingTabPanel;
@@ -42,6 +44,7 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountDiffPreference; import com.google.gerrit.reviewdb.client.AccountDiffPreference;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences; import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.client.AuthType; import com.google.gerrit.reviewdb.client.AuthType;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.Callback; import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
@@ -98,12 +101,14 @@ public class Gerrit implements EntryPoint {
private static MorphingTabPanel menuLeft; private static MorphingTabPanel menuLeft;
private static LinkMenuBar menuRight; private static LinkMenuBar menuRight;
private static LinkMenuBar diffBar; private static LinkMenuBar diffBar;
private static HidingMenuBar projectsBar;
private static RootPanel siteHeader; private static RootPanel siteHeader;
private static RootPanel siteFooter; private static RootPanel siteFooter;
private static SearchPanel searchPanel; private static SearchPanel searchPanel;
private static final Dispatcher dispatcher = new Dispatcher(); private static final Dispatcher dispatcher = new Dispatcher();
private static ViewSite<Screen> body; private static ViewSite<Screen> body;
private static PatchScreen patchScreen; private static PatchScreen patchScreen;
private static Project.NameKey projectKey;
private static String lastChangeListToken; private static String lastChangeListToken;
static { static {
@@ -181,12 +186,18 @@ public class Gerrit implements EntryPoint {
patchScreen = (PatchScreen) view; patchScreen = (PatchScreen) view;
menuLeft.setVisible(diffBar, true); menuLeft.setVisible(diffBar, true);
menuLeft.selectTab(menuLeft.getWidgetIndex(diffBar)); menuLeft.selectTab(menuLeft.getWidgetIndex(diffBar));
} else if (view instanceof ProjectScreen) {
projectKey = ((ProjectScreen) view).getProjectKey();
menuLeft.selectTab(menuLeft.getWidgetIndex(projectsBar));
projectsBar.setHideableItemsVisible(true);
} else { } else {
if (patchScreen != null && menuLeft.getSelectedWidget() == diffBar) { if (patchScreen != null && menuLeft.getSelectedWidget() == diffBar) {
menuLeft.selectTab(isSignedIn() ? 1 : 0); menuLeft.selectTab(isSignedIn() ? 1 : 0);
} }
patchScreen = null; patchScreen = null;
menuLeft.setVisible(diffBar, false); menuLeft.setVisible(diffBar, false);
projectKey = null;
projectsBar.setHideableItemsVisible(false);
} }
} }
@@ -653,8 +664,14 @@ public class Gerrit implements EntryPoint {
addDiffLink(diffBar, C.menuDiffPatchSets(), PatchScreen.TopView.PATCH_SETS); addDiffLink(diffBar, C.menuDiffPatchSets(), PatchScreen.TopView.PATCH_SETS);
addDiffLink(diffBar, C.menuDiffFiles(), PatchScreen.TopView.FILES); addDiffLink(diffBar, C.menuDiffFiles(), PatchScreen.TopView.FILES);
final LinkMenuBar projectsBar = new LinkMenuBar(); projectKey = null;
projectsBar = new HidingMenuBar();
addLink(projectsBar, C.menuProjectsList(), PageLinks.ADMIN_PROJECTS); addLink(projectsBar, C.menuProjectsList(), PageLinks.ADMIN_PROJECTS);
addProjectLink(projectsBar, C.menuProjectsInfo(), ProjectScreen.INFO);
addProjectLink(projectsBar, C.menuProjectsBranches(), ProjectScreen.BRANCH);
addProjectLink(projectsBar, C.menuProjectsAccess(), ProjectScreen.ACCESS);
addProjectLink(projectsBar, C.menuProjectsDashboards(), ProjectScreen.DASHBOARDS);
projectsBar.setHideableItemsVisible(false);
menuLeft.add(projectsBar, C.menuProjects()); menuLeft.add(projectsBar, C.menuProjects());
if (signedIn) { if (signedIn) {
@@ -792,6 +809,19 @@ public class Gerrit implements EntryPoint {
}); });
} }
private static void addProjectLink(final HidingMenuBar m, final String text,
final String panel) {
m.addHideableItem(new LinkMenuItem(text, "") {
@Override
public void go() {
if (projectKey != null) {
display(Dispatcher.toProjectAdmin(projectKey, panel));
}
AnchorElement.as(getElement()).blur();
}
});
}
private static void addDiffLink(final LinkMenuBar m, final String text, private static void addDiffLink(final LinkMenuBar m, final String text,
final PatchScreen.Type type) { final PatchScreen.Type type) {
m.addItem(new LinkMenuItem(text, "") { m.addItem(new LinkMenuItem(text, "") {

View File

@@ -71,6 +71,10 @@ public interface GerritConstants extends Constants {
String menuProjects(); String menuProjects();
String menuProjectsList(); String menuProjectsList();
String menuProjectsInfo();
String menuProjectsBranches();
String menuProjectsAccess();
String menuProjectsDashboards();
String menuProjectsCreate(); String menuProjectsCreate();
String menuPeople(); String menuPeople();

View File

@@ -54,6 +54,10 @@ menuDiffFiles = Files
menuProjects = Projects menuProjects = Projects
menuProjectsList = List menuProjectsList = List
menuProjectsInfo = General
menuProjectsBranches = Branches
menuProjectsAccess = Access
menuProjectsDashboards = Dashboards
menuProjectsCreate = Create New Project menuProjectsCreate = Create New Project
menuPeople = People menuPeople = People

View File

@@ -102,11 +102,7 @@ public interface AdminConstants extends Constants {
String groupTabMembers(); String groupTabMembers();
String projectListTitle(); String projectListTitle();
String createProjectTitle(); String createProjectTitle();
String projectAdminTabGeneral();
String projectAdminTabBranches();
String projectAdminTabAccess();
String projectListQueryLink(); String projectListQueryLink();
String projectAdminTabDashboards();
String plugins(); String plugins();
String pluginEnabled(); String pluginEnabled();

View File

@@ -82,10 +82,6 @@ groupTabGeneral = General
groupTabMembers = Members groupTabMembers = Members
projectListTitle = Projects projectListTitle = Projects
createProjectTitle = Create Project createProjectTitle = Create Project
projectAdminTabGeneral = General
projectAdminTabBranches = Branches
projectAdminTabAccess = Access
projectAdminTabDashboards = Dashboards
projectListQueryLink = Search for changes on this project projectListQueryLink = Search for changes on this project
plugins = Plugins plugins = Plugins

View File

@@ -14,12 +14,10 @@
package com.google.gerrit.client.admin; package com.google.gerrit.client.admin;
import static com.google.gerrit.client.Dispatcher.toProjectAdmin; import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.client.ui.MenuScreen;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
public abstract class ProjectScreen extends MenuScreen { public abstract class ProjectScreen extends Screen {
public static final String INFO = "info"; public static final String INFO = "info";
public static final String BRANCH = "branches"; public static final String BRANCH = "branches";
public static final String ACCESS = "access"; public static final String ACCESS = "access";
@@ -29,14 +27,9 @@ public abstract class ProjectScreen extends MenuScreen {
public ProjectScreen(final Project.NameKey toShow) { public ProjectScreen(final Project.NameKey toShow) {
name = toShow; name = toShow;
link(Util.C.projectAdminTabGeneral(), toProjectAdmin(name, INFO));
link(Util.C.projectAdminTabBranches(), toProjectAdmin(name, BRANCH));
link(Util.C.projectAdminTabAccess(), toProjectAdmin(name, ACCESS));
link(Util.C.projectAdminTabDashboards(), toProjectAdmin(name, DASHBOARDS));
} }
protected Project.NameKey getProjectKey() { public Project.NameKey getProjectKey() {
return name; return name;
} }

View File

@@ -0,0 +1,33 @@
// 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.ui;
import java.util.HashSet;
import java.util.Set;
public class HidingMenuBar extends LinkMenuBar {
Set<LinkMenuItem> hideableItems = new HashSet<LinkMenuItem>();
public void addHideableItem(final LinkMenuItem item) {
hideableItems.add(item);
addItem(item);
}
public void setHideableItemsVisible(boolean visible) {
for(LinkMenuItem item: hideableItems) {
item.setVisible(visible);
}
}
}