Skip to content

Commit af62aa6

Browse files
committed
Make the uncommitted selection range directly editable as text
1 parent b0614b5 commit af62aa6

File tree

10 files changed

+386
-33
lines changed

10 files changed

+386
-33
lines changed

src/components/app/ProfileFilterNavigator.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ import { showMenu } from '@firefox-devtools/react-contextmenu';
99
import classNames from 'classnames';
1010

1111
import explicitConnect from 'firefox-profiler/utils/connect';
12-
import { popCommittedRanges } from 'firefox-profiler/actions/profile-view';
12+
import {
13+
popCommittedRanges,
14+
updatePreviewSelection,
15+
commitRange,
16+
} from 'firefox-profiler/actions/profile-view';
1317
import {
1418
getPreviewSelection,
1519
getProfileFilterPageDataByTabID,
1620
getProfileRootRange,
1721
getProfileTimelineUnit,
22+
getCommittedRange,
1823
getCommittedRangeLabels,
24+
getZeroAt,
1925
} from 'firefox-profiler/selectors/profile';
2026
import { getTabFilter } from 'firefox-profiler/selectors/url-state';
2127
import { getFormattedTimelineValue } from 'firefox-profiler/profile-logic/committed-ranges';
@@ -40,6 +46,8 @@ type Props = {
4046

4147
type DispatchProps = {
4248
readonly onPop: Props['onPop'];
49+
readonly updatePreviewSelection?: Props['updatePreviewSelection'];
50+
readonly commitRange?: Props['commitRange'];
4351
};
4452

4553
type StateProps = Readonly<Omit<Props, keyof DispatchProps>>;
@@ -79,6 +87,12 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
7987
pageDataByTabID,
8088
tabFilter,
8189
profileTimelineUnit,
90+
committedRange,
91+
previewSelection,
92+
updatePreviewSelection,
93+
commitRange,
94+
uncommittedInputFieldRef,
95+
zeroAt,
8296
} = this.props;
8397

8498
let firstItem;
@@ -169,6 +183,12 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
169183
selectedItem={selectedItem}
170184
uncommittedItem={uncommittedItem}
171185
onPop={onPop}
186+
committedRange={committedRange}
187+
previewSelection={previewSelection}
188+
updatePreviewSelection={updatePreviewSelection}
189+
commitRange={commitRange}
190+
uncommittedInputFieldRef={uncommittedInputFieldRef}
191+
zeroAt={zeroAt}
172192
/>
173193
{pageDataByTabID && pageDataByTabID.size > 0 ? (
174194
<TabSelectorMenu />
@@ -178,12 +198,17 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
178198
}
179199
}
180200

201+
type OwnProps = {
202+
readonly uncommittedInputFieldRef?: React.RefObject<HTMLInputElement>;
203+
};
204+
181205
export const ProfileFilterNavigator = explicitConnect<
182-
{},
206+
OwnProps,
183207
StateProps,
184208
DispatchProps
185209
>({
186210
mapStateToProps: (state) => {
211+
const committedRange = getCommittedRange(state);
187212
const items = getCommittedRangeLabels(state);
188213
const previewSelection = getPreviewSelection(state);
189214
const profileTimelineUnit = getProfileTimelineUnit(state);
@@ -193,6 +218,7 @@ export const ProfileFilterNavigator = explicitConnect<
193218
profileTimelineUnit
194219
)
195220
: undefined;
221+
const zeroAt = getZeroAt(state);
196222

197223
const pageDataByTabID = getProfileFilterPageDataByTabID(state);
198224
const tabFilter = getTabFilter(state);
@@ -208,10 +234,15 @@ export const ProfileFilterNavigator = explicitConnect<
208234
tabFilter,
209235
rootRange,
210236
profileTimelineUnit,
237+
committedRange,
238+
previewSelection,
239+
zeroAt,
211240
};
212241
},
213242
mapDispatchToProps: {
214243
onPop: popCommittedRanges,
244+
updatePreviewSelection,
245+
commitRange,
215246
},
216247
component: ProfileFilterNavigatorBarImpl,
217248
});

src/components/app/ProfileViewer.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* license, v. 2.0. if a copy of the mpl was not distributed with this
33
* file, you can obtain one at http://mozilla.org/mpl/2.0/. */
44

5-
import { PureComponent } from 'react';
5+
import * as React from 'react';
66
import explicitConnect from 'firefox-profiler/utils/connect';
77

88
import { DetailsContainer } from './DetailsContainer';
@@ -59,7 +59,16 @@ type DispatchProps = {
5959

6060
type Props = ConnectedProps<{}, StateProps, DispatchProps>;
6161

62-
class ProfileViewerImpl extends PureComponent<Props> {
62+
class ProfileViewerImpl extends React.PureComponent<Props> {
63+
uncommittedInputFieldRef = React.createRef<HTMLInputElement>();
64+
65+
_onSelectionMove = () => {
66+
if (!this.uncommittedInputFieldRef.current) {
67+
return;
68+
}
69+
this.uncommittedInputFieldRef.current.blur();
70+
};
71+
6372
override render() {
6473
const {
6574
hasZipFile,
@@ -114,7 +123,9 @@ class ProfileViewerImpl extends PureComponent<Props> {
114123
/>
115124
) : null}
116125
<ProfileName />
117-
<ProfileFilterNavigator />
126+
<ProfileFilterNavigator
127+
uncommittedInputFieldRef={this.uncommittedInputFieldRef}
128+
/>
118129
{
119130
// Define a spacer in the middle that will shrink based on the availability
120131
// of space in the top bar. It will shrink away before any of the items
@@ -139,7 +150,7 @@ class ProfileViewerImpl extends PureComponent<Props> {
139150
secondaryInitialSize={270}
140151
onDragEnd={invalidatePanelLayout}
141152
>
142-
<Timeline />
153+
<Timeline onSelectionMove={this._onSelectionMove} />
143154
<SplitterLayout
144155
vertical
145156
percentage={true}

src/components/shared/FilterNavigatorBar.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@
6767
white-space: nowrap;
6868
}
6969

70+
.filterNavigatorBarItemUncommittedFieldInput {
71+
display: flex;
72+
overflow: hidden;
73+
width: 60px;
74+
height: 19px;
75+
box-sizing: border-box;
76+
border: 0.5px solid #aaa;
77+
margin-top: 2.5px;
78+
font-size: 11px;
79+
}
80+
7081
.filterNavigatorBarItemContent > .nodeIcon {
7182
margin-inline-end: 5px;
7283
}

0 commit comments

Comments
 (0)