-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Typescript search embeddable #26863
Typescript search embeddable #26863
Conversation
💔 Build Failed |
cd0b9df
to
8068d33
Compare
💔 Build Failed |
8068d33
to
e649458
Compare
💔 Build Failed |
e649458
to
adb0b9f
Compare
💔 Build Failed |
adb0b9f
to
1c55fa4
Compare
💔 Build Failed |
1c55fa4
to
873b010
Compare
💚 Build Succeeded |
873b010
to
762cb00
Compare
💔 Build Failed |
762cb00
to
54ac214
Compare
💚 Build Succeeded |
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.
Mainly two typing issues, and one suggestion (to take or ignore).
src/ui/public/timefilter/get_time.ts
Outdated
*/ | ||
|
||
import dateMath from '@elastic/datemath'; | ||
import _ from 'lodash'; |
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.
Since we're anyway touching this, let's make this a named import instead.
onEmbeddableStateChanged: OnEmbeddableStateChanged; | ||
savedSearch: SavedSearch; | ||
editUrl: string; | ||
loader: SavedSearchLoader; |
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.
This should be removed, since we don't pass the loader in. It currently only works, because search_embeddable_factory
is still in JS.
@@ -96,6 +160,9 @@ export class SearchEmbeddable extends Embeddable { | |||
|
|||
const timeRangeSearchSource = this.searchScope.searchSource.create(); | |||
timeRangeSearchSource.setField('filter', () => { | |||
if (!this.searchScope || !this.timeRange) { |
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.
Maybe a better way to not need all those checks, would be just first creating that scope on a local variable, in this function and then assign at the end to the class:
const searchScope: SearchScope = this.$rootScope.$new();
searchScope.description = this.savedSearch.description;
// ...
searchScope.setSortOrder = (columnName, direction) => {
// no check now required
searchScope.sort = this.customization.sort = [ columnName, direction ];
}
// ...
this.searchScope = searchScope;
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.
But since we're checking in a lot of places still for existence of columns
not sure if it really adds too much to the readability. So feel free to treat this as you wish.
f1b5707
to
6b5fe1d
Compare
💚 Build Succeeded |
done @timroes, thanks! |
@@ -36,7 +36,7 @@ declare const datemath: { | |||
input: string, | |||
options?: { | |||
roundUp?: boolean; | |||
forceNow?: boolean; | |||
forceNow?: Date; |
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.
not familiar with this code, but could we rename parameter or add some jsdocs decribing what this forceNow does ?
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.
code LGTM, tried adding search panel on dashboard and it works ok (chrome linux)
💚 Build Succeeded |
* typescript search embeddable * Add a comment
Pinging @elastic/kibana-app |
No description provided.