From c9cab9b6776a2ef4a5e6172a46ccd155133ca92a Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 28 Jan 2019 12:20:16 +0100 Subject: [PATCH 1/3] updating state if no panel --- .../dashboard/services/DashboardViewStateSrv.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard/services/DashboardViewStateSrv.ts b/public/app/features/dashboard/services/DashboardViewStateSrv.ts index cb9794d6abb..816b6d8bd2d 100644 --- a/public/app/features/dashboard/services/DashboardViewStateSrv.ts +++ b/public/app/features/dashboard/services/DashboardViewStateSrv.ts @@ -72,7 +72,6 @@ export class DashboardViewStateSrv { } _.extend(this.state, state); - this.dashboard.meta.fullscreen = this.state.fullscreen; if (!this.state.fullscreen) { this.state.fullscreen = null; @@ -117,10 +116,20 @@ export class DashboardViewStateSrv { } syncState() { - if (this.dashboard.meta.fullscreen) { + if (this.state.fullscreen) { const panel = this.dashboard.getPanelById(this.state.panelId); if (!panel) { + this.state.fullscreen = null; + this.state.panelId = null; + this.state.edit = null; + + this.update(this.state); + + setTimeout(() => { + appEvents.emit('alert-error', ['Error', 'Panel not found']); + }, 100); + return; } From d433a4792a9e3ae0547b5e8fe83d5b7fed9320e1 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 28 Jan 2019 14:07:37 +0100 Subject: [PATCH 2/3] fixing test --- .../features/dashboard/services/DashboardViewStateSrv.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts b/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts index aee6746ff36..0003d5c91e8 100644 --- a/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts +++ b/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts @@ -58,7 +58,7 @@ describe('when updating view state', () => { it('should remove params from query string', () => { viewState.update({ fullscreen: true, panelId: 1, edit: true }); viewState.update({ fullscreen: false }); - expect(viewState.dashboard.meta.fullscreen).toBe(false); + expect(viewState.dashboard.meta.fullscreen).toBe(true); expect(viewState.state.fullscreen).toBe(null); }); }); From 520756fb4ced5911668ba3eb8ad1fe90015e37a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 28 Jan 2019 14:44:35 +0100 Subject: [PATCH 3/3] Fixed wrong line in test --- .../features/dashboard/services/DashboardViewStateSrv.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts b/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts index 0003d5c91e8..20215017e1d 100644 --- a/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts +++ b/public/app/features/dashboard/services/DashboardViewStateSrv.test.ts @@ -58,7 +58,6 @@ describe('when updating view state', () => { it('should remove params from query string', () => { viewState.update({ fullscreen: true, panelId: 1, edit: true }); viewState.update({ fullscreen: false }); - expect(viewState.dashboard.meta.fullscreen).toBe(true); expect(viewState.state.fullscreen).toBe(null); }); });