diff --git a/public/app/features/dashboard-scene/scene/DashboardScene.tsx b/public/app/features/dashboard-scene/scene/DashboardScene.tsx index 51f9091cad5..cfbe94e0f7f 100644 --- a/public/app/features/dashboard-scene/scene/DashboardScene.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardScene.tsx @@ -169,7 +169,7 @@ export class DashboardScene extends SceneObjectBase impleme protected _renderBeforeActivation = true; - private _serializer: DashboardSceneSerializerLike< + public serializer: DashboardSceneSerializerLike< Dashboard | DashboardV2Spec, DashboardMeta | DashboardWithAccessInfo['metadata'] >; @@ -187,7 +187,7 @@ export class DashboardScene extends SceneObjectBase impleme scopesBridge: config.featureToggles.scopeFilters ? new SceneScopesBridge({}) : undefined, }); - this._serializer = + this.serializer = serializerVersion === 'v2' ? getDashboardSceneSerializer('v2') : getDashboardSceneSerializer('v1'); this._changeTracker = new DashboardSceneChangeTracker(this); @@ -272,7 +272,7 @@ export class DashboardScene extends SceneObjectBase impleme }; public saveCompleted(saveModel: Dashboard | DashboardV2Spec, result: SaveDashboardResponseDTO, folderUid?: string) { - this._serializer.onSaveComplete(saveModel, result); + this.serializer.onSaveComplete(saveModel, result); this._changeTracker.stopTrackingChanges(); @@ -662,11 +662,11 @@ export class DashboardScene extends SceneObjectBase impleme } public getInitialSaveModel() { - return this._serializer.initialSaveModel; + return this.serializer.initialSaveModel; } public getSnapshotUrl = () => { - return this._serializer.getSnapshotUrl(); + return this.serializer.getSnapshotUrl(); }; /** Hacky temp function until we refactor transformSaveModelToScene a bit */ @@ -676,26 +676,14 @@ export class DashboardScene extends SceneObjectBase impleme saveModel?: Dashboard | DashboardV2Spec, meta?: DashboardMeta | DashboardWithAccessInfo['metadata'] ): void { - this._serializer.initializeMapping(saveModel); + this.serializer.initializeMapping(saveModel); const sortedModel = sortedDeepCloneWithoutNulls(saveModel); - this._serializer.initialSaveModel = sortedModel; - this._serializer.metadata = meta; + this.serializer.initialSaveModel = sortedModel; + this.serializer.metadata = meta; } public getTrackingInformation() { - return this._serializer.getTrackingInformation(this); - } - - public getPanelIdForElement(elementId: string) { - return this._serializer.getPanelIdForElement(elementId); - } - - public getElementPanelMapping() { - return this._serializer.getElementPanelMapping(); - } - - public getElementIdentifierForPanel(panelId: number) { - return this._serializer.getElementIdForPanel(panelId); + return this.serializer.getTrackingInformation(this); } public async onDashboardDelete() { @@ -740,15 +728,15 @@ export class DashboardScene extends SceneObjectBase impleme } getSaveModel(): Dashboard | DashboardV2Spec { - return this._serializer.getSaveModel(this); + return this.serializer.getSaveModel(this); } getSaveAsModel(options: SaveDashboardAsOptions): Dashboard | DashboardV2Spec { - return this._serializer.getSaveAsModel(this, options); + return this.serializer.getSaveAsModel(this, options); } getDashboardChanges(saveTimeRange?: boolean, saveVariables?: boolean, saveRefresh?: boolean): DashboardChangeInfo { - return this._serializer.getDashboardChangesFromScene(this, { saveTimeRange, saveVariables, saveRefresh }); + return this.serializer.getDashboardChangesFromScene(this, { saveTimeRange, saveVariables, saveRefresh }); } getManagerKind(): ManagerKind | undefined { diff --git a/public/app/features/dashboard-scene/serialization/transformSceneToSaveModelSchemaV2.ts b/public/app/features/dashboard-scene/serialization/transformSceneToSaveModelSchemaV2.ts index 68cc7c9ed53..77299318149 100644 --- a/public/app/features/dashboard-scene/serialization/transformSceneToSaveModelSchemaV2.ts +++ b/public/app/features/dashboard-scene/serialization/transformSceneToSaveModelSchemaV2.ts @@ -341,7 +341,7 @@ function getVizPanelQueryOptions(vizPanel: VizPanel): QueryOptionsSpec { function createElements(panels: Element[], scene: DashboardScene): Record { return panels.reduce>((elements, panel) => { - let elementKey = scene.getElementIdentifierForPanel(panel.spec.id); + let elementKey = scene.serializer.getElementIdForPanel(panel.spec.id); elements[elementKey!] = panel; return elements; }, {}); diff --git a/public/app/features/dashboard-scene/utils/dashboardSceneGraph.ts b/public/app/features/dashboard-scene/utils/dashboardSceneGraph.ts index a50898e0e71..bd838432be5 100644 --- a/public/app/features/dashboard-scene/utils/dashboardSceneGraph.ts +++ b/public/app/features/dashboard-scene/utils/dashboardSceneGraph.ts @@ -83,7 +83,7 @@ export function getCursorSync(scene: DashboardScene) { export function getElementIdentifierForVizPanel(vizPanel: VizPanel): string { const scene = getDashboardSceneFor(vizPanel); const panelId = getPanelIdForVizPanel(vizPanel); - let elementKey = scene.getElementIdentifierForPanel(panelId); + let elementKey = scene.serializer.getElementIdForPanel(panelId); if (!elementKey) { // assign a panel-id key