Dashboard scenes: Fix issue going from view panel to edit panel when dashboard is not in edit mode (#87487)

Fix issue going from view panel to edit panel
This commit is contained in:
Oscar Kilhed 2024-05-15 11:53:02 +02:00 committed by GitHub
parent 37d1d1c0a0
commit d52381b744
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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) {