diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js index affa8e599d..ab042c465a 100644 --- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js +++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js @@ -244,7 +244,7 @@ this.$.restAPI.getPreferences().then(function(prefs) { this._userLinks = - prefs.my.map(this._stripHashPrefix).filter(this._isSupportedLink); + prefs.my.map(this._fixMyMenuItem).filter(this._isSupportedLink); }.bind(this)); this._loadAccountCapabilities(); }, @@ -260,10 +260,20 @@ }.bind(this)); }, - _stripHashPrefix: function(linkObj) { + _fixMyMenuItem: function(linkObj) { + // Normalize all urls to PolyGerrit style. if (linkObj.url.indexOf('#') === 0) { linkObj.url = linkObj.url.slice(1); } + + // Delete target property due to complications of + // https://bugs.chromium.org/p/gerrit/issues/detail?id=5888 + // + // The server tries to guess whether URL is a view within the UI. + // If not, it sets target='_blank' on the menu item. The server + // makes assumptions that work for the GWT UI, but not PolyGerrit, + // so we'll just disable it altogether for now. + delete linkObj.target; return linkObj; }, diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html index 4582b4f9c2..94f1f66f8d 100644 --- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html +++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.html @@ -53,14 +53,16 @@ limitations under the License. sandbox.restore(); }); - test('strip hash prefix', function() { + test('fix my menu item', function() { assert.deepEqual([ {url: '#/q/owner:self+is:draft'}, {url: 'https://awesometown.com/#hashyhash'}, - ].map(element._stripHashPrefix), + {url: 'url', target: '_blank'}, + ].map(element._fixMyMenuItem), [ {url: '/q/owner:self+is:draft'}, {url: 'https://awesometown.com/#hashyhash'}, + {url: 'url'}, ]); });