From 541b0a0ca1ce2aa1b1b6fd696612a486f6808d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 7 Feb 2018 14:10:23 +0100 Subject: [PATCH] fix: fixed bug with redirect after new dashboard saved, related to buggy angularjs location path/url and base href, fixes #10817 --- public/app/features/dashboard/dashboard_srv.ts | 3 ++- public/app/features/dashboard/dashgrid/AddPanelPanel.tsx | 1 - public/app/features/dashboard/history/history.ts | 3 ++- public/app/routes/dashboard_loaders.ts | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/app/features/dashboard/dashboard_srv.ts b/public/app/features/dashboard/dashboard_srv.ts index 08ab70053f6..8d00dc4fc60 100644 --- a/public/app/features/dashboard/dashboard_srv.ts +++ b/public/app/features/dashboard/dashboard_srv.ts @@ -1,5 +1,6 @@ import coreModule from 'app/core/core_module'; import { DashboardModel } from './dashboard_model'; +import locationUtil from 'app/core/utils/location_util'; export class DashboardSrv { dash: any; @@ -74,7 +75,7 @@ export class DashboardSrv { this.dash.version = data.version; if (data.url !== this.$location.path()) { - this.$location.url(data.url); + this.$location.url(locationUtil.stripBaseFromUrl(data.url)).replace(); } this.$rootScope.appEvent('dashboard-saved', this.dash); diff --git a/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx b/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx index 01d16436a45..aeb840c317a 100644 --- a/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx +++ b/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx @@ -93,7 +93,6 @@ export class AddPanelPanel extends React.Component this.onAddPanel(panel)} title={panel.name}> diff --git a/public/app/features/dashboard/history/history.ts b/public/app/features/dashboard/history/history.ts index 2a3fd0b3984..d9f0c087438 100644 --- a/public/app/features/dashboard/history/history.ts +++ b/public/app/features/dashboard/history/history.ts @@ -4,6 +4,7 @@ import _ from 'lodash'; import angular from 'angular'; import moment from 'moment'; +import locationUtil from 'app/core/utils/location_util'; import { DashboardModel } from '../dashboard_model'; import { HistoryListOpts, RevisionsModel, CalculateDiffOptions, HistorySrv } from './history_srv'; @@ -185,7 +186,7 @@ export class HistoryListCtrl { return this.historySrv .restoreDashboard(this.dashboard, version) .then(response => { - this.$location.path('dashboard/db/' + response.slug); + this.$location.url(locationUtil.stripBaseFromUrl(response.url)).replace(); this.$route.reload(); this.$rootScope.appEvent('alert-success', ['Dashboard restored', 'Restored from version ' + version]); }) diff --git a/public/app/routes/dashboard_loaders.ts b/public/app/routes/dashboard_loaders.ts index a9ccd60ee4f..d84f03ed38f 100644 --- a/public/app/routes/dashboard_loaders.ts +++ b/public/app/routes/dashboard_loaders.ts @@ -23,8 +23,7 @@ export class LoadDashboardCtrl { if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) { backendSrv.get(`/api/dashboards/db/${$routeParams.slug}`).then(res => { if (res) { - const url = locationUtil.stripBaseFromUrl(res.meta.url); - $location.path(url).replace(); + $location.path(locationUtil.stripBaseFromUrl(res.meta.url)).replace(); } }); return;