-
Notifications
You must be signed in to change notification settings - Fork 487
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
Virtualized traced results list #337
Closed
Closed
Changes from all commits
Commits
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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -18,6 +18,7 @@ import * as React from 'react'; | |
import { Select } from 'antd'; | ||
import { Link } from 'react-router-dom'; | ||
import { Field, reduxForm, formValueSelector } from 'redux-form'; | ||
import memoizeOne from 'memoize-one'; | ||
|
||
import DiffSelection from './DiffSelection'; | ||
import * as markers from './index.markers'; | ||
|
@@ -36,6 +37,7 @@ import type { FetchedTrace } from '../../../types'; | |
import type { SearchQuery } from '../../../types/search'; | ||
|
||
import './index.css'; | ||
import ListView from '../../common/ListView'; | ||
|
||
type SearchResultsProps = { | ||
cohortAddTrace: string => void, | ||
|
@@ -83,9 +85,11 @@ export const sortFormSelector = formValueSelector('traceResultsSort'); | |
|
||
export default class SearchResults extends React.PureComponent<SearchResultsProps> { | ||
props: SearchResultsProps; | ||
|
||
static defaultProps = { skipMessage: false }; | ||
|
||
searchUrl = memoizeOne(queryOfResults => getUrl(stripEmbeddedState(queryOfResults))); | ||
cohortIds = memoizeOne(diffCohort => new Set(diffCohort.map(datum => datum.id))); | ||
|
||
toggleComparison = (traceID: string, remove: boolean) => { | ||
const { cohortAddTrace, cohortRemoveTrace } = this.props; | ||
if (remove) { | ||
|
@@ -95,14 +99,43 @@ export default class SearchResults extends React.PureComponent<SearchResultsProp | |
} | ||
}; | ||
|
||
getKeyFromIndex = (index: number) => this.props.traces[index].traceID; | ||
|
||
getIndexFromKey = (key: string) => { | ||
const size = this.props.traces.length; | ||
for (let i = 0; i < size; ++i) { | ||
if (this.props.traces[i].traceID === key) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
|
||
renderRow = (key: string, style: Style, index: number, attrs: {}) => { | ||
const trace = this.props.traces[index]; | ||
const { disableComparisons, maxTraceDuration, queryOfResults, diffCohort } = this.props; | ||
|
||
return ( | ||
<div className="u-width-100" key={key} style={style} {...attrs}> | ||
<ResultItem | ||
durationPercent={getPercentageOfDuration(trace.duration, maxTraceDuration)} | ||
isInDiffCohort={this.cohortIds(diffCohort).has(trace.traceID)} | ||
linkTo={getLocation(trace.traceID, { fromSearch: this.searchUrl(queryOfResults) })} | ||
toggleComparison={this.toggleComparison} | ||
trace={trace} | ||
disableComparision={disableComparisons} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
render() { | ||
const { | ||
diffCohort, | ||
disableComparisons, | ||
goToTrace, | ||
hideGraph, | ||
loading, | ||
maxTraceDuration, | ||
queryOfResults, | ||
showStandaloneLink, | ||
skipMessage, | ||
|
@@ -131,7 +164,7 @@ export default class SearchResults extends React.PureComponent<SearchResultsProp | |
</React.Fragment> | ||
); | ||
} | ||
const cohortIds = new Set(diffCohort.map(datum => datum.id)); | ||
|
||
const searchUrl = getUrl(stripEmbeddedState(queryOfResults)); | ||
return ( | ||
<div> | ||
|
@@ -173,20 +206,18 @@ export default class SearchResults extends React.PureComponent<SearchResultsProp | |
</div> | ||
<div> | ||
{diffSelection} | ||
<ul className="ub-list-reset"> | ||
{traces.map(trace => ( | ||
<li className="ub-my3" key={trace.traceID}> | ||
<ResultItem | ||
durationPercent={getPercentageOfDuration(trace.duration, maxTraceDuration)} | ||
isInDiffCohort={cohortIds.has(trace.traceID)} | ||
linkTo={getLocation(trace.traceID, { fromSearch: searchUrl })} | ||
toggleComparison={this.toggleComparison} | ||
trace={trace} | ||
disableComparision={disableComparisons} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
<ListView | ||
dataLength={this.props.traces.length} | ||
itemHeightGetter={() => 155} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs to have the |
||
itemRenderer={this.renderRow} | ||
viewBuffer={5} | ||
viewBufferMin={5} | ||
initialDraw={15} | ||
itemsWrapperClassName="u-width-100" | ||
getKeyFromIndex={this.getKeyFromIndex} | ||
getIndexFromKey={this.getIndexFromKey} | ||
windowScroller | ||
/> | ||
</div> | ||
</div> | ||
); | ||
|
This file contains 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 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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.
For this, the
<Tag...>
seems pretty heavy. What about using something home-grown?