mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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>
This commit is contained in:
parent
73c215ae41
commit
52dbd67a11
@ -28,17 +28,25 @@ export function useContextMenu(
|
|||||||
|
|
||||||
const onNodeOpen = useCallback(
|
const onNodeOpen = useCallback(
|
||||||
(event: MouseEvent<SVGElement>, node: NodeDatum) => {
|
(event: MouseEvent<SVGElement>, node: NodeDatum) => {
|
||||||
const extraNodeItem = config.gridLayout
|
let label = 'Show in Grid layout';
|
||||||
? [
|
let showGridLayout = true;
|
||||||
{
|
|
||||||
label: 'Show in Graph layout',
|
if (config.gridLayout) {
|
||||||
onClick: (node: NodeDatum) => {
|
label = 'Show in Graph layout';
|
||||||
setFocusedNodeId(node.id);
|
showGridLayout = false;
|
||||||
setConfig({ ...config, gridLayout: false });
|
}
|
||||||
},
|
|
||||||
},
|
const extraNodeItem = [
|
||||||
]
|
{
|
||||||
: undefined;
|
label: label,
|
||||||
|
onClick: (node: NodeDatum) => {
|
||||||
|
setFocusedNodeId(node.id);
|
||||||
|
setConfig({ ...config, gridLayout: showGridLayout });
|
||||||
|
setMenu(undefined);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const renderer = getItemsRenderer(getLinks(nodes, node.dataFrameRowIndex), node, extraNodeItem);
|
const renderer = getItemsRenderer(getLinks(nodes, node.dataFrameRowIndex), node, extraNodeItem);
|
||||||
|
|
||||||
if (renderer) {
|
if (renderer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user