diff --git a/public/app/features/apiserver/types.ts b/public/app/features/apiserver/types.ts index 58df8592274..4ab780003ab 100644 --- a/public/app/features/apiserver/types.ts +++ b/public/app/features/apiserver/types.ts @@ -67,12 +67,15 @@ export const AnnoKeyDashboardIsSnapshot = 'grafana.app/dashboard-is-snapshot'; export const AnnoKeyDashboardSnapshotOriginalUrl = 'grafana.app/dashboard-snapshot-original-url'; /** @deprecated NOT A REAL annotation -- this is just a shim */ export const AnnoKeyDashboardGnetId = 'grafana.app/dashboard-gnet-id'; - /** @deprecated NOT A REAL annotation -- this is just a shim */ export const AnnoKeyFolderTitle = 'grafana.app/folderTitle'; /** @deprecated NOT A REAL annotation -- this is just a shim */ export const AnnoKeyFolderUrl = 'grafana.app/folderUrl'; +/** @experimental only provided by proxies for setup with reloadDashboardsOnParamsChange toggle on */ +/** Not intended to be used in production, we will be removing this in short-term future */ +export const AnnoReloadOnParamsChange = 'grafana.app/reloadOnParamsChange'; + // labels export const DeprecatedInternalId = 'grafana.app/deprecatedInternalID'; @@ -89,6 +92,10 @@ type GrafanaAnnotations = { [AnnoKeySourcePath]?: string; [AnnoKeySourceChecksum]?: string; [AnnoKeySourceTimestamp]?: string; + + /** @experimental only provided by proxies for setup with reloadDashboardsOnParamsChange toggle on */ + /** Not intended to be used in production, we will be removing this in short-term future */ + [AnnoReloadOnParamsChange]?: boolean; }; // Annotations provided by the front-end client diff --git a/public/app/features/dashboard/api/v1.test.ts b/public/app/features/dashboard/api/v1.test.ts index c92d083c2fc..f39538a0df4 100644 --- a/public/app/features/dashboard/api/v1.test.ts +++ b/public/app/features/dashboard/api/v1.test.ts @@ -1,6 +1,6 @@ import { GrafanaConfig, locationUtil } from '@grafana/data'; import { backendSrv } from 'app/core/services/backend_srv'; -import { AnnoKeyFolder } from 'app/features/apiserver/types'; +import { AnnoKeyFolder, AnnoReloadOnParamsChange } from 'app/features/apiserver/types'; import { DashboardDataDTO } from 'app/types/dashboard'; import { DashboardWithAccessInfo } from './types'; @@ -201,6 +201,17 @@ describe('v1 dashboard API', () => { expect(dashboardDTO.meta.folderId).toBeUndefined(); }); + it('should set reloadOnParamsChange to true if AnnoReloadOnParamsChange is present', async () => { + mockGet.mockResolvedValueOnce({ + ...mockDashboardDto, + metadata: { ...mockDashboardDto.metadata, annotations: { [AnnoReloadOnParamsChange]: true } }, + }); + + const api = new K8sDashboardAPI(); + const result = await api.getDashboardDTO('test'); + expect(result.meta.reloadOnParamsChange).toBe(true); + }); + describe('saveDashboard', () => { beforeEach(() => { locationUtil.initialize({ diff --git a/public/app/features/dashboard/api/v1.ts b/public/app/features/dashboard/api/v1.ts index d0d61ed3188..62f069c015d 100644 --- a/public/app/features/dashboard/api/v1.ts +++ b/public/app/features/dashboard/api/v1.ts @@ -18,6 +18,7 @@ import { AnnoKeySourcePath, AnnoKeyManagerAllowsEdits, ManagerKind, + AnnoReloadOnParamsChange, } from 'app/features/apiserver/types'; import { getDashboardUrl } from 'app/features/dashboard-scene/utils/getDashboardUrl'; import { DeleteDashboardResponse } from 'app/features/manage-dashboards/types'; @@ -141,6 +142,12 @@ export class K8sDashboardAPI implements DashboardAPI { }, }; + /** @experimental only provided by proxies for setup with reloadDashboardsOnParamsChange toggle on */ + /** Not intended to be used in production, we will be removing this in short-term future */ + if (dash.metadata.annotations?.[AnnoReloadOnParamsChange]) { + result.meta.reloadOnParamsChange = true; + } + const annotations = dash.metadata.annotations ?? {}; const managerKind = annotations[AnnoKeyManagerKind];