DashboardScene: Include url params when switching from old dashboard arch to new (#74969)

* DashboardScene: Include url params when switching from old dashboard arch to new

* remove imports

* fix
This commit is contained in:
Torkel Ödegaard 2023-09-22 13:04:17 +02:00 committed by GitHub
parent 28b4d7fa0c
commit 3529b7413d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 10 deletions

View File

@ -7,7 +7,6 @@ import {
SceneDataTransformer,
SceneGridItem,
SceneGridLayout,
SceneObjectRef,
VizPanel,
} from '@grafana/scenes';
import { getStandardTransformers } from 'app/features/transformers/standardTransformers';
@ -154,7 +153,7 @@ async function buildTestScene() {
await new Promise((r) => setTimeout(r, 1));
const tab = new InspectJsonTab({
panelRef: new SceneObjectRef(panel),
panelRef: panel.getRef(),
onClose: jest.fn(),
});

View File

@ -113,9 +113,9 @@ export function buildPanelEditScene(dashboard: DashboardScene, panel: VizPanel):
const dashboardStateCloned = sceneUtils.cloneSceneObjectState(dashboard.state);
return new PanelEditor({
dashboardRef: new SceneObjectRef(dashboard),
sourcePanelRef: new SceneObjectRef(panel),
panelRef: new SceneObjectRef(panelClone),
dashboardRef: dashboard.getRef(),
sourcePanelRef: panel.getRef(),
panelRef: panelClone.getRef(),
controls: dashboardStateCloned.controls,
$variables: dashboardStateCloned.$variables,
$timeRange: dashboardStateCloned.$timeRange,

View File

@ -10,7 +10,6 @@ import {
SceneGridLayout,
SceneObject,
SceneObjectBase,
SceneObjectRef,
SceneObjectState,
SceneObjectStateChangedEvent,
sceneUtils,
@ -129,7 +128,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
};
public onSave = () => {
this.setState({ overlay: new SaveDashboardDrawer({ dashboardRef: new SceneObjectRef(this) }) });
this.setState({ overlay: new SaveDashboardDrawer({ dashboardRef: this.getRef() }) });
};
public getPageNav(location: H.Location) {

View File

@ -1,6 +1,6 @@
import { AppEvents } from '@grafana/data';
import { locationService } from '@grafana/runtime';
import { SceneObjectRef, SceneObjectUrlSyncHandler, SceneObjectUrlValues } from '@grafana/scenes';
import { SceneObjectUrlSyncHandler, SceneObjectUrlValues } from '@grafana/scenes';
import appEvents from 'app/core/app_events';
import { PanelInspectDrawer } from '../inspect/PanelInspectDrawer';
@ -34,7 +34,7 @@ export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler {
}
update.inspectPanelKey = values.inspect;
update.overlay = new PanelInspectDrawer({ panelRef: new SceneObjectRef(panel) });
update.overlay = new PanelInspectDrawer({ panelRef: panel.getRef() });
} else if (inspectPanelId) {
update.inspectPanelKey = undefined;
update.overlay = undefined;

View File

@ -202,7 +202,10 @@ export const DashNav = React.memo<Props>((props) => {
key="button-scenes"
tooltip={'View as Scene'}
icon="apps"
onClick={() => locationService.push(`/scenes/dashboard/${dashboard.uid}`)}
onClick={() => {
const location = locationService.getLocation();
locationService.push(`/scenes/dashboard/${dashboard.uid}${location.search}`);
}}
/>
);
}