Merge "Create enum containing all Gerrit top menu items"
This commit is contained in:
@@ -837,7 +837,7 @@ public class MyTopMenuExtension implements TopMenu {
|
||||
@Override
|
||||
public List<MenuEntry> getEntries() {
|
||||
return Lists.newArrayList(
|
||||
new MenuEntry("Projects", Lists.newArrayList(
|
||||
new MenuEntry(GerritTopMenu.PROJECTS, Lists.newArrayList(
|
||||
new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/"))));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,21 @@
|
||||
SRCS = glob(['src/main/java/com/google/gerrit/extensions/**/*.java'])
|
||||
SRC = 'src/main/java/com/google/gerrit/extensions/'
|
||||
|
||||
gwt_module(
|
||||
name = 'client',
|
||||
srcs = glob([SRC + 'webui/GerritTopMenu.java']),
|
||||
gwtxml = SRC + 'Extensions.gwt.xml',
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
java_library2(
|
||||
name = 'api',
|
||||
srcs = SRCS,
|
||||
srcs = glob([SRC + '**/*.java']),
|
||||
compile_deps = ['//lib/guice:guice'],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
java_sources(
|
||||
name = 'api-src',
|
||||
srcs = SRCS,
|
||||
srcs = glob([SRC + '**/*.java']),
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
@@ -0,0 +1,18 @@
|
||||
<!--
|
||||
Copyright (C) 2013 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.
|
||||
-->
|
||||
<module>
|
||||
<source path='webui' />
|
||||
</module>
|
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2013 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.extensions.webui;
|
||||
|
||||
public enum GerritTopMenu {
|
||||
ALL, MY, DIFFERENCES, PROJECTS, PEOPLE, PLUGINS, DOCUMENTATION;
|
||||
|
||||
public final String menuName;
|
||||
|
||||
private GerritTopMenu() {
|
||||
menuName = name().substring(0, 1) + name().substring(1).toLowerCase();
|
||||
}
|
||||
}
|
@@ -20,11 +20,14 @@ import java.util.List;
|
||||
|
||||
@ExtensionPoint
|
||||
public interface TopMenu {
|
||||
|
||||
public class MenuEntry {
|
||||
public final String name;
|
||||
public final List<MenuItem> items;
|
||||
|
||||
public MenuEntry(GerritTopMenu gerritMenu, List<MenuItem> items) {
|
||||
this(gerritMenu.menuName, items);
|
||||
}
|
||||
|
||||
public MenuEntry(String name, List<MenuItem> items) {
|
||||
this.name = name;
|
||||
this.items = items;
|
||||
|
@@ -70,6 +70,7 @@ gwt_module(
|
||||
'//gerrit-gwtexpui:SafeHtml',
|
||||
'//gerrit-gwtexpui:UserAgent',
|
||||
'//gerrit-common:client',
|
||||
'//gerrit-extension-api:client',
|
||||
'//gerrit-patch-jgit:client',
|
||||
'//gerrit-prettify:client',
|
||||
'//gerrit-reviewdb:client',
|
||||
@@ -117,6 +118,7 @@ java_test(
|
||||
deps = [
|
||||
':ui_module',
|
||||
'//gerrit-common:client',
|
||||
'//gerrit-extension-api:client',
|
||||
'//lib:junit',
|
||||
'//lib/gwt:dev',
|
||||
'//lib/gwt:user',
|
||||
|
@@ -24,6 +24,7 @@
|
||||
<inherits name='com.google.gwtexpui.linker.ServerPlannedIFrameLinker'/>
|
||||
<inherits name='com.google.gwtexpui.progress.Progress'/>
|
||||
<inherits name='com.google.gwtexpui.safehtml.SafeHtml'/>
|
||||
<inherits name='com.google.gerrit.extensions.Extensions'/>
|
||||
<inherits name='com.google.gerrit.prettify.PrettyFormatter'/>
|
||||
<inherits name='com.google.gerrit.Common'/>
|
||||
<inherits name='com.google.gerrit.UserAgent'/>
|
||||
|
@@ -42,6 +42,7 @@ import com.google.gerrit.common.data.GerritConfig;
|
||||
import com.google.gerrit.common.data.GitwebConfig;
|
||||
import com.google.gerrit.common.data.HostPageData;
|
||||
import com.google.gerrit.common.data.SystemInfoService;
|
||||
import com.google.gerrit.extensions.webui.GerritTopMenu;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||
@@ -113,13 +114,6 @@ public class Gerrit implements EntryPoint {
|
||||
private static AccountDiffPreference myAccountDiffPref;
|
||||
private static String xGerritAuth;
|
||||
|
||||
private static final String ALL_BAR = "All";
|
||||
private static final String MY_BAR = "My";
|
||||
private static final String DIFF_BAR = "Differences";
|
||||
private static final String PROJECTS_BAR = "Projects";
|
||||
private static final String PEOPLE_BAR = "People";
|
||||
private static final String PLUGINS_BAR = "Plugins";
|
||||
private static final String DOCUMENTATION_BAR = "Documentation";
|
||||
private static Map<String, LinkMenuBar> menuBars;
|
||||
|
||||
private static MorphingTabPanel menuLeft;
|
||||
@@ -210,7 +204,7 @@ public class Gerrit implements EntryPoint {
|
||||
* @param view the loaded view.
|
||||
*/
|
||||
public static void updateMenus(Screen view) {
|
||||
LinkMenuBar diffBar = menuBars.get(DIFF_BAR);
|
||||
LinkMenuBar diffBar = menuBars.get(GerritTopMenu.DIFFERENCES.menuName);
|
||||
if (view instanceof PatchScreen) {
|
||||
patchScreen = (PatchScreen) view;
|
||||
menuLeft.setVisible(diffBar, true);
|
||||
@@ -671,7 +665,7 @@ public class Gerrit implements EntryPoint {
|
||||
LinkMenuBar m;
|
||||
|
||||
m = new LinkMenuBar();
|
||||
menuBars.put(ALL_BAR, m);
|
||||
menuBars.put(GerritTopMenu.ALL.menuName, m);
|
||||
addLink(m, C.menuAllOpen(), PageLinks.toChangeQuery("status:open"));
|
||||
addLink(m, C.menuAllMerged(), PageLinks.toChangeQuery("status:merged"));
|
||||
addLink(m, C.menuAllAbandoned(), PageLinks.toChangeQuery("status:abandoned"));
|
||||
@@ -679,7 +673,7 @@ public class Gerrit implements EntryPoint {
|
||||
|
||||
if (signedIn) {
|
||||
m = new LinkMenuBar();
|
||||
menuBars.put(MY_BAR, m);
|
||||
menuBars.put(GerritTopMenu.MY.menuName, m);
|
||||
addLink(m, C.menuMyChanges(), PageLinks.MINE);
|
||||
addLink(m, C.menuMyDrafts(), PageLinks.toChangeQuery("is:draft"));
|
||||
addLink(m, C.menuMyDraftComments(), PageLinks.toChangeQuery("has:draft"));
|
||||
@@ -693,7 +687,7 @@ public class Gerrit implements EntryPoint {
|
||||
|
||||
patchScreen = null;
|
||||
LinkMenuBar diffBar = new LinkMenuBar();
|
||||
menuBars.put(DIFF_BAR, diffBar);
|
||||
menuBars.put(GerritTopMenu.DIFFERENCES.menuName, diffBar);
|
||||
menuLeft.addInvisible(diffBar, C.menuDiff());
|
||||
addDiffLink(diffBar, CC.patchTableDiffSideBySide(), PatchScreen.Type.SIDE_BY_SIDE);
|
||||
addDiffLink(diffBar, CC.patchTableDiffUnified(), PatchScreen.Type.UNIFIED);
|
||||
@@ -710,7 +704,7 @@ public class Gerrit implements EntryPoint {
|
||||
}
|
||||
}
|
||||
};
|
||||
menuBars.put(PROJECTS_BAR, projectsBar);
|
||||
menuBars.put(GerritTopMenu.PROJECTS.menuName, projectsBar);
|
||||
addLink(projectsBar, C.menuProjectsList(), PageLinks.ADMIN_PROJECTS);
|
||||
addProjectLink(projectsBar, C.menuProjectsInfo(), ProjectScreen.INFO);
|
||||
addProjectLink(projectsBar, C.menuProjectsBranches(), ProjectScreen.BRANCH);
|
||||
@@ -722,13 +716,13 @@ public class Gerrit implements EntryPoint {
|
||||
|
||||
if (signedIn) {
|
||||
final LinkMenuBar peopleBar = new LinkMenuBar();
|
||||
menuBars.put(PEOPLE_BAR, peopleBar);
|
||||
menuBars.put(GerritTopMenu.PEOPLE.menuName, peopleBar);
|
||||
final LinkMenuItem groupsListMenuItem =
|
||||
addLink(peopleBar, C.menuPeopleGroupsList(), PageLinks.ADMIN_GROUPS);
|
||||
menuLeft.add(peopleBar, C.menuPeople());
|
||||
|
||||
final LinkMenuBar pluginsBar = new LinkMenuBar();
|
||||
menuBars.put(PLUGINS_BAR, pluginsBar);
|
||||
menuBars.put(GerritTopMenu.PLUGINS.menuName, pluginsBar);
|
||||
AccountCapabilities.all(new GerritCallback<AccountCapabilities>() {
|
||||
@Override
|
||||
public void onSuccess(AccountCapabilities result) {
|
||||
@@ -754,7 +748,7 @@ public class Gerrit implements EntryPoint {
|
||||
|
||||
if (getConfig().isDocumentationAvailable()) {
|
||||
m = new LinkMenuBar();
|
||||
menuBars.put(DOCUMENTATION_BAR, m);
|
||||
menuBars.put(GerritTopMenu.DOCUMENTATION.menuName, m);
|
||||
addDocLink(m, C.menuDocumentationIndex(), "index.html");
|
||||
addDocLink(m, C.menuDocumentationSearch(), "user-search.html");
|
||||
addDocLink(m, C.menuDocumentationUpload(), "user-upload.html");
|
||||
|
Reference in New Issue
Block a user