Node Graph: Always show context menu (#56876)

* Ensure context menu always appears

* Close the context menu after selecting the alternative layout

Co-authored-by: Hamas Shafiq <hamas.shafiq@grafana.com>
pull/57466/head^2
Joey Tawadrous 3 years ago committed by GitHub
parent 73c215ae41
commit 52dbd67a11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      public/app/plugins/panel/nodeGraph/useContextMenu.tsx

@ -28,17 +28,25 @@ export function useContextMenu(
const onNodeOpen = useCallback(
(event: MouseEvent<SVGElement>, node: NodeDatum) => {
const extraNodeItem = config.gridLayout
? [
let label = 'Show in Grid layout';
let showGridLayout = true;
if (config.gridLayout) {
label = 'Show in Graph layout';
showGridLayout = false;
}
const extraNodeItem = [
{
label: 'Show in Graph layout',
label: label,
onClick: (node: NodeDatum) => {
setFocusedNodeId(node.id);
setConfig({ ...config, gridLayout: false });
setConfig({ ...config, gridLayout: showGridLayout });
setMenu(undefined);
},
},
]
: undefined;
];
const renderer = getItemsRenderer(getLinks(nodes, node.dataFrameRowIndex), node, extraNodeItem);
if (renderer) {

Loading…
Cancel
Save