mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
VizTooltips: Disable newVizTooltips when dashboard shared cursor is enabled (#79996)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import uPlot from 'uplot';
|
||||
|
||||
import { Field, getDisplayProcessor, getLinksSupplier, PanelProps } from '@grafana/data';
|
||||
import { DashboardCursorSync, Field, getDisplayProcessor, getLinksSupplier, PanelProps } from '@grafana/data';
|
||||
import { PanelDataErrorView } from '@grafana/runtime';
|
||||
import { TooltipDisplayMode } from '@grafana/schema';
|
||||
import { TooltipPlugin, TooltipPlugin2, UPlotConfigBuilder, usePanelContext, useTheme2, ZoomPlugin } from '@grafana/ui';
|
||||
@@ -229,6 +229,7 @@ export const CandlestickPanel = ({
|
||||
}
|
||||
|
||||
const enableAnnotationCreation = Boolean(canAddAnnotations && canAddAnnotations());
|
||||
const showNewVizTooltips = config.featureToggles.newVizTooltips && sync && sync() === DashboardCursorSync.Off;
|
||||
|
||||
return (
|
||||
<TimeSeries
|
||||
@@ -257,7 +258,7 @@ export const CandlestickPanel = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
{config.featureToggles.newVizTooltips ? (
|
||||
{showNewVizTooltips ? (
|
||||
<TooltipPlugin2
|
||||
config={uplotConfig}
|
||||
hoverMode={TooltipHoverMode.xAll}
|
||||
@@ -293,7 +294,7 @@ export const CandlestickPanel = ({
|
||||
<AnnotationsPlugin annotations={data.annotations} config={uplotConfig} timeZone={timeZone} />
|
||||
)}
|
||||
{/* Enables annotations creation*/}
|
||||
{!config.featureToggles.newVizTooltips ? (
|
||||
{!showNewVizTooltips ? (
|
||||
enableAnnotationCreation ? (
|
||||
<AnnotationEditorPlugin data={alignedDataFrame} timeZone={timeZone} config={uplotConfig}>
|
||||
{({ startAnnotating }) => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { css } from '@emotion/css';
|
||||
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
||||
|
||||
import {
|
||||
DashboardCursorSync,
|
||||
DataFrame,
|
||||
DataFrameType,
|
||||
Field,
|
||||
@@ -156,6 +157,7 @@ export const HeatmapPanel = ({
|
||||
// ugh
|
||||
const dataRef = useRef(info);
|
||||
dataRef.current = info;
|
||||
const showNewVizTooltips = config.featureToggles.newVizTooltips && sync && sync() === DashboardCursorSync.Off;
|
||||
|
||||
const builder = useMemo(() => {
|
||||
const scaleConfig: ScaleDistributionConfig = dataRef.current?.heatmap?.fields[1].config?.custom?.scaleDistribution;
|
||||
@@ -164,8 +166,8 @@ export const HeatmapPanel = ({
|
||||
dataRef,
|
||||
theme,
|
||||
eventBus,
|
||||
onhover: onhover,
|
||||
onclick: options.tooltip.show ? onclick : null,
|
||||
onhover: !showNewVizTooltips ? onhover : null,
|
||||
onclick: !showNewVizTooltips && options.tooltip.show ? onclick : null,
|
||||
isToolTipOpen,
|
||||
timeZone,
|
||||
getTimeRange: () => timeRangeRef.current,
|
||||
@@ -223,16 +225,14 @@ export const HeatmapPanel = ({
|
||||
);
|
||||
}
|
||||
|
||||
const newVizTooltips = config.featureToggles.newVizTooltips ?? false;
|
||||
|
||||
return (
|
||||
<>
|
||||
<VizLayout width={width} height={height} legend={renderLegend()}>
|
||||
{(vizWidth: number, vizHeight: number) => (
|
||||
<UPlotChart config={builder} data={facets as any} width={vizWidth} height={vizHeight}>
|
||||
{/*children ? children(config, alignedFrame) : null*/}
|
||||
{!newVizTooltips && <ZoomPlugin config={builder} onZoom={onChangeTimeRange} />}
|
||||
{newVizTooltips && options.tooltip.show && (
|
||||
{!showNewVizTooltips && <ZoomPlugin config={builder} onZoom={onChangeTimeRange} />}
|
||||
{showNewVizTooltips && options.tooltip.show && (
|
||||
<TooltipPlugin2
|
||||
config={builder}
|
||||
hoverMode={TooltipHoverMode.xyOne}
|
||||
@@ -267,7 +267,7 @@ export const HeatmapPanel = ({
|
||||
</UPlotChart>
|
||||
)}
|
||||
</VizLayout>
|
||||
{!newVizTooltips && (
|
||||
{!showNewVizTooltips && (
|
||||
<Portal>
|
||||
{hover && options.tooltip.show && (
|
||||
<VizTooltipContainer
|
||||
|
||||
@@ -163,6 +163,7 @@ export const StateTimelinePanel = ({
|
||||
}
|
||||
}
|
||||
const enableAnnotationCreation = Boolean(canAddAnnotations && canAddAnnotations());
|
||||
const showNewVizTooltips = config.featureToggles.newVizTooltips && sync && sync() === DashboardCursorSync.Off;
|
||||
|
||||
return (
|
||||
<TimelineChart
|
||||
@@ -178,7 +179,7 @@ export const StateTimelinePanel = ({
|
||||
mode={TimelineMode.Changes}
|
||||
>
|
||||
{(builder, alignedFrame) => {
|
||||
if (oldConfig.current !== builder) {
|
||||
if (oldConfig.current !== builder && !showNewVizTooltips) {
|
||||
oldConfig.current = addTooltipSupport({
|
||||
config: builder,
|
||||
onUPlotClick,
|
||||
@@ -195,7 +196,7 @@ export const StateTimelinePanel = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
{config.featureToggles.newVizTooltips ? (
|
||||
{showNewVizTooltips ? (
|
||||
<>
|
||||
{options.tooltip.mode !== TooltipDisplayMode.None && (
|
||||
<TooltipPlugin2
|
||||
|
||||
@@ -190,6 +190,8 @@ export const StatusHistoryPanel = ({
|
||||
);
|
||||
}
|
||||
|
||||
const showNewVizTooltips = config.featureToggles.newVizTooltips && sync && sync() === DashboardCursorSync.Off;
|
||||
|
||||
return (
|
||||
<TimelineChart
|
||||
theme={theme}
|
||||
@@ -204,7 +206,7 @@ export const StatusHistoryPanel = ({
|
||||
mode={TimelineMode.Samples}
|
||||
>
|
||||
{(builder, alignedFrame) => {
|
||||
if (oldConfig.current !== builder) {
|
||||
if (oldConfig.current !== builder && !showNewVizTooltips) {
|
||||
oldConfig.current = addTooltipSupport({
|
||||
config: builder,
|
||||
onUPlotClick,
|
||||
@@ -228,7 +230,7 @@ export const StatusHistoryPanel = ({
|
||||
disableCanvasRendering={true}
|
||||
/>
|
||||
)}
|
||||
{config.featureToggles.newVizTooltips ? (
|
||||
{showNewVizTooltips ? (
|
||||
<>
|
||||
{options.tooltip.mode !== TooltipDisplayMode.None && (
|
||||
<TooltipPlugin2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { PanelProps, DataFrameType } from '@grafana/data';
|
||||
import { PanelProps, DataFrameType, DashboardCursorSync } from '@grafana/data';
|
||||
import { PanelDataErrorView } from '@grafana/runtime';
|
||||
import { TooltipDisplayMode } from '@grafana/schema';
|
||||
import { KeyboardPlugin, TooltipPlugin, TooltipPlugin2, usePanelContext, ZoomPlugin } from '@grafana/ui';
|
||||
@@ -64,6 +64,7 @@ export const TimeSeriesPanel = ({
|
||||
}
|
||||
|
||||
const enableAnnotationCreation = Boolean(canAddAnnotations && canAddAnnotations());
|
||||
const showNewVizTooltips = config.featureToggles.newVizTooltips && sync && sync() === DashboardCursorSync.Off;
|
||||
|
||||
return (
|
||||
<TimeSeries
|
||||
@@ -92,7 +93,7 @@ export const TimeSeriesPanel = ({
|
||||
<KeyboardPlugin config={uplotConfig} />
|
||||
{options.tooltip.mode === TooltipDisplayMode.None || (
|
||||
<>
|
||||
{config.featureToggles.newVizTooltips ? (
|
||||
{showNewVizTooltips ? (
|
||||
<TooltipPlugin2
|
||||
config={uplotConfig}
|
||||
hoverMode={
|
||||
@@ -135,7 +136,7 @@ export const TimeSeriesPanel = ({
|
||||
<AnnotationsPlugin annotations={data.annotations} config={uplotConfig} timeZone={timeZone} />
|
||||
)}
|
||||
{/*Enables annotations creation*/}
|
||||
{!config.featureToggles.newVizTooltips ? (
|
||||
{!showNewVizTooltips ? (
|
||||
enableAnnotationCreation ? (
|
||||
<AnnotationEditorPlugin data={alignedDataFrame} timeZone={timeZone} config={uplotConfig}>
|
||||
{({ startAnnotating }) => {
|
||||
|
||||
@@ -26,7 +26,7 @@ export const TrendPanel = ({
|
||||
replaceVariables,
|
||||
id,
|
||||
}: PanelProps<Options>) => {
|
||||
const { sync, dataLinkPostProcessor } = usePanelContext();
|
||||
const { dataLinkPostProcessor } = usePanelContext();
|
||||
// Need to fallback to first number field if no xField is set in options otherwise panel crashes 😬
|
||||
const trendXFieldName =
|
||||
options.xField ?? data.series[0].fields.find((field) => field.type === FieldType.number)?.name;
|
||||
@@ -137,7 +137,6 @@ export const TrendPanel = ({
|
||||
data={alignedDataFrame}
|
||||
mode={options.tooltip.mode}
|
||||
sortOrder={options.tooltip.sort}
|
||||
sync={sync}
|
||||
dataIdxs={dataIdxs}
|
||||
seriesIdx={seriesIdx}
|
||||
isPinned={isPinned}
|
||||
@@ -152,7 +151,6 @@ export const TrendPanel = ({
|
||||
config={uPlotConfig}
|
||||
mode={options.tooltip.mode}
|
||||
sortOrder={options.tooltip.sort}
|
||||
sync={sync}
|
||||
timeZone={timeZone}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -43,7 +43,6 @@ export const TrendTooltip = ({
|
||||
data,
|
||||
mode = TooltipDisplayMode.Single,
|
||||
sortOrder = SortOrder.None,
|
||||
sync,
|
||||
dataIdxs,
|
||||
seriesIdx,
|
||||
isPinned,
|
||||
|
||||
Reference in New Issue
Block a user