Skip to content
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

Validate when there is no query but a JSON file is loaded #383

Merged
merged 1 commit into from
May 22, 2019

Conversation

rubenvp8510
Copy link
Collaborator

Which problem is this PR solving?

  • I had an issue when I tried to load a JSON file, the UI throws an error about undefined variable. The only way I was managed to work with it, is doing a search first and then I can load my JSON file.

Short description of the changes

  • Just validate if the URL does not have a searchQuery.

@rubenvp8510 rubenvp8510 force-pushed the json-load-issue branch 3 times, most recently from b32a20a to 98c000b Compare May 21, 2019 05:23
@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #383 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #383      +/-   ##
==========================================
+ Coverage   88.72%   88.75%   +0.02%     
==========================================
  Files         159      159              
  Lines        3556     3556              
  Branches      811      813       +2     
==========================================
+ Hits         3155     3156       +1     
+ Misses        365      364       -1     
  Partials       36       36
Impacted Files Coverage Δ
.../components/SearchTracePage/SearchResults/index.js 75% <100%> (ø) ⬆️
.../jaeger-ui/src/components/SearchTracePage/index.js 88.13% <100%> (ø) ⬆️
...eViewer/TimelineHeaderRow/TimelineViewingLayer.tsx 89.83% <0%> (+1.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 126f42c...69d91a8. Read the comment docs.

Copy link
Collaborator

@everett980 everett980 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR!

It seems like queryOfResults should be undefined when uploading a JSON without searching, not null.

@@ -71,7 +71,7 @@ export class SearchTracePageImpl extends Component {

goToTrace = traceID => {
const { queryOfResults } = this.props;
const searchUrl = getUrl(stripEmbeddedState(queryOfResults));
const searchUrl = queryOfResults !== null ? getUrl(stripEmbeddedState(queryOfResults)) : getUrl();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems as though queryOfResults should be of type SearchQuery or undefined, never null.
in mapStateToProps props.queryOfResults comes from reduxState.trace.search.query which is an optional property of type SearchQuery. null is not assignable to optional properties.
I think this could simply be: const searchUrl = queryOfResults ? getUrl(stripEmbeddedState(queryOfResults)) : getUrl();
Same for SearchResults/index.js

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 I'll do the change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -132,7 +132,7 @@ export default class SearchResults extends React.PureComponent<SearchResultsProp
);
}
const cohortIds = new Set(diffCohort.map(datum => datum.id));
const searchUrl = getUrl(stripEmbeddedState(queryOfResults));
const searchUrl = queryOfResults !== null ? getUrl(stripEmbeddedState(queryOfResults)) : getUrl();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/components/SearchTracePage/ isn't fully covered by TypeScript yet, but it would be nice for the type SearchResultsProps to have queryOfResults as optional. That way it'll be easier to transition to TS in the future, and serve as accurate documentation in the interim.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, idea! I did the changes.

@everett980 everett980 merged commit bf2baa2 into jaegertracing:master May 22, 2019
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 5, 2021
Handle no search query when a JSON file is loaded
Signed-off-by: vvvprabhakar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants