polygerrit-ui: hide project-aware top menus from header

Project-aware topmenu links need to be shown only when a project is
selected: so special handling must be handled, as it was in GWT.

As opposed to GWT however, it does not make sense to show these in
header in any case, since there is no notion of 'current project'
in menu anymore. So we just hide them for now, and we may show them in
the project page as well (but in a separate patch).

Change-Id: I180e63b648d2fc228e61c2ad0d485d3ab8ab31f4
This commit is contained in:
Francois Ferrand
2019-05-03 11:46:58 +02:00
parent 3255182532
commit dbad8574fb
2 changed files with 35 additions and 1 deletions

View File

@@ -206,7 +206,10 @@
const topMenuLinks = [];
links.forEach(link => { topMenuLinks[link.title] = link.links; });
for (const m of topMenus) {
const items = m.items.map(this._fixCustomMenuItem);
const items = m.items.map(this._fixCustomMenuItem).filter(link => {
// Ignore GWT project links
return !link.url.includes('${projectName}');
});
if (m.name in topMenuLinks) {
items.forEach(link => { topMenuLinks[m.name].push(link); });
} else {

View File

@@ -191,6 +191,37 @@ limitations under the License.
}]);
});
test('ignore top project menus', () => {
const adminLinks = [{
name: 'Repos',
url: '/repos',
}];
const topMenus = [{
name: 'Projects',
items: [{
name: 'Project Settings',
target: '_blank',
url: '/plugins/myplugin/${projectName}',
}, {
name: 'Project List',
target: '_blank',
url: '/plugins/myplugin/index.html',
}],
}];
assert.deepEqual(element._computeLinks([], [], adminLinks, topMenus), [{
title: 'Browse',
links: adminLinks,
},
{
title: 'Projects',
links: [{
name: 'Project List',
external: true,
url: '/plugins/myplugin/index.html',
}],
}]);
});
test('merge top menus', () => {
const adminLinks = [{
name: 'Repos',