Files
grafana/packages/grafana-ui/src/utils/dataLinks.ts
Dominik Prokop b2b0be7b93 Table panel: Add multiple data links support to Default, Image and JSONView cells (#51162)
* Table panel: Support multiple data links in default cell

* Table panel: Show data links for Image and JSONView cells

* Simplify DataLinksContextMenu api

* Betterer
2022-06-27 05:23:29 -07:00

21 lines
578 B
TypeScript

import { LinkModel } from '@grafana/data';
import { MenuItemProps } from '../components/Menu/MenuItem';
/**
* Delays creating links until we need to open the ContextMenu
*/
export const linkModelToContextMenuItems: (links: () => LinkModel[]) => MenuItemProps[] = (links) => {
return links().map((link) => {
return {
label: link.title,
ariaLabel: link.title,
// TODO: rename to href
url: link.href,
target: link.target,
icon: `${link.target === '_blank' ? 'external-link-alt' : 'link'}`,
onClick: link.onClick,
};
});
};