diff --git a/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.test.ts b/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.test.ts index 72843c523fd..984b7c488b0 100644 --- a/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.test.ts +++ b/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.test.ts @@ -41,6 +41,17 @@ describe('DashboardSceneUrlSync', () => { }); }); + describe('entering edit mode', () => { + it('it should be possible to go from the view panel view to the edit view when the dashboard is not in edit mdoe', () => { + const scene = buildTestScene(); + scene.setState({ isEditing: false }); + scene.urlSync?.updateFromUrl({ viewPanel: 'panel-1' }); + expect(scene.state.viewPanelScene).toBeDefined(); + scene.urlSync?.updateFromUrl({ editPanel: 'panel-1' }); + expect(scene.state.editPanel).toBeDefined(); + }); + }); + describe('Given a viewPanelKey with clone that is not found', () => { const scene = buildTestScene(); diff --git a/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts b/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts index 90a8a932491..207d57312a5 100644 --- a/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts +++ b/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts @@ -129,6 +129,11 @@ export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler { return; } + // We cannot simultaneously be in edit and view panel state. + if (this._scene.state.viewPanelScene) { + this._scene.setState({ viewPanelScene: undefined }); + } + // If we are not in editing (for example after full page reload) if (!isEditing) { this._scene.onEnterEditMode(); diff --git a/public/app/features/dashboard-scene/utils/urlBuilders.ts b/public/app/features/dashboard-scene/utils/urlBuilders.ts index a7b328bab72..4c059d3a6e6 100644 --- a/public/app/features/dashboard-scene/utils/urlBuilders.ts +++ b/public/app/features/dashboard-scene/utils/urlBuilders.ts @@ -90,7 +90,7 @@ export function getViewPanelUrl(vizPanel: VizPanel) { } export function getEditPanelUrl(panelId: number) { - return locationUtil.getUrlForPartial(locationService.getLocation(), { editPanel: panelId }); + return locationUtil.getUrlForPartial(locationService.getLocation(), { editPanel: panelId, viewPanel: undefined }); } export function getInspectUrl(vizPanel: VizPanel, inspectTab?: InspectTab) {