mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
Merge remote-tracking branch 'origin/10277_logout_route_full_page_reload'
This commit is contained in:
@@ -6,10 +6,12 @@ import appEvents from "app/core/app_events";
|
|||||||
// Good for communication react > angular and vice verse
|
// Good for communication react > angular and vice verse
|
||||||
export class GlobalEventSrv {
|
export class GlobalEventSrv {
|
||||||
private appSubUrl;
|
private appSubUrl;
|
||||||
|
private fullPageReloadRoutes;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
constructor(private $location, private $timeout) {
|
constructor(private $location, private $timeout, private $window) {
|
||||||
this.appSubUrl = config.appSubUrl;
|
this.appSubUrl = config.appSubUrl;
|
||||||
|
this.fullPageReloadRoutes = ["/logout"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Angular's $location does not like <base href...> and absolute urls
|
// Angular's $location does not like <base href...> and absolute urls
|
||||||
@@ -27,6 +29,10 @@ export class GlobalEventSrv {
|
|||||||
init() {
|
init() {
|
||||||
appEvents.on("location-change", payload => {
|
appEvents.on("location-change", payload => {
|
||||||
const urlWithoutBase = this.stripBaseFromUrl(payload.href);
|
const urlWithoutBase = this.stripBaseFromUrl(payload.href);
|
||||||
|
if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
|
||||||
|
this.$window.location.href = payload.href;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
// A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
|
// A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GlobalEventSrv } from "app/core/services/global_event_srv";
|
import { GlobalEventSrv } from "app/core/services/global_event_srv";
|
||||||
import { beforeEach } from "test/lib/common";
|
import { beforeEach } from "test/lib/common";
|
||||||
|
|
||||||
jest.mock("app/core/config", () => {
|
jest.mock("app/core/config", () => {
|
||||||
@@ -11,7 +11,7 @@ describe("GlobalEventSrv", () => {
|
|||||||
let searchSrv;
|
let searchSrv;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
searchSrv = new GlobalEventSrv(null, null);
|
searchSrv = new GlobalEventSrv(null, null, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("With /subUrl as appSubUrl", () => {
|
describe("With /subUrl as appSubUrl", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user