Mark admin navigation link URLs without included base URLs

With Ifa3e19c509, the admin navigation links became a mixture of URLs
generated by the new router abstraction and older URLs that are
hard-coded. Whereas router-generated links already include the base URL,
the base must be added to hard-coded links. With this change, boolean
properties are added so that the admin view can determine whether the
link already includes the base URL and avoid adding it twice.

Bug: Issue 7612
Change-Id: I6ed33aeb147a1bff924c0a684ed8a0eb6ad71ad1
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js
index dabbe19..2e4bf69 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.js
@@ -14,8 +14,11 @@
 (function() {
   'use strict';
 
+  // Note: noBaseUrl: true is set on entries where the URL is not yet supported
+  // by router abstraction.
   const ADMIN_LINKS = [{
     name: 'Projects',
+    noBaseUrl: true,
     url: '/admin/projects',
     view: 'gr-project-list',
     viewableToAll: true,
@@ -23,6 +26,7 @@
   }, {
     name: 'Groups',
     section: 'Groups',
+    noBaseUrl: true,
     url: '/admin/groups',
     view: 'gr-admin-group-list',
     children: [],
@@ -30,6 +34,7 @@
     name: 'Plugins',
     capability: 'viewPlugins',
     section: 'Plugins',
+    noBaseUrl: true,
     url: '/admin/plugins',
     view: 'gr-plugin-list',
   }];
@@ -113,11 +118,13 @@
           linkCopy.subsection = {
             name: this._projectName,
             view: 'gr-project',
+            noBaseUrl: true,
             url: `/admin/projects/${this.encodeURL(this._projectName, true)}`,
             children: [{
               name: 'Access',
               detailType: 'access',
               view: 'gr-project-access',
+              noBaseUrl: true,
               url: `/admin/projects/` +
                   `${this.encodeURL(this._projectName, true)},access`,
             },
@@ -125,6 +132,7 @@
               name: 'Commands',
               detailType: 'commands',
               view: 'gr-project-commands',
+              noBaseUrl: true,
               url: `/admin/projects/` +
                   `${this.encodeURL(this._projectName, true)},commands`,
             },
@@ -132,6 +140,7 @@
               name: 'Branches',
               detailType: 'branches',
               view: 'gr-project-detail-list',
+              noBaseUrl: true,
               url: `/admin/projects/` +
                   `${this.encodeURL(this._projectName, true)},branches`,
             },
@@ -139,6 +148,7 @@
               name: 'Tags',
               detailType: 'tags',
               view: 'gr-project-detail-list',
+              noBaseUrl: true,
               url: `/admin/projects/` +
                   `${this.encodeURL(this._projectName, true)},tags`,
             }],
@@ -236,7 +246,7 @@
 
     _computeLinkURL(link) {
       if (!link || typeof link.url === 'undefined') { return ''; }
-      if (link.target) {
+      if (link.target || !link.noBaseUrl) {
         return link.url;
       }
       return this._computeRelativeURL(link.url);
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html
index 4575ff7..5e4033f 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.html
@@ -59,8 +59,14 @@
 
     test('link URLs', () => {
       assert.equal(
-          element._computeLinkURL({url: '/test'}),
+          element._computeLinkURL({url: '/test', noBaseUrl: true}),
           '//' + window.location.host + '/test');
+
+      sandbox.stub(element, 'getBaseUrl').returns('/foo');
+      assert.equal(
+          element._computeLinkURL({url: '/test', noBaseUrl: true}),
+          '//' + window.location.host + '/foo/test');
+      assert.equal(element._computeLinkURL({url: '/test'}), '/test');
       assert.equal(
           element._computeLinkURL({url: '/test', target: '_blank'}),
           '/test');