Dashboards: Use string for AnnoKeyDashboardIsSnapshot (#105306)

This commit is contained in:
Ryan McKinley
2025-05-13 10:09:34 +03:00
committed by GitHub
parent c6428dfc74
commit 242cb8edbd
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ type GrafanaClientAnnotations = {
[AnnoKeyFolderTitle]?: string; [AnnoKeyFolderTitle]?: string;
[AnnoKeyFolderUrl]?: string; [AnnoKeyFolderUrl]?: string;
[AnnoKeySavedFromUI]?: string; [AnnoKeySavedFromUI]?: string;
[AnnoKeyDashboardIsSnapshot]?: boolean; [AnnoKeyDashboardIsSnapshot]?: string;
[AnnoKeyDashboardSnapshotOriginalUrl]?: string; [AnnoKeyDashboardSnapshotOriginalUrl]?: string;
[AnnoKeyGrantPermissions]?: string; [AnnoKeyGrantPermissions]?: string;
// TODO: This should be provided by the API // TODO: This should be provided by the API
@@ -30,6 +30,7 @@ import {
QueryVariableKind, QueryVariableKind,
TextVariableKind, TextVariableKind,
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen'; } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
import { AnnoKeyDashboardIsSnapshot } from 'app/features/apiserver/types';
import { DashboardWithAccessInfo } from 'app/features/dashboard/api/types'; import { DashboardWithAccessInfo } from 'app/features/dashboard/api/types';
import { MIXED_DATASOURCE_NAME } from 'app/plugins/datasource/mixed/MixedDataSource'; import { MIXED_DATASOURCE_NAME } from 'app/plugins/datasource/mixed/MixedDataSource';
@@ -367,7 +368,7 @@ describe('transformSaveModelSchemaV2ToScene', () => {
...defaultDashboard.metadata, ...defaultDashboard.metadata,
annotations: { annotations: {
...defaultDashboard.metadata.annotations, ...defaultDashboard.metadata.annotations,
'grafana.app/dashboard-is-snapshot': true, [AnnoKeyDashboardIsSnapshot]: 'true',
}, },
}, },
}; };
@@ -131,9 +131,15 @@ export function ensureV2Response(
[AnnoKeyUpdatedTimestamp]: dto.meta.updated, [AnnoKeyUpdatedTimestamp]: dto.meta.updated,
[AnnoKeyFolder]: dto.meta.folderUid, [AnnoKeyFolder]: dto.meta.folderUid,
[AnnoKeySlug]: dto.meta.slug, [AnnoKeySlug]: dto.meta.slug,
[AnnoKeyDashboardGnetId]: dashboard.gnetId ?? undefined,
[AnnoKeyDashboardIsSnapshot]: dto.meta.isSnapshot,
}; };
if (dashboard.gnetId) {
annotationsMeta[AnnoKeyDashboardGnetId] = dashboard.gnetId;
}
if (dto.meta.isSnapshot) {
// FIXME -- lets not put non-annotation data in annotations!
annotationsMeta[AnnoKeyDashboardIsSnapshot] = 'true';
}
creationTimestamp = dto.meta.created; creationTimestamp = dto.meta.created;
labelsMeta = { labelsMeta = {
[DeprecatedInternalId]: dashboard.id?.toString() ?? undefined, [DeprecatedInternalId]: dashboard.id?.toString() ?? undefined,