+ {formattedValue}
+
+ );
}
diff --git a/packages/grafana-ui/src/components/Table/TableNG/Cells/BarGaugeCell.tsx b/packages/grafana-ui/src/components/Table/TableNG/Cells/BarGaugeCell.tsx
index 69ebfac671c..3f762218553 100644
--- a/packages/grafana-ui/src/components/Table/TableNG/Cells/BarGaugeCell.tsx
+++ b/packages/grafana-ui/src/components/Table/TableNG/Cells/BarGaugeCell.tsx
@@ -2,8 +2,7 @@ import { ThresholdsConfig, ThresholdsMode, VizOrientation, getFieldConfigWithMin
import { BarGaugeDisplayMode, BarGaugeValueMode, TableCellDisplayMode } from '@grafana/schema';
import { BarGauge } from '../../../BarGauge/BarGauge';
-import { renderSingleLink } from '../../DataLinksActionsTooltip';
-import { useSingleLink } from '../hooks';
+import { MaybeWrapWithLink } from '../MaybeWrapWithLink';
import { BarGaugeCellProps } from '../types';
import { extractPixelValue, getCellOptions, getAlignmentFactor } from '../utils';
@@ -47,25 +46,23 @@ export const BarGaugeCell = ({ value, field, theme, height, width, rowIdx }: Bar
const alignmentFactors = getAlignmentFactor(field, displayValue, rowIdx!);
- const barGaugeComponent = (
-
+ return (
+
+
+
);
-
- const link = useSingleLink(field, rowIdx);
-
- return link == null ? barGaugeComponent : renderSingleLink(link, barGaugeComponent);
};
diff --git a/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx b/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx
index e0c1050396a..9953ef0948e 100644
--- a/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx
+++ b/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx
@@ -4,9 +4,8 @@ import { Property } from 'csstype';
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '../../../../themes/ThemeContext';
-import { renderSingleLink } from '../../DataLinksActionsTooltip';
import { TableCellDisplayMode } from '../../types';
-import { useSingleLink } from '../hooks';
+import { MaybeWrapWithLink } from '../MaybeWrapWithLink';
import { ImageCellProps } from '../types';
const DATALINKS_HEIGHT_OFFSET = 10;
@@ -19,10 +18,13 @@ export const ImageCell = ({ cellOptions, field, height, justifyContent, value, r
const { alt, title } =
cellOptions.type === TableCellDisplayMode.Image ? cellOptions : { alt: undefined, title: undefined };
- const img =
;
- const link = useSingleLink(field, rowIdx);
-
- return {link == null ? img : renderSingleLink(link, img)}
;
+ return (
+
+
+
+
+
+ );
};
const getStyles = (theme: GrafanaTheme2, height: number, justifyContent: Property.JustifyContent) => ({
diff --git a/packages/grafana-ui/src/components/Table/TableNG/Cells/JSONCell.tsx b/packages/grafana-ui/src/components/Table/TableNG/Cells/JSONCell.tsx
index dc195cbcd67..ed66bdef90c 100644
--- a/packages/grafana-ui/src/components/Table/TableNG/Cells/JSONCell.tsx
+++ b/packages/grafana-ui/src/components/Table/TableNG/Cells/JSONCell.tsx
@@ -4,8 +4,7 @@ import { Property } from 'csstype';
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '../../../../themes/ThemeContext';
-import { renderSingleLink } from '../../DataLinksActionsTooltip';
-import { useSingleLink } from '../hooks';
+import { MaybeWrapWithLink } from '../MaybeWrapWithLink';
import { JSONCellProps } from '../types';
export const JSONCell = ({ value, justifyContent, field, rowIdx }: JSONCellProps) => {
@@ -31,9 +30,13 @@ export const JSONCell = ({ value, justifyContent, field, rowIdx }: JSONCellProps
}
}
- const link = useSingleLink(field, rowIdx);
-
- return {link == null ? displayValue : renderSingleLink(link, displayValue)}
;
+ return (
+
+
+ {displayValue}
+
+
+ );
};
const getStyles = (theme: GrafanaTheme2, justifyContent: Property.JustifyContent) => ({
diff --git a/packages/grafana-ui/src/components/Table/TableNG/MaybeWrapWithLink.tsx b/packages/grafana-ui/src/components/Table/TableNG/MaybeWrapWithLink.tsx
new file mode 100644
index 00000000000..443053e8134
--- /dev/null
+++ b/packages/grafana-ui/src/components/Table/TableNG/MaybeWrapWithLink.tsx
@@ -0,0 +1,32 @@
+import { memo, ReactNode } from 'react';
+
+import { Field } from '@grafana/data';
+
+import { renderSingleLink } from '../DataLinksActionsTooltip';
+
+import { getCellLinks } from './utils';
+
+interface MaybeWrapWithLinkProps {
+ field: Field;
+ rowIdx: number;
+ children: ReactNode;
+}
+
+export const MaybeWrapWithLink = memo(({ field, rowIdx, children }: MaybeWrapWithLinkProps): ReactNode => {
+ const linksCount = field.config.links?.length ?? 0;
+ const actionsCount = field.config.actions?.length ?? 0;
+
+ // as real, single link
+ if (linksCount === 1 && actionsCount === 0) {
+ let link = (getCellLinks(field, rowIdx) ?? [])[0];
+ return renderSingleLink(link, children);
+ }
+ // as faux link that acts as hit-area for tooltip activation
+ else if (linksCount + actionsCount > 0) {
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
+ return