Skip to content

Commit 1074767

Browse files
authored
Do not switch to call tree when clicking the activity graph while on sample based panels (#5672)
1 parent 61a5894 commit 1074767

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/reducers/app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
import { combineReducers } from 'redux';
6-
import { tabSlugs } from '../app-logic/tabs-handling';
6+
import { tabSlugs, tabsShowingSampleData } from '../app-logic/tabs-handling';
77

88
import type { TabSlug } from '../app-logic/tabs-handling';
99
import type { BrowserConnectionStatus } from '../app-logic/browser-connection';
@@ -170,6 +170,10 @@ const lastVisibleThreadTabSlug: Reducer<TabSlug> = (
170170
}
171171
return state;
172172
case 'FOCUS_CALL_TREE':
173+
if (tabsShowingSampleData.includes(state)) {
174+
// Don't switch to call tree if the tab is already showing sample data.
175+
return state;
176+
}
173177
return 'calltree';
174178
default:
175179
return state;

src/reducers/url-state.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { combineReducers } from 'redux';
66
import { oneLine } from 'common-tags';
77
import { objectEntries } from '../utils/types';
8-
import { tabSlugs } from '../app-logic/tabs-handling';
8+
import { tabSlugs, tabsShowingSampleData } from '../app-logic/tabs-handling';
99

1010
import type {
1111
ThreadIndex,
@@ -98,6 +98,10 @@ const selectedTab: Reducer<TabSlug> = (state = 'calltree', action) => {
9898
case 'CHANGE_TAB_FILTER':
9999
return action.selectedTab;
100100
case 'FOCUS_CALL_TREE':
101+
if (tabsShowingSampleData.includes(state)) {
102+
// Don't switch to call tree if the tab is already showing sample data.
103+
return state;
104+
}
101105
return 'calltree';
102106
default:
103107
return state;

src/test/components/ThreadActivityGraph.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe('ThreadActivityGraph', function () {
264264
expect(getCallNodePath()).toEqual([]);
265265
});
266266

267-
it('when clicking a stack, this selects the call tree panel', function () {
267+
it('when clicking a stack while on a tab that does not show sample data, this selects the call tree panel', function () {
268268
const { dispatch, getState, clickActivityGraph } = setup();
269269

270270
expect(getSelectedTab(getState())).toBe('calltree');
@@ -277,6 +277,19 @@ describe('ThreadActivityGraph', function () {
277277
expect(getLastVisibleThreadTabSlug(getState())).toBe('calltree');
278278
});
279279

280+
it('when clicking a stack while on a tab that shows sample data, it should not change the selected panel', function () {
281+
const { dispatch, getState, clickActivityGraph } = setup();
282+
283+
expect(getSelectedTab(getState())).toBe('calltree');
284+
dispatch(changeSelectedTab('flame-graph'));
285+
286+
// The full call node at this sample is:
287+
// A -> B -> C -> F -> G
288+
clickActivityGraph(1, 0.2);
289+
expect(getSelectedTab(getState())).toBe('flame-graph');
290+
expect(getLastVisibleThreadTabSlug(getState())).toBe('flame-graph');
291+
});
292+
280293
it(`when clicking outside of the graph, this doesn't select the call tree panel`, function () {
281294
const { dispatch, getState, clickActivityGraph } = setup();
282295

0 commit comments

Comments
 (0)