Fix TopMenu extensions for the Project Menu items
The behaviour of TopMenu extensions to the TopMenu projects menubar was broken after the extension of “Project-aware” menu items I516f129dc Even project agnostic items were incorrectly processed as project-specific causing them to be hidden when there was no active project selected. The issue has been discussed on the mailing list (see [1]) and acknowledged to be a regression to be fixed. Issue can be easily reproduced looking at the cookbook-plugin: “Browse Repositories” TopMenu entry is hidden whilst it should be normally shown. [1] https://groups.google.com/forum/#!topic/repo-discuss/nFBQFc0MS6E Change-Id: I8adb59ddda3cae6fc5819c525580096002377c5b
This commit is contained in:
@@ -103,6 +103,7 @@ public class Gerrit implements EntryPoint {
|
|||||||
public static final SystemInfoService SYSTEM_SVC;
|
public static final SystemInfoService SYSTEM_SVC;
|
||||||
public static final EventBus EVENT_BUS = GWT.create(SimpleEventBus.class);
|
public static final EventBus EVENT_BUS = GWT.create(SimpleEventBus.class);
|
||||||
public static Themer THEMER = GWT.create(Themer.class);
|
public static Themer THEMER = GWT.create(Themer.class);
|
||||||
|
public static final String PROJECT_NAME_MENU_VAR = "${projectName}";
|
||||||
|
|
||||||
private static String myHost;
|
private static String myHost;
|
||||||
private static GerritConfig myConfig;
|
private static GerritConfig myConfig;
|
||||||
@@ -773,15 +774,10 @@ public class Gerrit implements EntryPoint {
|
|||||||
for (TopMenu menu : topMenuExtensions) {
|
for (TopMenu menu : topMenuExtensions) {
|
||||||
String name = menu.getName();
|
String name = menu.getName();
|
||||||
LinkMenuBar existingBar = menuBars.get(name);
|
LinkMenuBar existingBar = menuBars.get(name);
|
||||||
LinkMenuBar bar = existingBar != null ? existingBar : new LinkMenuBar();
|
LinkMenuBar bar =
|
||||||
if (GerritTopMenu.PROJECTS.menuName.equals(name)) {
|
existingBar != null ? existingBar : new LinkMenuBar();
|
||||||
for (TopMenuItem item : Natives.asList(menu.getItems())) {
|
for (TopMenuItem item : Natives.asList(menu.getItems())) {
|
||||||
addProjectLink(bar, item);
|
addMenuLink(bar, item);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (TopMenuItem item : Natives.asList(menu.getItems())) {
|
|
||||||
addExtensionLink(bar, item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (existingBar == null) {
|
if (existingBar == null) {
|
||||||
menuBars.put(name, bar);
|
menuBars.put(name, bar);
|
||||||
@@ -909,7 +905,7 @@ public class Gerrit implements EntryPoint {
|
|||||||
@Override
|
@Override
|
||||||
protected void onScreenLoad(Project.NameKey project) {
|
protected void onScreenLoad(Project.NameKey project) {
|
||||||
String p =
|
String p =
|
||||||
panel.replace("${projectName}",
|
panel.replace(PROJECT_NAME_MENU_VAR,
|
||||||
URL.encodeQueryString(project.get()));
|
URL.encodeQueryString(project.get()));
|
||||||
if (!panel.startsWith("/x/") && !isAbsolute(panel)) {
|
if (!panel.startsWith("/x/") && !isAbsolute(panel)) {
|
||||||
UrlBuilder builder = new UrlBuilder();
|
UrlBuilder builder = new UrlBuilder();
|
||||||
@@ -969,6 +965,14 @@ public class Gerrit implements EntryPoint {
|
|||||||
m.add(atag);
|
m.add(atag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addMenuLink(LinkMenuBar m, TopMenuItem item) {
|
||||||
|
if (item.getUrl().contains(PROJECT_NAME_MENU_VAR)) {
|
||||||
|
addProjectLink(m, item);
|
||||||
|
} else {
|
||||||
|
addExtensionLink(m, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void addExtensionLink(LinkMenuBar m, TopMenuItem item) {
|
private static void addExtensionLink(LinkMenuBar m, TopMenuItem item) {
|
||||||
if (item.getUrl().startsWith("#")
|
if (item.getUrl().startsWith("#")
|
||||||
&& (item.getTarget() == null || item.getTarget().isEmpty())) {
|
&& (item.getTarget() == null || item.getTarget().isEmpty())) {
|
||||||
|
Reference in New Issue
Block a user