Dashboard: Add experimental reloadOnParamsChange annotation support in v1beta1 API client (#109461)

Warning: This is heavily experimental feature and WILL BE REMOVED in a few months.
This commit is contained in:
Dominik Prokop
2025-08-13 11:43:22 +02:00
committed by GitHub
parent 47aa892d24
commit 28030ce000
3 changed files with 27 additions and 2 deletions
+8 -1
View File
@@ -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
+12 -1
View File
@@ -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({
+7
View File
@@ -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<DashboardDTO, Dashboard> {
},
};
/** @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];