Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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