From 00635a9928cb0bcc83f6959b68da63204d1b853c Mon Sep 17 00:00:00 2001 From: Wyatt Allen Date: Wed, 6 Sep 2017 17:37:22 -0700 Subject: [PATCH] Mark all "My" menu links as external Custom menu links may use URLs that are not covered by the client router. When following a link that shares the domain, it will be intercepted by the catchall route and a visual 404 will be mistakenly shown. With this change, all of the custom links in this menu are marked as external so that following them causes a full reload and a 404 is shown only in the appropriate case. Bug: Issue 8373 Change-Id: I1cad36de97786a0f9af42e08105ab485fa198a15 --- .../app/elements/core/gr-main-header/gr-main-header.js | 6 ++++++ .../elements/core/gr-main-header/gr-main-header_test.html | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) 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 ab042c465a..3e7c82ab4d 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 @@ -274,6 +274,12 @@ // makes assumptions that work for the GWT UI, but not PolyGerrit, // so we'll just disable it altogether for now. delete linkObj.target; + + // Becasue the "my menu" links may be arbitrary URLs, we don't know + // whether they correspond to any client routes. Mark all such links as + // external. + linkObj.external = true; + 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 94f1f66f8d..bea57361b9 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 @@ -60,9 +60,9 @@ limitations under the License. {url: 'url', target: '_blank'}, ].map(element._fixMyMenuItem), [ - {url: '/q/owner:self+is:draft'}, - {url: 'https://awesometown.com/#hashyhash'}, - {url: 'url'}, + {url: '/q/owner:self+is:draft', external: true}, + {url: 'https://awesometown.com/#hashyhash', external: true}, + {url: 'url', external: true}, ]); });