mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Annotations: Fixes so alert annotations are visible in the correct Panel (#37959)
This commit is contained in:
parent
3ca00f90b5
commit
0d2aaed3e8
@ -94,4 +94,64 @@ describe('DataFrame to annotations', () => {
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('all valid key names should be included in the output result', async () => {
|
||||||
|
const frame = toDataFrame({
|
||||||
|
fields: [
|
||||||
|
{ name: 'time', values: [100] },
|
||||||
|
{ name: 'timeEnd', values: [200] },
|
||||||
|
{ name: 'title', values: ['title'] },
|
||||||
|
{ name: 'text', values: ['text'] },
|
||||||
|
{ name: 'tags', values: ['t1,t2,t3'] },
|
||||||
|
{ name: 'id', values: [1] },
|
||||||
|
{ name: 'userId', values: ['Admin'] },
|
||||||
|
{ name: 'login', values: ['admin'] },
|
||||||
|
{ name: 'email', values: ['admin@unknown.us'] },
|
||||||
|
{ name: 'prevState', values: ['normal'] },
|
||||||
|
{ name: 'newState', values: ['alerting'] },
|
||||||
|
{ name: 'data', values: [{ text: 'a', value: 'A' }] },
|
||||||
|
{ name: 'panelId', values: [4] },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const observable = getAnnotationsFromData([frame]);
|
||||||
|
|
||||||
|
await expect(observable).toEmitValues([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
color: 'red',
|
||||||
|
data: { text: 'a', value: 'A' },
|
||||||
|
email: 'admin@unknown.us',
|
||||||
|
id: 1,
|
||||||
|
login: 'admin',
|
||||||
|
newState: 'alerting',
|
||||||
|
panelId: 4,
|
||||||
|
prevState: 'normal',
|
||||||
|
tags: ['t1', 't2', 't3'],
|
||||||
|
text: 'text',
|
||||||
|
time: 100,
|
||||||
|
timeEnd: 200,
|
||||||
|
title: 'title',
|
||||||
|
type: 'default',
|
||||||
|
userId: 'Admin',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('key names that are not valid should be excluded in the output result', async () => {
|
||||||
|
const frame = toDataFrame({
|
||||||
|
fields: [
|
||||||
|
{ name: 'time', values: [100] },
|
||||||
|
{ name: 'text', values: ['text'] },
|
||||||
|
{ name: 'someData', values: [{ value: 'bar' }] },
|
||||||
|
{ name: 'panelSource', values: ['100'] },
|
||||||
|
{ name: 'timeStart', values: [100] },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const observable = getAnnotationsFromData([frame]);
|
||||||
|
|
||||||
|
await expect(observable).toEmitValues([[{ color: 'red', text: 'text', time: 100, type: 'default' }]]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -122,6 +122,7 @@ const alertEventAndAnnotationFields: AnnotationFieldInfo[] = [
|
|||||||
{ key: 'prevState' },
|
{ key: 'prevState' },
|
||||||
{ key: 'newState' },
|
{ key: 'newState' },
|
||||||
{ key: 'data' as any },
|
{ key: 'data' as any },
|
||||||
|
{ key: 'panelId' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function getAnnotationsFromData(
|
export function getAnnotationsFromData(
|
||||||
|
Loading…
Reference in New Issue
Block a user