Skip to content

Commit 365e6d6

Browse files
committed
Make the uncommitted selection range directly editable as text
1 parent c70f208 commit 365e6d6

10 files changed

Lines changed: 585 additions & 29 deletions

File tree

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>>;
@@ -83,6 +91,12 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
8391
pageDataByTabID,
8492
tabFilter,
8593
profileTimelineUnit,
94+
committedRange,
95+
previewSelection,
96+
updatePreviewSelection,
97+
commitRange,
98+
uncommittedInputFieldRef,
99+
zeroAt,
86100
} = this.props;
87101

88102
let firstItem;
@@ -180,6 +194,12 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
180194
onFirstItemClick={
181195
isFirstItemClickable ? this._onFirstItemClick : undefined
182196
}
197+
committedRange={committedRange}
198+
previewSelection={previewSelection}
199+
updatePreviewSelection={updatePreviewSelection}
200+
commitRange={commitRange}
201+
uncommittedInputFieldRef={uncommittedInputFieldRef}
202+
zeroAt={zeroAt}
183203
/>
184204
{pageDataByTabID && pageDataByTabID.size > 0 ? (
185205
<TabSelectorMenu />
@@ -189,12 +209,17 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
189209
}
190210
}
191211

212+
type OwnProps = {
213+
readonly uncommittedInputFieldRef?: React.RefObject<HTMLInputElement>;
214+
};
215+
192216
export const ProfileFilterNavigator = explicitConnect<
193-
{},
217+
OwnProps,
194218
StateProps,
195219
DispatchProps
196220
>({
197221
mapStateToProps: (state) => {
222+
const committedRange = getCommittedRange(state);
198223
const items = getCommittedRangeLabels(state);
199224
const previewSelection = getPreviewSelection(state);
200225
const profileTimelineUnit = getProfileTimelineUnit(state);
@@ -204,6 +229,7 @@ export const ProfileFilterNavigator = explicitConnect<
204229
profileTimelineUnit
205230
)
206231
: undefined;
232+
const zeroAt = getZeroAt(state);
207233

208234
const pageDataByTabID = getProfileFilterPageDataByTabID(state);
209235
const tabFilter = getTabFilter(state);
@@ -219,10 +245,15 @@ export const ProfileFilterNavigator = explicitConnect<
219245
tabFilter,
220246
rootRange,
221247
profileTimelineUnit,
248+
committedRange,
249+
previewSelection,
250+
zeroAt,
222251
};
223252
},
224253
mapDispatchToProps: {
225254
onPop: popCommittedRanges,
255+
updatePreviewSelection,
256+
commitRange,
226257
},
227258
component: ProfileFilterNavigatorBarImpl,
228259
});

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)