Skip to content

Commit

Permalink
Dashboard scenes: Fix issue going from view panel to edit panel when …
Browse files Browse the repository at this point in the history
…dashboard is not in edit mode (#87487)

Fix issue going from view panel to edit panel
  • Loading branch information
oscarkilhed committed May 15, 2024
1 parent 37d1d1c commit d52381b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion public/app/features/dashboard-scene/utils/urlBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d52381b

Please sign in to comment.