mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Explore: Allow the use of plugin panels Allow plugins to define a visualisation to use in explore that comes from a plugin. * Explore: Allow the use of plugin panels Rename ExplorePanel to CustomContainer * Explore: Allow the use of plugin panels Changed CustomContainer to take all frames for plugin id. Add field preferredVisualisationPluginId to frame metadata. Updated decorators to check for plugin and fallback to preferredVisualisationType if plugin cannot be found. * Explore: Allow the use of plugin panels Handle case where there are no custom frames * Explore: Allow the use of plugin panels Add test cases
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
|
|
import { AbsoluteTimeRange, DataFrame, dateTime, LoadingState } from '@grafana/data';
|
|
import { PanelRenderer } from '@grafana/runtime';
|
|
import { PanelChrome } from '@grafana/ui';
|
|
|
|
import { getPanelPluginMeta } from '../plugins/importPanelPlugin';
|
|
|
|
export interface Props {
|
|
width: number;
|
|
height: number;
|
|
timeZone: string;
|
|
pluginId: string;
|
|
frames: DataFrame[];
|
|
absoluteRange: AbsoluteTimeRange;
|
|
state: LoadingState;
|
|
}
|
|
|
|
export function CustomContainer({ width, height, timeZone, state, pluginId, frames, absoluteRange }: Props) {
|
|
const timeRange = {
|
|
from: dateTime(absoluteRange.from),
|
|
to: dateTime(absoluteRange.to),
|
|
raw: {
|
|
from: dateTime(absoluteRange.from),
|
|
to: dateTime(absoluteRange.to),
|
|
},
|
|
};
|
|
|
|
const plugin = getPanelPluginMeta(pluginId);
|
|
|
|
return (
|
|
<PanelChrome title={plugin.name} width={width} height={height} loadingState={state}>
|
|
{(innerWidth, innerHeight) => (
|
|
<PanelRenderer
|
|
data={{ series: frames, state: state, timeRange }}
|
|
pluginId={pluginId}
|
|
title=""
|
|
width={innerWidth}
|
|
height={innerHeight}
|
|
timeZone={timeZone}
|
|
/>
|
|
)}
|
|
</PanelChrome>
|
|
);
|
|
}
|