1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.0 KiB

import React, { FC, useCallback } from 'react';
import { DataFrame, QueryResultMetaNotice } from '@grafana/data';
import { PanelHeaderNotice } from './PanelHeaderNotice';
import { locationService } from '@grafana/runtime';
interface Props {
panelId: number;
frames: DataFrame[];
}
export const PanelHeaderNotices: FC<Props> = ({ frames, panelId }) => {
const openInspect = useCallback(
(e: React.SyntheticEvent, tab: string) => {
e.stopPropagation();
locationService.partial({ inspect: panelId, inspectTab: tab });
},
[panelId]
);
// dedupe on severity
const notices: Record<string, QueryResultMetaNotice> = {};
for (const frame of frames) {
if (!frame.meta || !frame.meta.notices) {
continue;
}
for (const notice of frame.meta.notices) {
notices[notice.severity] = notice;
}
}
return (
<>
{Object.values(notices).map((notice) => (
<PanelHeaderNotice notice={notice} onClick={openInspect} key={notice.severity} />
))}
</>
);
};