Skip to content

Commit f0dd702

Browse files
committed
Fix double-click opening source view and context menus in butterfly wings
- Fix wrong tab slug ('calltree' → 'function-list') in _onEnterOrDoubleClick for SelfWing, UpperWingFlameGraph, LowerWing, and UpperWing so that double-clicking a call node opens the bottom box for the correct tab - Add a contextMenuId prop to FlameGraph (defaulting to 'CallNodeContextMenu') so wings can specify a different context menu - Wire up FunctionListContextMenu for UpperWingFlameGraph and SelfWing: right-clicking now dispatches changeRightClickedFunctionIndex so the FunctionListContextMenu (already rendered in Details) can respond
1 parent 76b921f commit f0dd702

5 files changed

Lines changed: 32 additions & 8 deletions

File tree

src/components/calltree/LowerWing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class LowerWingImpl extends PureComponent<Props> {
202202
_onEnterOrDoubleClick = (nodeId: IndexIntoCallNodeTable) => {
203203
const { tree, updateBottomBoxContentsAndMaybeOpen } = this.props;
204204
const bottomBoxInfo = tree.getBottomBoxInfoForCallNode(nodeId);
205-
updateBottomBoxContentsAndMaybeOpen('calltree', bottomBoxInfo);
205+
updateBottomBoxContentsAndMaybeOpen('function-list', bottomBoxInfo);
206206
};
207207

208208
maybeProcureInterestingInitialSelection() {

src/components/calltree/SelfWing.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import {
2222
getSelectedThreadsKey,
2323
getInvertCallstack,
2424
} from 'firefox-profiler/selectors/url-state';
25-
import { updateBottomBoxContentsAndMaybeOpen } from 'firefox-profiler/actions/profile-view';
25+
import {
26+
updateBottomBoxContentsAndMaybeOpen,
27+
changeRightClickedFunctionIndex,
28+
} from 'firefox-profiler/actions/profile-view';
2629

2730
import type {
2831
Thread,
@@ -69,6 +72,7 @@ type StateProps = {
6972

7073
type DispatchProps = {
7174
readonly updateBottomBoxContentsAndMaybeOpen: typeof updateBottomBoxContentsAndMaybeOpen;
75+
readonly changeRightClickedFunctionIndex: typeof changeRightClickedFunctionIndex;
7276
};
7377

7478
type Props = ConnectedProps<{}, StateProps, DispatchProps>;
@@ -108,6 +112,11 @@ class SelfWingImpl extends React.PureComponent<Props, LocalState> {
108112
callNodeIndex: IndexIntoCallNodeTable | null
109113
) => {
110114
this.setState({ rightClickedCallNodeIndex: callNodeIndex });
115+
const { callNodeInfo, threadsKey, changeRightClickedFunctionIndex } =
116+
this.props;
117+
const funcIndex =
118+
callNodeIndex !== null ? callNodeInfo.funcForNode(callNodeIndex) : null;
119+
changeRightClickedFunctionIndex(threadsKey, funcIndex);
111120
};
112121

113122
_onCallNodeEnterOrDoubleClick = (
@@ -118,7 +127,7 @@ class SelfWingImpl extends React.PureComponent<Props, LocalState> {
118127
}
119128
const { callTree, updateBottomBoxContentsAndMaybeOpen } = this.props;
120129
const bottomBoxInfo = callTree.getBottomBoxInfoForCallNode(callNodeIndex);
121-
updateBottomBoxContentsAndMaybeOpen('calltree', bottomBoxInfo);
130+
updateBottomBoxContentsAndMaybeOpen('function-list', bottomBoxInfo);
122131
};
123132

124133
// Transforms are disabled in the SelfWing because it operates on an ephemeral
@@ -177,6 +186,7 @@ class SelfWingImpl extends React.PureComponent<Props, LocalState> {
177186
}
178187
tracedTiming={null}
179188
displayStackType={displayStackType}
189+
contextMenuId="FunctionListContextMenu"
180190
onSelectedCallNodeChange={this._onSelectedCallNodeChange}
181191
onRightClickedCallNodeChange={this._onRightClickedCallNodeChange}
182192
onCallNodeEnterOrDoubleClick={this._onCallNodeEnterOrDoubleClick}
@@ -215,6 +225,7 @@ export const SelfWing = explicitConnect<{}, StateProps, DispatchProps>({
215225
}),
216226
mapDispatchToProps: {
217227
updateBottomBoxContentsAndMaybeOpen,
228+
changeRightClickedFunctionIndex,
218229
},
219230
component: SelfWingImpl,
220231
});

src/components/calltree/UpperWing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class UpperWingImpl extends PureComponent<Props> {
204204
_onEnterOrDoubleClick = (nodeId: IndexIntoCallNodeTable) => {
205205
const { tree, updateBottomBoxContentsAndMaybeOpen } = this.props;
206206
const bottomBoxInfo = tree.getBottomBoxInfoForCallNode(nodeId);
207-
updateBottomBoxContentsAndMaybeOpen('calltree', bottomBoxInfo);
207+
updateBottomBoxContentsAndMaybeOpen('function-list', bottomBoxInfo);
208208
};
209209

210210
maybeProcureInterestingInitialSelection() {

src/components/calltree/UpperWingFlameGraph.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import {
2626
changeUpperWingSelectedCallNode,
2727
changeUpperWingRightClickedCallNode,
28+
changeRightClickedFunctionIndex,
2829
handleCallNodeTransformShortcut,
2930
updateBottomBoxContentsAndMaybeOpen,
3031
} from 'firefox-profiler/actions/profile-view';
@@ -83,6 +84,7 @@ type StateProps = {
8384
type DispatchProps = {
8485
readonly changeUpperWingSelectedCallNode: typeof changeUpperWingSelectedCallNode;
8586
readonly changeUpperWingRightClickedCallNode: typeof changeUpperWingRightClickedCallNode;
87+
readonly changeRightClickedFunctionIndex: typeof changeRightClickedFunctionIndex;
8688
readonly handleCallNodeTransformShortcut: typeof handleCallNodeTransformShortcut;
8789
readonly updateBottomBoxContentsAndMaybeOpen: typeof updateBottomBoxContentsAndMaybeOpen;
8890
};
@@ -119,12 +121,19 @@ class UpperWingFlameGraphImpl
119121
_onRightClickedCallNodeChange = (
120122
callNodeIndex: IndexIntoCallNodeTable | null
121123
) => {
122-
const { callNodeInfo, threadsKey, changeUpperWingRightClickedCallNode } =
123-
this.props;
124+
const {
125+
callNodeInfo,
126+
threadsKey,
127+
changeUpperWingRightClickedCallNode,
128+
changeRightClickedFunctionIndex,
129+
} = this.props;
124130
changeUpperWingRightClickedCallNode(
125131
threadsKey,
126132
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
127133
);
134+
const funcIndex =
135+
callNodeIndex !== null ? callNodeInfo.funcForNode(callNodeIndex) : null;
136+
changeRightClickedFunctionIndex(threadsKey, funcIndex);
128137
};
129138

130139
_onCallNodeEnterOrDoubleClick = (
@@ -135,7 +144,7 @@ class UpperWingFlameGraphImpl
135144
}
136145
const { callTree, updateBottomBoxContentsAndMaybeOpen } = this.props;
137146
const bottomBoxInfo = callTree.getBottomBoxInfoForCallNode(callNodeIndex);
138-
updateBottomBoxContentsAndMaybeOpen('calltree', bottomBoxInfo);
147+
updateBottomBoxContentsAndMaybeOpen('function-list', bottomBoxInfo);
139148
};
140149

141150
_onKeyboardTransformShortcut = (
@@ -198,6 +207,7 @@ class UpperWingFlameGraphImpl
198207
}
199208
tracedTiming={tracedTiming}
200209
displayStackType={displayStackType}
210+
contextMenuId="FunctionListContextMenu"
201211
onSelectedCallNodeChange={this._onSelectedCallNodeChange}
202212
onRightClickedCallNodeChange={this._onRightClickedCallNodeChange}
203213
onCallNodeEnterOrDoubleClick={this._onCallNodeEnterOrDoubleClick}
@@ -247,6 +257,7 @@ export const UpperWingFlameGraph = explicitConnectWithForwardRef<
247257
mapDispatchToProps: {
248258
changeUpperWingSelectedCallNode,
249259
changeUpperWingRightClickedCallNode,
260+
changeRightClickedFunctionIndex,
250261
handleCallNodeTransformShortcut,
251262
updateBottomBoxContentsAndMaybeOpen,
252263
},

src/components/flame-graph/FlameGraph.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type Props = {
6565
readonly ctssSampleCategoriesAndSubcategories: SampleCategoriesAndSubcategories;
6666
readonly tracedTiming: CallTreeTimings | null;
6767
readonly displayStackType: boolean;
68+
readonly contextMenuId?: string;
6869
readonly onSelectedCallNodeChange: (
6970
callNodeIndex: IndexIntoCallNodeTable | null
7071
) => void;
@@ -282,6 +283,7 @@ class FlameGraphImpl
282283
ctssSampleCategoriesAndSubcategories,
283284
tracedTiming,
284285
displayStackType,
286+
contextMenuId = 'CallNodeContextMenu',
285287
onSelectedCallNodeChange,
286288
onRightClickedCallNodeChange,
287289
onCallNodeEnterOrDoubleClick,
@@ -305,7 +307,7 @@ class FlameGraphImpl
305307
return (
306308
<div className="flameGraphContent" onKeyDown={this._handleKeyDown}>
307309
<ContextMenuTrigger
308-
id="CallNodeContextMenu"
310+
id={contextMenuId}
309311
attributes={{
310312
className: 'treeViewContextMenu',
311313
}}

0 commit comments

Comments
 (0)