mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: disable annotations (#50984)
* PublicDashboards: disable annotations
This commit is contained in:
parent
64356509b5
commit
25d4ddf959
@ -3083,7 +3083,7 @@ exports[`no type assertions`] = {
|
||||
[25, 30, 27, "Do not use any type assertions.", "3324295634"],
|
||||
[25, 30, 13, "Do not use any type assertions.", "2146830713"]
|
||||
],
|
||||
"public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts:4136590395": [
|
||||
"public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts:674871004": [
|
||||
[25, 29, 9, "Do not use any type assertions.", "3692209159"]
|
||||
],
|
||||
"public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.test.ts:1052443115": [
|
||||
@ -3097,7 +3097,7 @@ exports[`no type assertions`] = {
|
||||
[16, 6, 59, "Do not use any type assertions.", "3685154675"],
|
||||
[16, 6, 49, "Do not use any type assertions.", "1184085652"]
|
||||
],
|
||||
"public/app/features/query/state/DashboardQueryRunner/testHelpers.ts:2779664026": [
|
||||
"public/app/features/query/state/DashboardQueryRunner/testHelpers.ts:1555409841": [
|
||||
[56, 13, 20, "Do not use any type assertions.", "320652245"]
|
||||
],
|
||||
"public/app/features/query/state/PanelQueryRunner.test.ts:2736652574": [
|
||||
@ -9965,11 +9965,11 @@ exports[`no explicit any`] = {
|
||||
[57, 24, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[67, 24, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
],
|
||||
"public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts:4136590395": [
|
||||
"public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts:674871004": [
|
||||
[25, 35, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[30, 27, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[90, 23, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[99, 23, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
[99, 23, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[108, 23, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
],
|
||||
"public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.test.ts:1052443115": [
|
||||
[21, 21, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
@ -10000,7 +10000,7 @@ exports[`no explicit any`] = {
|
||||
[53, 23, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[73, 23, 3, "Unexpected any. Specify a different type.", "193409811"]
|
||||
],
|
||||
"public/app/features/query/state/DashboardQueryRunner/testHelpers.ts:2779664026": [
|
||||
"public/app/features/query/state/DashboardQueryRunner/testHelpers.ts:1555409841": [
|
||||
[7, 40, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[7, 57, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
[14, 37, 3, "Unexpected any. Specify a different type.", "193409811"],
|
||||
|
@ -86,6 +86,15 @@ describe('AnnotationsWorker', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when canWork is called with correct props for a public dashboard with public view', () => {
|
||||
it('then it should return true', () => {
|
||||
const options = getDefaultOptions();
|
||||
options.dashboard.meta.publicDashboardAccessToken = 'accessTokenString';
|
||||
|
||||
expect(worker.canWork(options)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when canWork is called with incorrect props', () => {
|
||||
it('then it should return false', () => {
|
||||
const dashboard: any = { annotations: { list: [] } };
|
||||
|
@ -6,6 +6,7 @@ import { AnnotationQuery, DataSourceApi } from '@grafana/data';
|
||||
import { getDataSourceSrv } from '@grafana/runtime';
|
||||
|
||||
import { AnnotationQueryFinished, AnnotationQueryStarted } from '../../../../types/events';
|
||||
import { DashboardModel } from '../../../dashboard/state';
|
||||
|
||||
import { AnnotationsQueryRunner } from './AnnotationsQueryRunner';
|
||||
import { getDashboardQueryRunner } from './DashboardQueryRunner';
|
||||
@ -28,7 +29,8 @@ export class AnnotationsWorker implements DashboardQueryRunnerWorker {
|
||||
|
||||
canWork({ dashboard }: DashboardQueryRunnerOptions): boolean {
|
||||
const annotations = dashboard.annotations.list.find(AnnotationsWorker.getAnnotationsToProcessFilter);
|
||||
return Boolean(annotations);
|
||||
// We shouldn't return annotations for public dashboards v1
|
||||
return Boolean(annotations) && !this.publicDashboardViewMode(dashboard);
|
||||
}
|
||||
|
||||
work(options: DashboardQueryRunnerOptions): Observable<DashboardQueryRunnerWorkerResult> {
|
||||
@ -91,4 +93,8 @@ export class AnnotationsWorker implements DashboardQueryRunnerWorker {
|
||||
private static getAnnotationsToProcessFilter(annotation: AnnotationQuery): boolean {
|
||||
return annotation.enable && !Boolean(annotation.snapshotData);
|
||||
}
|
||||
|
||||
publicDashboardViewMode(dashboard: DashboardModel): boolean {
|
||||
return dashboard.meta.publicDashboardAccessToken !== undefined && dashboard.meta.publicDashboardAccessToken !== '';
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,9 @@ export function getDefaultOptions(): DashboardQueryRunnerOptions {
|
||||
publish: jest.fn(),
|
||||
},
|
||||
panels: [{ alert: {} } as any],
|
||||
meta: {
|
||||
publicDashboardAccessToken: '',
|
||||
},
|
||||
};
|
||||
const range = getDefaultTimeRange();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user