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:
@@ -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 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.OpenIdSsoPanel;
|
||||
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.patches.PatchScreen;
|
||||
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.LinkMenuItem;
|
||||
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.AccountGeneralPreferences;
|
||||
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.core.client.Callback;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
@@ -98,12 +101,14 @@ public class Gerrit implements EntryPoint {
|
||||
private static MorphingTabPanel menuLeft;
|
||||
private static LinkMenuBar menuRight;
|
||||
private static LinkMenuBar diffBar;
|
||||
private static HidingMenuBar projectsBar;
|
||||
private static RootPanel siteHeader;
|
||||
private static RootPanel siteFooter;
|
||||
private static SearchPanel searchPanel;
|
||||
private static final Dispatcher dispatcher = new Dispatcher();
|
||||
private static ViewSite<Screen> body;
|
||||
private static PatchScreen patchScreen;
|
||||
private static Project.NameKey projectKey;
|
||||
private static String lastChangeListToken;
|
||||
|
||||
static {
|
||||
@@ -181,12 +186,18 @@ public class Gerrit implements EntryPoint {
|
||||
patchScreen = (PatchScreen) view;
|
||||
menuLeft.setVisible(diffBar, true);
|
||||
menuLeft.selectTab(menuLeft.getWidgetIndex(diffBar));
|
||||
} else if (view instanceof ProjectScreen) {
|
||||
projectKey = ((ProjectScreen) view).getProjectKey();
|
||||
menuLeft.selectTab(menuLeft.getWidgetIndex(projectsBar));
|
||||
projectsBar.setHideableItemsVisible(true);
|
||||
} else {
|
||||
if (patchScreen != null && menuLeft.getSelectedWidget() == diffBar) {
|
||||
menuLeft.selectTab(isSignedIn() ? 1 : 0);
|
||||
}
|
||||
patchScreen = null;
|
||||
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.menuDiffFiles(), PatchScreen.TopView.FILES);
|
||||
|
||||
final LinkMenuBar projectsBar = new LinkMenuBar();
|
||||
projectKey = null;
|
||||
projectsBar = new HidingMenuBar();
|
||||
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());
|
||||
|
||||
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,
|
||||
final PatchScreen.Type type) {
|
||||
m.addItem(new LinkMenuItem(text, "") {
|
||||
|
||||
@@ -71,6 +71,10 @@ public interface GerritConstants extends Constants {
|
||||
|
||||
String menuProjects();
|
||||
String menuProjectsList();
|
||||
String menuProjectsInfo();
|
||||
String menuProjectsBranches();
|
||||
String menuProjectsAccess();
|
||||
String menuProjectsDashboards();
|
||||
String menuProjectsCreate();
|
||||
|
||||
String menuPeople();
|
||||
|
||||
@@ -54,6 +54,10 @@ menuDiffFiles = Files
|
||||
|
||||
menuProjects = Projects
|
||||
menuProjectsList = List
|
||||
menuProjectsInfo = General
|
||||
menuProjectsBranches = Branches
|
||||
menuProjectsAccess = Access
|
||||
menuProjectsDashboards = Dashboards
|
||||
menuProjectsCreate = Create New Project
|
||||
|
||||
menuPeople = People
|
||||
|
||||
@@ -102,11 +102,7 @@ public interface AdminConstants extends Constants {
|
||||
String groupTabMembers();
|
||||
String projectListTitle();
|
||||
String createProjectTitle();
|
||||
String projectAdminTabGeneral();
|
||||
String projectAdminTabBranches();
|
||||
String projectAdminTabAccess();
|
||||
String projectListQueryLink();
|
||||
String projectAdminTabDashboards();
|
||||
|
||||
String plugins();
|
||||
String pluginEnabled();
|
||||
|
||||
@@ -82,10 +82,6 @@ groupTabGeneral = General
|
||||
groupTabMembers = Members
|
||||
projectListTitle = Projects
|
||||
createProjectTitle = Create Project
|
||||
projectAdminTabGeneral = General
|
||||
projectAdminTabBranches = Branches
|
||||
projectAdminTabAccess = Access
|
||||
projectAdminTabDashboards = Dashboards
|
||||
projectListQueryLink = Search for changes on this project
|
||||
|
||||
plugins = Plugins
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
|
||||
package com.google.gerrit.client.admin;
|
||||
|
||||
import static com.google.gerrit.client.Dispatcher.toProjectAdmin;
|
||||
|
||||
import com.google.gerrit.client.ui.MenuScreen;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
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 BRANCH = "branches";
|
||||
public static final String ACCESS = "access";
|
||||
@@ -29,14 +27,9 @@ public abstract class ProjectScreen extends MenuScreen {
|
||||
|
||||
public ProjectScreen(final Project.NameKey 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user