Skip to content

Commit b61f7a8

Browse files
authored
Add the stack implementation radio buttons to the marker chart and marker table panels, and other small changes (Merge PR firefox-devtools#4572)
2 parents d8afad1 + adc4090 commit b61f7a8

18 files changed

Lines changed: 1293 additions & 967 deletions

locales/en-US/app.ftl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,15 @@ ServiceWorkerManager--hide-notice-button =
706706
## This is the settings component that is used in Call Tree, Flame Graph and Stack
707707
## Chart panels. It's used to switch between different views of the stack.
708708

709-
StackSettings--implementation-all-stacks = All stacks
710-
StackSettings--implementation-javascript = JavaScript
711-
StackSettings--implementation-native = Native
709+
StackSettings--implementation-all-frames = All frames
710+
.title = Do not filter the stack frames
711+
StackSettings--implementation-javascript2 = JavaScript
712+
.title = Show only the stack frames related to JavaScript execution
713+
StackSettings--implementation-native2 = Native
714+
.title = Show only the stack frames for native code
715+
716+
# This label is displayed in the marker chart and marker table panels only.
717+
StackSettings--stack-implementation-label = Filter stacks:
712718
713719
StackSettings--use-data-source-label = Data source:
714720
StackSettings--call-tree-strategy-timing = Timings

res/css/photon/label.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
.photon-label-micro {
1919
font-size: 11px;
2020
}
21+
22+
.photon-label-horiz-padding {
23+
padding: 0 3px;
24+
}

src/components/shared/MarkerSettings.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@
99
padding: 0;
1010
line-height: 25px;
1111
}
12-
13-
.markerSettingsSpacer {
14-
flex: 1;
15-
}

src/components/shared/MarkerSettings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import explicitConnect from 'firefox-profiler/utils/connect';
1111
import { changeMarkersSearchString } from 'firefox-profiler/actions/profile-view';
1212
import { getMarkersSearchString } from 'firefox-profiler/selectors/url-state';
1313
import { PanelSearch } from './PanelSearch';
14+
import { StackImplementationSetting } from 'firefox-profiler/components/shared/StackImplementationSetting';
1415

1516
import type { ConnectedProps } from 'firefox-profiler/utils/connect';
1617

18+
import 'firefox-profiler/components/shared/PanelSettingsList.css';
1719
import './MarkerSettings.css';
1820

1921
type StateProps = {|
@@ -35,7 +37,9 @@ class MarkerSettingsImpl extends PureComponent<Props> {
3537
const { searchString } = this.props;
3638
return (
3739
<div className="markerSettings">
38-
<div className="markerSettingsSpacer" />
40+
<ul className="panelSettingsList">
41+
<StackImplementationSetting labelL10nId="StackSettings--stack-implementation-label" />
42+
</ul>
3943
<Localized
4044
id="MarkerSettings--panel-search"
4145
attrs={{ label: true, title: true }}

src/components/shared/PanelSearch.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
/* so that the introduction is on top of other panels, _but_ still keep it
33
* below the input field (see below) */
44
z-index: 1;
5-
padding: 0 5px;
5+
padding: 0 4px;
66
}
77

88
.panelSearchFieldLabel {
99
/* We fix the height so that the panelSearchFieldIntroduction doesn't increase it */
10-
display: block;
10+
display: inline-flex;
1111
height: 100%;
12+
align-items: center;
13+
gap: 4px;
1214
}
1315

1416
.panelSearchFieldInput {
@@ -17,7 +19,7 @@
1719

1820
.panelSearchFieldIntroduction {
1921
z-index: -1; /* it needs to be below the input field */
20-
padding: 0 5px;
22+
padding: 0 4px;
2123
background-color: white;
2224
box-shadow: 0 1px 4px rgb(12 12 13 / 0.1); /* This is grey-90 with 10% opacity, according to the photon design document */
2325
color: var(--grey-50);

src/components/shared/PanelSearch.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ export class PanelSearch extends React.PureComponent<Props, State> {
5454
onBlur={this._onSearchFieldBlur}
5555
onFocus={this._onSearchFieldFocus}
5656
/>
57-
<div
58-
className={classNames('panelSearchFieldIntroduction', {
59-
isHidden: !showIntroduction,
60-
isDisplayed: showIntroduction,
61-
})}
62-
>
63-
<Localized id="PanelSearch--search-field-hint">
64-
Did you know you can use the comma (,) to search using several
65-
terms?
66-
</Localized>
67-
</div>
6857
</label>
58+
<div
59+
className={classNames('panelSearchFieldIntroduction', {
60+
isHidden: !showIntroduction,
61+
isDisplayed: showIntroduction,
62+
})}
63+
>
64+
<Localized id="PanelSearch--search-field-hint">
65+
Did you know you can use the comma (,) to search using several
66+
terms?
67+
</Localized>
68+
</div>
6969
</div>
7070
);
7171
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
.panelSettingsList {
6+
display: flex;
7+
flex: 1;
8+
align-items: flex-start;
9+
padding: 0;
10+
margin: 0;
11+
list-style: none;
12+
}
13+
14+
.panelSettingsListItem {
15+
display: inline-flex;
16+
align-items: center;
17+
padding: 0;
18+
margin: 0 5px;
19+
}
20+
21+
.panelSettingsListItem:not(:first-child) {
22+
padding-left: 10px;
23+
border-left: 1px solid var(--grey-20);
24+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
// @flow
6+
7+
import React, { PureComponent } from 'react';
8+
import { Localized } from '@fluent/react';
9+
10+
import { changeImplementationFilter } from 'firefox-profiler/actions/profile-view';
11+
import { getImplementationFilter } from 'firefox-profiler/selectors/url-state';
12+
13+
import { toValidImplementationFilter } from 'firefox-profiler/profile-logic/profile-data';
14+
import explicitConnect, {
15+
type ConnectedProps,
16+
} from 'firefox-profiler/utils/connect';
17+
18+
import { getProfileUsesMultipleStackTypes } from 'firefox-profiler/selectors/profile';
19+
20+
import './PanelSettingsList.css';
21+
22+
import type { ImplementationFilter } from 'firefox-profiler/types';
23+
24+
type OwnProps = {|
25+
labelL10nId?: string,
26+
|};
27+
28+
type StateProps = {|
29+
+implementationFilter: ImplementationFilter,
30+
+allowSwitchingStackType: boolean,
31+
|};
32+
33+
type DispatchProps = {|
34+
+changeImplementationFilter: typeof changeImplementationFilter,
35+
|};
36+
37+
type Props = ConnectedProps<OwnProps, StateProps, DispatchProps>;
38+
39+
class StackImplementationSettingImpl extends PureComponent<Props> {
40+
_onImplementationFilterChange = (e: SyntheticEvent<HTMLInputElement>) => {
41+
this.props.changeImplementationFilter(
42+
// This function is here to satisfy Flow that we are getting a valid
43+
// implementation filter.
44+
toValidImplementationFilter(e.currentTarget.value)
45+
);
46+
};
47+
48+
_renderImplementationRadioButton(
49+
labelL10nId: string,
50+
implementationFilter: ImplementationFilter
51+
) {
52+
const htmlId = `implementation-radio-${implementationFilter}`;
53+
return (
54+
<>
55+
<Localized id={labelL10nId} attrs={{ title: true }}>
56+
<input
57+
type="radio"
58+
className="photon-radio photon-radio-micro"
59+
value={implementationFilter}
60+
id={htmlId}
61+
onChange={this._onImplementationFilterChange}
62+
checked={this.props.implementationFilter === implementationFilter}
63+
/>
64+
</Localized>
65+
<Localized id={labelL10nId} attrs={{ title: true }}>
66+
<label
67+
className="photon-label photon-label-micro photon-label-horiz-padding"
68+
htmlFor={htmlId}
69+
></label>
70+
</Localized>
71+
</>
72+
);
73+
}
74+
75+
render() {
76+
const { allowSwitchingStackType, labelL10nId } = this.props;
77+
78+
return allowSwitchingStackType ? (
79+
<li className="panelSettingsListItem">
80+
{labelL10nId ? <Localized id={labelL10nId} /> : null}
81+
{this._renderImplementationRadioButton(
82+
'StackSettings--implementation-all-frames',
83+
'combined'
84+
)}
85+
{this._renderImplementationRadioButton(
86+
'StackSettings--implementation-javascript2',
87+
'js'
88+
)}
89+
{this._renderImplementationRadioButton(
90+
'StackSettings--implementation-native2',
91+
'cpp'
92+
)}
93+
</li>
94+
) : null;
95+
}
96+
}
97+
98+
export const StackImplementationSetting = explicitConnect<
99+
OwnProps,
100+
StateProps,
101+
DispatchProps
102+
>({
103+
mapStateToProps: (state) => ({
104+
implementationFilter: getImplementationFilter(state),
105+
allowSwitchingStackType: getProfileUsesMultipleStackTypes(state),
106+
}),
107+
mapDispatchToProps: {
108+
changeImplementationFilter,
109+
},
110+
component: StackImplementationSettingImpl,
111+
});

src/components/shared/StackSettings.css

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,6 @@
1111
white-space: nowrap;
1212
}
1313

14-
.stackSettingsList {
15-
display: block;
16-
display: flex;
17-
flex: 1;
18-
align-items: flex-start;
19-
padding: 0;
20-
margin: 0;
21-
list-style: none;
22-
}
23-
24-
.stackSettingsListItem {
25-
padding: 0;
26-
margin: 0 5px;
27-
}
28-
29-
.stackSettingsLabel {
30-
height: 25px;
31-
padding: 0;
32-
}
33-
34-
.stackSettingsFilter {
35-
padding-right: 10px;
36-
border-right: 1px solid var(--grey-20);
37-
}
38-
39-
.stackSettingsFilterLabel {
40-
align-items: center;
41-
padding: 0 5px 0 0;
42-
}
43-
4414
.stackSettingsSelect {
4515
/* Create a new stacking context for the select using a position:relative. This way
4616
* the focus ring around the select breaks out of its surrounding container. */

0 commit comments

Comments
 (0)