-
Notifications
You must be signed in to change notification settings - Fork 482
Implement marker filter menu and "drop samples outside of marker filter" transform #4631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
71bdfef
Split the thread per-thread selectors to be able to get markers for …
canova 9fb0eae
Add a new filter-samples transform that can filter samples by marker …
canova 2837d2c
Add a new marker filters menu and add a menu item for dropping samples
canova 9e9174e
Filter js and native allocation stacks as well
canova 9de0424
Keep the marker filters menu visibility in a state
canova bcff9ba
Add tests for "filter-samples" transform
canova 61fc524
Add an arrow icon besides the filter icon
canova b0b73fa
Reword the transform to make it more explicit
canova 107ed46
Remove the unnecessary state prop
canova 68fdc14
Keep the context menu visibility inside the component state instead o…
canova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * 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/. */ | ||
|
|
||
| // @flow | ||
| import React, { PureComponent } from 'react'; | ||
| import { MenuItem } from '@firefox-devtools/react-contextmenu'; | ||
| import { Localized } from '@fluent/react'; | ||
|
|
||
| import { ContextMenu } from './ContextMenu'; | ||
| import explicitConnect from 'firefox-profiler/utils/connect'; | ||
| import { | ||
| getMarkersSearchString, | ||
| getSelectedThreadsKey, | ||
| } from 'firefox-profiler/selectors/url-state'; | ||
| import { addTransformToStack } from 'firefox-profiler/actions/profile-view'; | ||
|
|
||
| import type { ThreadsKey } from 'firefox-profiler/types'; | ||
| import type { ConnectedProps } from 'firefox-profiler/utils/connect'; | ||
|
|
||
| type OwnProps = {| | ||
| +onShow: () => void, | ||
| +onHide: () => void, | ||
| |}; | ||
|
|
||
| type StateProps = {| | ||
| +searchString: string, | ||
| +threadsKey: ThreadsKey, | ||
| |}; | ||
|
|
||
| type DispatchProps = {| | ||
| +addTransformToStack: typeof addTransformToStack, | ||
| |}; | ||
|
|
||
| type Props = ConnectedProps<OwnProps, StateProps, DispatchProps>; | ||
|
|
||
| class MarkerFiltersContextMenuImpl extends PureComponent<Props> { | ||
| filterSamplesByMarker = () => { | ||
| const { searchString, threadsKey, addTransformToStack } = this.props; | ||
| addTransformToStack(threadsKey, { | ||
| type: 'filter-samples', | ||
| filterType: 'marker-search', | ||
| filter: searchString, | ||
| }); | ||
| }; | ||
|
|
||
| render() { | ||
| const { searchString, onShow, onHide } = this.props; | ||
| return ( | ||
| <ContextMenu | ||
| id="MarkerFiltersContextMenu" | ||
| className="markerFiltersContextMenu" | ||
| onShow={onShow} | ||
| onHide={onHide} | ||
| > | ||
| <MenuItem onClick={this.filterSamplesByMarker}> | ||
| <Localized | ||
| id="MarkerFiltersContextMenu--drop-samples-outside-of-markers-matching" | ||
| vars={{ filter: searchString }} | ||
| elems={{ strong: <strong /> }} | ||
| > | ||
| {/* Using a fragment here so we can have a strong tag inside. */} | ||
| <> | ||
| Drop samples outside of markers matching “ | ||
| <strong>${searchString}</strong>” | ||
| </> | ||
| </Localized> | ||
| </MenuItem> | ||
| </ContextMenu> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export const MarkerFiltersContextMenu = explicitConnect< | ||
| OwnProps, | ||
| StateProps, | ||
| DispatchProps | ||
| >({ | ||
| mapStateToProps: (state) => ({ | ||
| searchString: getMarkersSearchString(state), | ||
| threadsKey: getSelectedThreadsKey(state), | ||
| }), | ||
| mapDispatchToProps: { | ||
| addTransformToStack, | ||
| }, | ||
| component: MarkerFiltersContextMenuImpl, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaaah so that's what we should do for the track menu as well 😁
I wonder if we could be able to extract this for an easier reuse...
(not for now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking about the track menu as well while doing this :) We can possibly extract it.