From 6c0250dde285affbdc56edcd069473f33d48b3be Mon Sep 17 00:00:00 2001 From: Adela Almasan <88068998+adela-almasan@users.noreply.github.com> Date: Wed, 30 Apr 2025 09:42:15 -0500 Subject: [PATCH] TableNG: Fix interpolation for actions (#104577) --- .../src/components/Table/TableNG/Cells/TableCellNG.tsx | 5 +++-- packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx | 4 ++++ packages/grafana-ui/src/components/Table/TableNG/types.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/Table/TableNG/Cells/TableCellNG.tsx b/packages/grafana-ui/src/components/Table/TableNG/Cells/TableCellNG.tsx index f80642b1448..f046e2ec064 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/Cells/TableCellNG.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/Cells/TableCellNG.tsx @@ -45,6 +45,7 @@ export function TableCellNG(props: TableCellNGProps) { getActions, rowBg, onCellFilterAdded, + replaceVariables, } = props; const cellInspect = field.config?.custom?.inspect ?? false; @@ -75,8 +76,8 @@ export function TableCellNG(props: TableCellNGProps) { const [isHovered, setIsHovered] = useState(false); const actions = useMemo( - () => (getActions ? getActions(frame, field, rowIdx) : []), - [getActions, frame, field, rowIdx] + () => (getActions ? getActions(frame, field, rowIdx, replaceVariables) : []), + [getActions, frame, field, rowIdx, replaceVariables] ); useLayoutEffect(() => { diff --git a/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx b/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx index 4b3b27fb074..a3b2696b6f9 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx @@ -75,6 +75,7 @@ export function TableNG(props: TableNGProps) { data, enableSharedCrosshair, showTypeIcons, + replaceVariables, } = props; const initialSortColumns = useMemo(() => { @@ -456,6 +457,7 @@ export function TableNG(props: TableNGProps) { styles, theme, showTypeIcons, + replaceVariables, ...props, }, handlers: { @@ -667,6 +669,7 @@ export function mapFrameToDataGrid({ timeRange, getActions, showTypeIcons, + replaceVariables, } = options; const { onCellExpand, onColumnResize } = handlers; @@ -815,6 +818,7 @@ export function mapFrameToDataGrid({ getActions={getActions} rowBg={rowBg} onCellFilterAdded={onCellFilterAdded} + replaceVariables={replaceVariables} /> ); }, diff --git a/packages/grafana-ui/src/components/Table/TableNG/types.ts b/packages/grafana-ui/src/components/Table/TableNG/types.ts index c2a760b4f49..b5a8457395b 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/types.ts +++ b/packages/grafana-ui/src/components/Table/TableNG/types.ts @@ -157,6 +157,7 @@ export interface TableCellNGProps { value: TableCellValue; rowBg: Function | undefined; onCellFilterAdded?: TableFilterActionCallback; + replaceVariables?: InterpolateFunction; } /* ------------------------- Specialized Cell Props ------------------------- */