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
Avoid not needed search creation on default and stream search page #11372
Conversation
fcba5c7
to
51cded7
Compare
51cded7
to
9fa9514
Compare
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.
Looks good so far! Added just one minor remark.
timezone: range.timezone, | ||
} as KeywordTimeRange : undefined; | ||
default: | ||
// @ts-ignore |
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.
To avoid using @ts-ignore
here, we can do two things:
- Using the complete
range
to generate theError
in the next line (TS is complaining becauserange.rangetype
is supposed to benever
at this point), which could also help for debugging. - Using
@ts-expect-error
instead. This is doing the same as@ts-ignore
(suppressing an error), but in addition it is raising an error if no error is suppressed. This way, we are also being notified when a new possible value forrangetype
is introduced but it is not handled in acase
-clause.
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.
Thanks for the tip, I really like the typing related advantages of @ts-expect-error
.
9fa9514
to
fa759d1
Compare
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.
LGTM and fixes the issue!
Description
Motivation and Context
Before this change we we created two searches, when opening the default or stream search page via a URL with search query params like:
?q=http_method:GET&rangetype=relative&relative=300
. This was not the case when opening a saved search. This problem occurred because we were creating a search with the default search query first and another one with the search settings provided by the URL query params.Please note, this bug still exists when the URL query params contain a stream filter. Fixing this bug will require more complex changes, which we should implement in a follow-up PR.