DashboardScene: Update tracking behavior (#80057)

This commit is contained in:
Dominik Prokop 2024-01-05 04:32:06 -08:00 committed by GitHub
parent 99f7110e39
commit 47b986606e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -138,7 +138,7 @@ describe('transformSaveModelToScene', () => {
const scene = createDashboardSceneFromDashboardModel(oldModel);
expect(scene.state.$behaviors).toHaveLength(3);
expect(scene.state.$behaviors).toHaveLength(4);
expect(scene.state.$behaviors![1]).toBeInstanceOf(behaviors.CursorSync);
expect((scene.state.$behaviors![1] as behaviors.CursorSync).state.sync).toEqual(DashboardCursorSync.Crosshair);
});

View File

@ -68,10 +68,7 @@ export function transformSaveModelToScene(rsp: DashboardDTO): DashboardScene {
autoMigrateOldPanels: false,
});
const scene = createDashboardSceneFromDashboardModel(oldModel);
scene.state.$behaviors?.push(registerDashboardSceneTracking(oldModel, rsp.dashboard.version));
return scene;
return createDashboardSceneFromDashboardModel(oldModel);
}
export function createSceneObjectsForPanels(oldPanels: PanelModel[]): SceneGridItemLike[] {
@ -261,6 +258,7 @@ export function createDashboardSceneFromDashboardModel(oldModel: DashboardModel)
new behaviors.CursorSync({
sync: oldModel.graphTooltip,
}),
registerDashboardSceneTracking(oldModel),
registerPanelInteractionsReporter,
],
$data:
@ -484,11 +482,11 @@ const getLimitedDescriptionReporter = () => {
};
};
function registerDashboardSceneTracking(model: DashboardModel, version?: number) {
function registerDashboardSceneTracking(model: DashboardModel) {
return () => {
const unsetDashboardInteractionsScenesContext = DashboardInteractions.setScenesContext();
trackDashboardLoaded(model, version);
trackDashboardLoaded(model, model.version);
return () => {
unsetDashboardInteractionsScenesContext();