From a55b42d11f85c936bdfa408379fd625106932224 Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Tue, 19 Dec 2017 13:39:11 +0100 Subject: [PATCH 1/2] fix: The /logout route should always full page reload (#10277) --- public/app/core/services/global_event_srv.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/public/app/core/services/global_event_srv.ts b/public/app/core/services/global_event_srv.ts index 5cc21dc7b7a..4c5458aec2d 100644 --- a/public/app/core/services/global_event_srv.ts +++ b/public/app/core/services/global_event_srv.ts @@ -6,10 +6,13 @@ import appEvents from 'app/core/app_events'; // Good for communication react > angular and vice verse export class GlobalEventSrv { private appSubUrl; + private fullPageReloadRoutes; + /** @ngInject */ - constructor(private $location, private $timeout) { + constructor(private $location, private $timeout, private $window) { this.appSubUrl = config.appSubUrl; + this.fullPageReloadRoutes = ['/logout']; } // Angular's $location does not like and absolute urls @@ -26,9 +29,13 @@ export class GlobalEventSrv { init() { appEvents.on('location-change', payload => { const urlWithoutBase = this.stripBaseFromUrl(payload.href); + if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) { + this.$window.location.href = payload.href; + return; + } this.$timeout(() => { // A hack to use timeout when we're changing things (in this case the url) from outside of Angular. - this.$location.url(urlWithoutBase); + this.$location.url(urlWithoutBase); }); }); } From 23cceaecc4a1958e167e55a7a95cc7ef43d3efef Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Tue, 19 Dec 2017 14:45:44 +0100 Subject: [PATCH 2/2] test: Update test with new component signature --- .../app/core/specs/global_event_srv.jest.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/app/core/specs/global_event_srv.jest.ts b/public/app/core/specs/global_event_srv.jest.ts index 0ecd5cbe40b..1223814fb38 100644 --- a/public/app/core/specs/global_event_srv.jest.ts +++ b/public/app/core/specs/global_event_srv.jest.ts @@ -1,23 +1,23 @@ -import { GlobalEventSrv } from 'app/core/services/global_event_srv'; -import { beforeEach } from 'test/lib/common'; +import { GlobalEventSrv } from "app/core/services/global_event_srv"; +import { beforeEach } from "test/lib/common"; -jest.mock('app/core/config', () => { +jest.mock("app/core/config", () => { return { - appSubUrl: '/subUrl' + appSubUrl: "/subUrl" }; }); -describe('GlobalEventSrv', () => { +describe("GlobalEventSrv", () => { let searchSrv; beforeEach(() => { - searchSrv = new GlobalEventSrv(null, null); + searchSrv = new GlobalEventSrv(null, null, null); }); - describe('With /subUrl as appSubUrl', () => { - it('/subUrl should be stripped', () => { - const urlWithoutMaster = searchSrv.stripBaseFromUrl('/subUrl/grafana/'); - expect(urlWithoutMaster).toBe('/grafana/'); + describe("With /subUrl as appSubUrl", () => { + it("/subUrl should be stripped", () => { + const urlWithoutMaster = searchSrv.stripBaseFromUrl("/subUrl/grafana/"); + expect(urlWithoutMaster).toBe("/grafana/"); }); }); });