mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* Allow overriding internal data link supplier * Remove SplitOpen and getFieldLinksForExplore dependencies * Fix checking if row index is provided * Fix unit test * Add a comment * Mark SplitOpen as deprecated * Use Panel Context to provide internal data link supplier * Update packages/grafana-ui/src/components/PanelChrome/PanelContext.ts Co-authored-by: Haris Rozajac <58232930+harisrozajac@users.noreply.github.com> * Update packages/grafana-data/src/utils/dataLinks.ts Co-authored-by: Haris Rozajac <58232930+harisrozajac@users.noreply.github.com> * Add missing eventsScope * Fix infinite render loops * Rename internal data link supplier to data link post processor * Update packages/grafana-data/src/field/fieldOverrides.ts Co-authored-by: Torkel Ödegaard <torkel@grafana.com> --------- Co-authored-by: Haris Rozajac <58232930+harisrozajac@users.noreply.github.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
|
|
import { AbsoluteTimeRange, DataFrame, dateTime, EventBus, LoadingState, SplitOpen } from '@grafana/data';
|
|
import { PanelRenderer } from '@grafana/runtime';
|
|
import { PanelChrome, PanelContext, PanelContextProvider } from '@grafana/ui';
|
|
|
|
import { getPanelPluginMeta } from '../plugins/importPanelPlugin';
|
|
|
|
import { useExploreDataLinkPostProcessor } from './hooks/useExploreDataLinkPostProcessor';
|
|
|
|
export interface Props {
|
|
width: number;
|
|
height: number;
|
|
timeZone: string;
|
|
pluginId: string;
|
|
frames: DataFrame[];
|
|
absoluteRange: AbsoluteTimeRange;
|
|
state: LoadingState;
|
|
splitOpenFn: SplitOpen;
|
|
eventBus: EventBus;
|
|
}
|
|
|
|
export function CustomContainer({
|
|
width,
|
|
height,
|
|
timeZone,
|
|
state,
|
|
pluginId,
|
|
frames,
|
|
absoluteRange,
|
|
splitOpenFn,
|
|
eventBus,
|
|
}: Props) {
|
|
const timeRange = useMemo(
|
|
() => ({
|
|
from: dateTime(absoluteRange.from),
|
|
to: dateTime(absoluteRange.to),
|
|
raw: {
|
|
from: dateTime(absoluteRange.from),
|
|
to: dateTime(absoluteRange.to),
|
|
},
|
|
}),
|
|
[absoluteRange.from, absoluteRange.to]
|
|
);
|
|
|
|
const plugin = getPanelPluginMeta(pluginId);
|
|
|
|
const dataLinkPostProcessor = useExploreDataLinkPostProcessor(splitOpenFn, timeRange);
|
|
|
|
const panelContext: PanelContext = {
|
|
dataLinkPostProcessor,
|
|
eventBus,
|
|
eventsScope: 'explore',
|
|
};
|
|
|
|
return (
|
|
<PanelContextProvider value={panelContext}>
|
|
<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>
|
|
</PanelContextProvider>
|
|
);
|
|
}
|