From 7206d16352db99cdc906cf69bd70c15e1a6f1b76 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 31 May 2021 03:32:13 -0400 Subject: [PATCH] DataLinks: Fixes an issue __series.name is not working in data link (#34932) (#34960) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit c7076c9e194f6b4f013459d97f1bf06da50def30) Co-authored-by: Torkel Ödegaard --- .../timeseries/plugins/ContextMenuPlugin.tsx | 46 +++++++------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/public/app/plugins/panel/timeseries/plugins/ContextMenuPlugin.tsx b/public/app/plugins/panel/timeseries/plugins/ContextMenuPlugin.tsx index 006cf73ac5f..9d1e122b062 100644 --- a/public/app/plugins/panel/timeseries/plugins/ContextMenuPlugin.tsx +++ b/public/app/plugins/panel/timeseries/plugins/ContextMenuPlugin.tsx @@ -10,16 +10,8 @@ import { MenuItem, UPlotConfigBuilder, } from '@grafana/ui'; -import { - CartesianCoords2D, - DataFrame, - DataFrameView, - getFieldDisplayName, - InterpolateFunction, - TimeZone, -} from '@grafana/data'; +import { CartesianCoords2D, DataFrame, getFieldDisplayName, InterpolateFunction, TimeZone } from '@grafana/data'; import { useClickAway } from 'react-use'; -import { getFieldLinksSupplier } from '../../../../features/panel/panellinks/linkSuppliers'; import { pluginLog } from '@grafana/ui/src/components/uPlot/utils'; interface ContextMenuPluginProps { @@ -207,28 +199,22 @@ export const ContextMenuView: React.FC = ({ const hasLinks = field.config.links && field.config.links.length > 0; if (hasLinks) { - const linksSupplier = getFieldLinksSupplier({ - display: displayValue, - name: field.name, - view: new DataFrameView(data), - rowIndex: dataIdx, - colIndex: seriesIdx, - field: field.config, - hasLinks, - }); - - if (linksSupplier) { + if (field.getLinks) { items.push({ - items: linksSupplier.getLinks(replaceVariables).map((link) => { - return { - label: link.title, - ariaLabel: link.title, - url: link.href, - target: link.target, - icon: `${link.target === '_self' ? 'link' : 'external-link-alt'}` as IconName, - onClick: link.onClick, - }; - }), + items: field + .getLinks({ + valueRowIndex: dataIdx, + }) + .map((link) => { + return { + label: link.title, + ariaLabel: link.title, + url: link.href, + target: link.target, + icon: `${link.target === '_self' ? 'link' : 'external-link-alt'}` as IconName, + onClick: link.onClick, + }; + }), }); } }