Skip to content
Open
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
35 changes: 33 additions & 2 deletions src/components/app/ProfileFilterNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import { showMenu } from '@firefox-devtools/react-contextmenu';
import classNames from 'classnames';

import explicitConnect from 'firefox-profiler/utils/connect';
import { popCommittedRanges } from 'firefox-profiler/actions/profile-view';
import {
popCommittedRanges,
updatePreviewSelection,
commitRange,
} from 'firefox-profiler/actions/profile-view';
import {
getPreviewSelection,
getProfileFilterPageDataByTabID,
getProfileRootRange,
getProfileTimelineUnit,
getCommittedRange,
getCommittedRangeLabels,
getZeroAt,
} from 'firefox-profiler/selectors/profile';
import { getTabFilter } from 'firefox-profiler/selectors/url-state';
import { getFormattedTimelineValue } from 'firefox-profiler/profile-logic/committed-ranges';
Expand All @@ -40,6 +46,8 @@ type Props = {

type DispatchProps = {
readonly onPop: Props['onPop'];
readonly updatePreviewSelection?: Props['updatePreviewSelection'];
readonly commitRange?: Props['commitRange'];
};

type StateProps = Readonly<Omit<Props, keyof DispatchProps>>;
Expand Down Expand Up @@ -79,6 +87,12 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
pageDataByTabID,
tabFilter,
profileTimelineUnit,
committedRange,
previewSelection,
updatePreviewSelection,
commitRange,
uncommittedInputFieldRef,
zeroAt,
} = this.props;

let firstItem;
Expand Down Expand Up @@ -169,6 +183,12 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
selectedItem={selectedItem}
uncommittedItem={uncommittedItem}
onPop={onPop}
committedRange={committedRange}
previewSelection={previewSelection}
updatePreviewSelection={updatePreviewSelection}
commitRange={commitRange}
uncommittedInputFieldRef={uncommittedInputFieldRef}
zeroAt={zeroAt}
/>
{pageDataByTabID && pageDataByTabID.size > 0 ? (
<TabSelectorMenu />
Expand All @@ -178,12 +198,17 @@ class ProfileFilterNavigatorBarImpl extends React.PureComponent<Props> {
}
}

type OwnProps = {
readonly uncommittedInputFieldRef?: React.RefObject<HTMLInputElement>;
};

export const ProfileFilterNavigator = explicitConnect<
{},
OwnProps,
StateProps,
DispatchProps
>({
mapStateToProps: (state) => {
const committedRange = getCommittedRange(state);
const items = getCommittedRangeLabels(state);
const previewSelection = getPreviewSelection(state);
const profileTimelineUnit = getProfileTimelineUnit(state);
Expand All @@ -193,6 +218,7 @@ export const ProfileFilterNavigator = explicitConnect<
profileTimelineUnit
)
: undefined;
const zeroAt = getZeroAt(state);

const pageDataByTabID = getProfileFilterPageDataByTabID(state);
const tabFilter = getTabFilter(state);
Expand All @@ -208,10 +234,15 @@ export const ProfileFilterNavigator = explicitConnect<
tabFilter,
rootRange,
profileTimelineUnit,
committedRange,
previewSelection,
zeroAt,
};
},
mapDispatchToProps: {
onPop: popCommittedRanges,
updatePreviewSelection,
commitRange,
},
component: ProfileFilterNavigatorBarImpl,
});
19 changes: 15 additions & 4 deletions src/components/app/ProfileViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* license, v. 2.0. if a copy of the mpl was not distributed with this
* file, you can obtain one at http://mozilla.org/mpl/2.0/. */

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

import { DetailsContainer } from './DetailsContainer';
Expand Down Expand Up @@ -59,7 +59,16 @@ type DispatchProps = {

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

class ProfileViewerImpl extends PureComponent<Props> {
class ProfileViewerImpl extends React.PureComponent<Props> {
uncommittedInputFieldRef = React.createRef<HTMLInputElement>();

_onSelectionMove = () => {
if (!this.uncommittedInputFieldRef.current) {
return;
}
this.uncommittedInputFieldRef.current.blur();
};

override render() {
const {
hasZipFile,
Expand Down Expand Up @@ -114,7 +123,9 @@ class ProfileViewerImpl extends PureComponent<Props> {
/>
) : null}
<ProfileName />
<ProfileFilterNavigator />
<ProfileFilterNavigator
uncommittedInputFieldRef={this.uncommittedInputFieldRef}
/>
{
// Define a spacer in the middle that will shrink based on the availability
// of space in the top bar. It will shrink away before any of the items
Expand All @@ -139,7 +150,7 @@ class ProfileViewerImpl extends PureComponent<Props> {
secondaryInitialSize={270}
onDragEnd={invalidatePanelLayout}
>
<Timeline />
<Timeline onSelectionMove={this._onSelectionMove} />
<SplitterLayout
vertical
percentage={true}
Expand Down
11 changes: 11 additions & 0 deletions src/components/shared/FilterNavigatorBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
white-space: nowrap;
}

.filterNavigatorBarItemUncommittedFieldInput {
display: flex;
overflow: hidden;
width: 60px;
height: 19px;
box-sizing: border-box;
border: 0.5px solid #aaa;
margin-top: 2.5px;
font-size: 11px;
}

.filterNavigatorBarItemContent > .nodeIcon {
margin-inline-end: 5px;
}
Expand Down
Loading