The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
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.
 
 
 
 
 
 
grafana/public/app/features/dashboard-scene/scene/PanelNotices.tsx

48 lines
1.2 KiB

import { SceneComponentProps, SceneObjectBase, VizPanel, sceneGraph } from '@grafana/scenes';
import { PanelHeaderNotices } from 'app/features/dashboard/dashgrid/PanelHeader/PanelHeaderNotices';
import { getPanelIdForVizPanel } from '../utils/utils';
export class PanelNotices extends SceneObjectBase {
static Component = PanelNoticesRenderer;
constructor() {
super({});
this.addActivationHandler(this.onActivate);
}
private onActivate = () => {
const panel = this.parent;
if (!panel || !(panel instanceof VizPanel)) {
throw new Error('PanelNotices can be used only as title items for VizPanel');
}
};
public getPanel() {
const panel = this.parent;
if (panel && panel instanceof VizPanel) {
return panel;
}
return null;
}
}
function PanelNoticesRenderer({ model }: SceneComponentProps<PanelNotices>) {
const panel = model.getPanel();
const dataObject = sceneGraph.getData(model);
const data = dataObject.useState();
if (!panel) {
return null;
}
const panelId = getPanelIdForVizPanel(panel);
if (data.data?.series) {
return <PanelHeaderNotices frames={data.data?.series} panelId={panelId} />;
}
return null;
}