DataLinks: Fixes an issue __series.name is not working in data link (#34932) (#34960)

(cherry picked from commit c7076c9e19)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
Grot (@grafanabot) 2021-05-31 03:32:13 -04:00 committed by GitHub
parent fdd80b1b4c
commit 7206d16352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<ContextMenuProps> = ({
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<MenuItemProps>((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<MenuItemProps>((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,
};
}),
});
}
}