Add dashbaord version to scene metadata
This commit is contained in:
@@ -8,7 +8,7 @@ import { Prompt } from 'app/core/components/FormPrompt/Prompt';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
|
||||
import { SaveLibraryVizPanelModal } from '../panel-edit/SaveLibraryVizPanelModal';
|
||||
import { DashboardScene, isV2Dashboard } from '../scene/DashboardScene';
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
import { getLibraryPanelBehavior, isLibraryPanel } from '../utils/utils';
|
||||
|
||||
interface DashboardPromptProps {
|
||||
@@ -155,16 +155,12 @@ const getStyles = () => ({
|
||||
export function ignoreChanges(scene: DashboardScene | null) {
|
||||
const original = scene?.getInitialSaveModel();
|
||||
|
||||
if (original && isV2Dashboard(original)) {
|
||||
throw new Error('isV2Dashboard is not implemented');
|
||||
}
|
||||
|
||||
if (!original) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ignore changes if original is unsaved
|
||||
if (original.version === 0) {
|
||||
if (scene?.state.meta.version === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ describe('DashboardScene', () => {
|
||||
expect(scene.state.isDirty).toBe(false);
|
||||
scene.exitEditMode({ skipConfirm: true });
|
||||
expect(scene.state.title).toEqual('Updated title');
|
||||
expect(scene.state.meta.version).toEqual(2);
|
||||
});
|
||||
|
||||
it('Should start the detect changes worker', () => {
|
||||
|
||||
@@ -281,6 +281,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
||||
slug: result.slug,
|
||||
folderUid: folderUid,
|
||||
isNew: false,
|
||||
version: result.version,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
+3
-1
@@ -120,7 +120,9 @@ export function transformSaveModelSchemaV2ToScene(dto: DashboardWithAccessInfo<D
|
||||
isDirty: false,
|
||||
links: dashboard.links,
|
||||
// TODO: Combine access and metadata to compose the V1 meta object
|
||||
meta: {},
|
||||
meta: {
|
||||
version: parseInt(metadata.resourceVersion, 10),
|
||||
},
|
||||
tags: dashboard.tags,
|
||||
title: dashboard.title,
|
||||
uid: metadata.name,
|
||||
|
||||
@@ -118,6 +118,7 @@ export function ensureV1Response(
|
||||
isFolder: false,
|
||||
uid: dashboard.metadata.name,
|
||||
k8s: dashboard.metadata,
|
||||
version: parseInt(dashboard.metadata.resourceVersion, 10),
|
||||
},
|
||||
dashboard: spec,
|
||||
};
|
||||
|
||||
@@ -88,6 +88,7 @@ export class K8sDashboardAPI implements DashboardAPI<DashboardDTO> {
|
||||
isFolder: false,
|
||||
uid: dash.metadata.name,
|
||||
k8s: dash.metadata,
|
||||
version: parseInt(dash.metadata.resourceVersion, 10),
|
||||
},
|
||||
dashboard: dash.spec,
|
||||
};
|
||||
|
||||
@@ -69,6 +69,7 @@ export interface DashboardMeta {
|
||||
dashboardNotFound?: boolean;
|
||||
isEmbedded?: boolean;
|
||||
isNew?: boolean;
|
||||
version?: number;
|
||||
|
||||
// When loaded from kubernetes, we stick the raw metadata here
|
||||
// yes weird, but this means all the editor structures can exist unchanged
|
||||
|
||||
Reference in New Issue
Block a user