Rename serializerVersion

This commit is contained in:
Ivan Ortega
2025-12-17 20:26:39 +01:00
parent a23873e88f
commit 7ec202cced
5 changed files with 10 additions and 11 deletions
@@ -85,7 +85,7 @@ export interface LoadDashboardOptions {
slug?: string;
type?: string;
urlFolderUid?: string;
serializerVersion?: 'v1' | 'v2';
targetVersion?: 'v1' | 'v2';
}
export type HomeDashboardDTO = DashboardDTO & {
@@ -420,7 +420,7 @@ describe('DashboardPrompt', () => {
});
});
function buildTestScene(overrides?: Partial<DashboardSceneState>, serializerVersion: 'v1' | 'v2' = 'v1') {
function buildTestScene(overrides?: Partial<DashboardSceneState>, targetVersion: 'v1' | 'v2' = 'v1') {
const defaultPanels = [
new VizPanel({
title: 'Panel A',
@@ -445,7 +445,7 @@ function buildTestScene(overrides?: Partial<DashboardSceneState>, serializerVers
body: DefaultGridLayoutManager.fromVizPanels(defaultPanels),
...overrides,
},
serializerVersion
targetVersion
);
return scene;
@@ -192,7 +192,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> impleme
DashboardJson | DashboardV2Spec
>;
public constructor(state: Partial<DashboardSceneState>, serializerVersion: 'v1' | 'v2' = 'v1') {
public constructor(state: Partial<DashboardSceneState>, targetVersion: 'v1' | 'v2' = 'v1') {
super({
title: t('dashboard-scene.dashboard-scene.title.dashboard', 'Dashboard'),
meta: {},
@@ -205,8 +205,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> impleme
layoutOrchestrator: new DashboardLayoutOrchestrator(),
});
this.serializer =
serializerVersion === 'v2' ? getDashboardSceneSerializer('v2') : getDashboardSceneSerializer('v1');
this.serializer = targetVersion === 'v2' ? getDashboardSceneSerializer('v2') : getDashboardSceneSerializer('v1');
this._changeTracker = new DashboardSceneChangeTracker(this);
@@ -266,8 +266,8 @@ export function createDashboardSceneFromDashboardModel(
let alertStatesLayer: AlertStatesDataLayer | undefined;
const uid = oldModel.uid;
const isReport = options?.route === DashboardRoutes.Report;
const serializerVersion =
options?.serializerVersion ?? (shouldForceV2API() && !oldModel.meta.isSnapshot && !isReport ? 'v2' : 'v1');
const targetVersion =
options?.targetVersion ?? (shouldForceV2API() && !oldModel.meta.isSnapshot && !isReport ? 'v2' : 'v1');
if (oldModel.meta.isSnapshot) {
variables = createVariablesForSnapshot(oldModel);
@@ -355,7 +355,7 @@ export function createDashboardSceneFromDashboardModel(
let body: DashboardLayoutManager;
if (serializerVersion === 'v2' && oldModel.panels.some((p) => p.type === 'row')) {
if (targetVersion === 'v2' && oldModel.panels.some((p) => p.type === 'row')) {
body = createRowsFromPanels(oldModel.panels);
} else {
body = new DefaultGridLayoutManager({
@@ -405,7 +405,7 @@ export function createDashboardSceneFromDashboardModel(
hideTimeControls: oldModel.timepicker.hidden,
}),
},
serializerVersion
targetVersion
);
// Enable panel profiling for this dashboard using the composed SceneRenderProfiler
@@ -227,7 +227,7 @@ export class ShareExportTab extends SceneObjectBase<ShareExportTabState> impleme
dashboard: { ...v1SaveModel, title: v1SaveModel.title ?? '', uid: v1SaveModel.uid ?? '' },
meta: scene.state.meta,
},
{ uid: scene.state.uid ?? '', route: DashboardRoutes.Normal, serializerVersion: 'v2' }
{ uid: scene.state.uid ?? '', route: DashboardRoutes.Normal, targetVersion: 'v2' }
);
}