Compare commits

...

1 Commits

Author SHA1 Message Date
Dominik Prokop
3ab68bd22c Fix dashboard link placement not preserved in v2 dashboards 2025-11-28 15:12:18 +01:00
2 changed files with 49 additions and 0 deletions

View File

@@ -419,6 +419,54 @@ describe('transformSceneToSaveModelSchemaV2', () => {
}).not.toThrow();
});
it('should preserve placement property when serializing dashboard links', () => {
const sceneWithPlacement = new DashboardScene({
title: 'Test Dashboard',
links: [
{
title: 'Link with placement',
url: 'http://test.com',
asDropdown: false,
icon: '',
includeVars: false,
keepTime: false,
tags: [],
targetBlank: false,
tooltip: '',
type: 'link',
placement: 'inControlsMenu',
},
{
title: 'Link without placement',
url: 'http://test2.com',
asDropdown: false,
icon: '',
includeVars: false,
keepTime: false,
tags: [],
targetBlank: false,
tooltip: '',
type: 'link',
},
],
body: new DefaultGridLayoutManager({
grid: new SceneGridLayout({ children: [] }),
}),
$timeRange: new SceneTimeRange({
from: 'now-1h',
to: 'now',
}),
meta: {},
editPane: new DashboardEditPane(),
});
const result = transformSceneToSaveModelSchemaV2(sceneWithPlacement);
expect(result.links).toHaveLength(2);
expect(result.links![0].placement).toBe('inControlsMenu');
expect(result.links![1].placement).toBeUndefined();
});
describe('getPersistedDSFor query', () => {
it('should respect datasource reference mapping when determining query datasource', () => {
// Setup test data

View File

@@ -97,6 +97,7 @@ export function transformSceneToSaveModelSchemaV2(scene: DashboardScene, isSnaps
keepTime: link.keepTime ?? defaultDashboardLink().keepTime,
includeVars: link.includeVars ?? defaultDashboardLink().includeVars,
targetBlank: link.targetBlank ?? defaultDashboardLink().targetBlank,
...(link.placement && { placement: link.placement }),
})),
tags: sceneDash.tags ?? defaultDashboardV2Spec().tags,
// EOF dashboard settings