From 67fe282f7e7801eb04e0de87966c0e9e57e05f4b Mon Sep 17 00:00:00 2001 From: Andre Pereira Date: Mon, 20 Mar 2023 08:57:03 +0000 Subject: [PATCH] Flame Graph: Fix Copy Function Name (#64970) Fix getting the function name when clicking the Copy Function Name context menu item of the flame graph --- .../panel/flamegraph/components/FlameGraph/FlameGraph.tsx | 1 + .../components/FlameGraph/FlameGraphContextMenu.tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraph.tsx b/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraph.tsx index 092ffeab2a9..5fc11b97a15 100644 --- a/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraph.tsx +++ b/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraph.tsx @@ -269,6 +269,7 @@ const FlameGraph = ({ setSelectedBarIndex={setSelectedBarIndex} setRangeMin={setRangeMin} setRangeMax={setRangeMax} + getLabelValue={getLabelValue} /> )} diff --git a/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraphContextMenu.tsx b/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraphContextMenu.tsx index e3ecddcebda..c61a5f3fb28 100644 --- a/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraphContextMenu.tsx +++ b/public/app/plugins/panel/flamegraph/components/FlameGraph/FlameGraphContextMenu.tsx @@ -16,6 +16,7 @@ type Props = { setSelectedBarIndex: (bar: number) => void; setRangeMin: (range: number) => void; setRangeMax: (range: number) => void; + getLabelValue: (label: string | number) => string; }; const FlameGraphContextMenu = ({ @@ -28,6 +29,7 @@ const FlameGraphContextMenu = ({ setSelectedBarIndex, setRangeMin, setRangeMax, + getLabelValue, }: Props) => { const renderMenuItems = () => { return ( @@ -55,7 +57,7 @@ const FlameGraphContextMenu = ({ onClick={() => { if (graphRef.current && contextMenuData) { const bar = levels[contextMenuData.levelIndex][contextMenuData.barIndex]; - navigator.clipboard.writeText(bar.label).then(() => { + navigator.clipboard.writeText(getLabelValue(bar.label)).then(() => { setContextMenuData(undefined); }); }