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/ViewPanelScene.tsx

32 lines
917 B

import { SceneComponentProps, SceneObjectBase, SceneObjectRef, SceneObjectState, VizPanel } from '@grafana/scenes';
import { activateInActiveParents } from '../utils/utils';
interface ViewPanelSceneState extends SceneObjectState {
panelRef: SceneObjectRef<VizPanel>;
}
export class ViewPanelScene extends SceneObjectBase<ViewPanelSceneState> {
public constructor(state: ViewPanelSceneState) {
super(state);
this.addActivationHandler(this._activationHandler.bind(this));
}
public _activationHandler() {
const panel = this.state.panelRef.resolve();
return activateInActiveParents(panel);
}
public getUrlKey() {
return this.state.panelRef.resolve().state.key;
}
public static Component = ({ model }: SceneComponentProps<ViewPanelScene>) => {
const { panelRef } = model.useState();
const panel = panelRef.resolve();
return <panel.Component model={panel} />;
};
}