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

View File

@ -97,7 +97,7 @@ type GrafanaClientAnnotations = {
[AnnoKeyFolderTitle]?: string;
[AnnoKeyFolderUrl]?: string;
[AnnoKeySavedFromUI]?: string;
[AnnoKeyDashboardIsSnapshot]?: boolean;
[AnnoKeyDashboardIsSnapshot]?: string;
[AnnoKeyDashboardSnapshotOriginalUrl]?: string;
[AnnoKeyGrantPermissions]?: string;
// TODO: This should be provided by the API

View File

@ -30,6 +30,7 @@ import {
QueryVariableKind,
TextVariableKind,
} 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 { MIXED_DATASOURCE_NAME } from 'app/plugins/datasource/mixed/MixedDataSource';
@ -367,7 +368,7 @@ describe('transformSaveModelSchemaV2ToScene', () => {
...defaultDashboard.metadata,
annotations: {
...defaultDashboard.metadata.annotations,
'grafana.app/dashboard-is-snapshot': true,
[AnnoKeyDashboardIsSnapshot]: 'true',
},
},
};

View File

@ -131,9 +131,15 @@ export function ensureV2Response(
[AnnoKeyUpdatedTimestamp]: dto.meta.updated,
[AnnoKeyFolder]: dto.meta.folderUid,
[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;
labelsMeta = {
[DeprecatedInternalId]: dashboard.id?.toString() ?? undefined,