Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions src/components/timeline/TrackThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
changeSelectedCallNode,
focusCallTree,
selectLeafCallNode,
selectBestAncestorCallNodeAndExpandCallTree,
} from '../../actions/profile-view';
import { reportTrackThreadHeight } from '../../actions/app';
import EmptyThreadIndicator from './EmptyThreadIndicator';
Expand Down Expand Up @@ -81,7 +80,6 @@ type DispatchProps = {|
+changeSelectedCallNode: typeof changeSelectedCallNode,
+focusCallTree: typeof focusCallTree,
+selectLeafCallNode: typeof selectLeafCallNode,
+selectBestAncestorCallNodeAndExpandCallTree: typeof selectBestAncestorCallNodeAndExpandCallTree,
+reportTrackThreadHeight: typeof reportTrackThreadHeight,
|};

Expand All @@ -92,31 +90,15 @@ type Props = {|

class TimelineTrackThread extends PureComponent<Props> {
/**
* Handle when a sample is clicked in the ThreadStackGraph. This will select
* the leaf-most stack frame or call node.
* Handle when a sample is clicked in the ThreadStackGraph and in the ThreadActivityGraph.
* This will select the leaf-most stack frame or call node.
*/
_onSampleClick = (sampleIndex: IndexIntoSamplesTable) => {
const { threadIndex, selectLeafCallNode, focusCallTree } = this.props;
selectLeafCallNode(threadIndex, sampleIndex);
focusCallTree();
};

/**
* Handle when the ThreadActivityGraph is clicked. It uses a slightly different
* strategy of selecting the "best" ancestor call node for a given sample.
* This strategy should make for more interesting selections when clicking around
* the graph.
*/
_onActivitySampleClick = (sampleIndex: IndexIntoSamplesTable) => {
const {
threadIndex,
selectBestAncestorCallNodeAndExpandCallTree,
focusCallTree,
} = this.props;
selectBestAncestorCallNodeAndExpandCallTree(threadIndex, sampleIndex);
focusCallTree();
};

_onMarkerSelect = (
threadIndex: ThreadIndex,
start: Milliseconds,
Expand Down Expand Up @@ -206,7 +188,7 @@ class TimelineTrackThread extends PureComponent<Props> {
fullThread={fullThread}
rangeStart={rangeStart}
rangeEnd={rangeEnd}
onSampleClick={this._onActivitySampleClick}
onSampleClick={this._onSampleClick}
categories={categories}
samplesSelectedStates={samplesSelectedStates}
/>
Expand Down Expand Up @@ -270,7 +252,6 @@ export default explicitConnect<OwnProps, StateProps, DispatchProps>({
changeSelectedCallNode,
focusCallTree,
selectLeafCallNode,
selectBestAncestorCallNodeAndExpandCallTree,
reportTrackThreadHeight,
},
component: withSize<Props>(TimelineTrackThread),
Expand Down
12 changes: 3 additions & 9 deletions src/test/components/ThreadActivityGraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,18 @@ describe('ThreadActivityGraph', function() {
* as once it's connected to the Redux store in the SelectedActivityGraph.
*/
describe('ThreadActivityGraph', function() {
it('can click a best ancestor call node', function() {
it('selects the full call node path when clicked', function() {
const { clickActivityGraph, getCallNodePath } = setup();

// The full call node at this sample is:
// A -> B -> C -> F -> G
// However, the best ancestor call node is:
// A -> B -> C -> F
// As this is the most common ancestor with the same category.
clickActivityGraph(1, 0.2);
expect(getCallNodePath()).toEqual(['A', 'B', 'C', 'F']);
expect(getCallNodePath()).toEqual(['A', 'B', 'C', 'F', 'G']);

// The full call node at this sample is:
// A -> B -> H -> I
// However, the best ancestor call node is:
// A -> B -> H
// As this is the most common ancestor with the same category.
clickActivityGraph(1, 0.8);
expect(getCallNodePath()).toEqual(['A', 'B', 'H']);
expect(getCallNodePath()).toEqual(['A', 'B', 'H', 'I']);
});

it('will redraw even when there are no samples in range', function() {
Expand Down