|
19 | 19 | import './search_embeddable.scss'; |
20 | 20 | import angular from 'angular'; |
21 | 21 | import _ from 'lodash'; |
22 | | -import * as Rx from 'rxjs'; |
23 | 22 | import { Subscription } from 'rxjs'; |
24 | 23 | import { i18n } from '@kbn/i18n'; |
25 | 24 | import { UiActionsStart, APPLY_FILTER_TRIGGER } from '../../../../ui_actions/public'; |
@@ -98,6 +97,7 @@ export class SearchEmbeddable |
98 | 97 | private prevTimeRange?: TimeRange; |
99 | 98 | private prevFilters?: Filter[]; |
100 | 99 | private prevQuery?: Query; |
| 100 | + private prevSearchSessionId?: string; |
101 | 101 |
|
102 | 102 | constructor( |
103 | 103 | { |
@@ -140,7 +140,7 @@ export class SearchEmbeddable |
140 | 140 | .timefilter.getAutoRefreshFetch$() |
141 | 141 | .subscribe(this.fetch); |
142 | 142 |
|
143 | | - this.subscription = Rx.merge(this.getOutput$(), this.getInput$()).subscribe(() => { |
| 143 | + this.subscription = this.getUpdated$().subscribe(() => { |
144 | 144 | this.panelTitle = this.output.title || ''; |
145 | 145 |
|
146 | 146 | if (this.searchScope) { |
@@ -262,7 +262,8 @@ export class SearchEmbeddable |
262 | 262 | } |
263 | 263 |
|
264 | 264 | public reload() { |
265 | | - this.fetch(); |
| 265 | + if (this.searchScope) |
| 266 | + this.pushContainerStateParamsToScope(this.searchScope, { forceFetch: true }); |
266 | 267 | } |
267 | 268 |
|
268 | 269 | private fetch = async () => { |
@@ -326,26 +327,31 @@ export class SearchEmbeddable |
326 | 327 | } |
327 | 328 | }; |
328 | 329 |
|
329 | | - private pushContainerStateParamsToScope(searchScope: SearchScope) { |
| 330 | + private pushContainerStateParamsToScope( |
| 331 | + searchScope: SearchScope, |
| 332 | + { forceFetch = false }: { forceFetch: boolean } = { forceFetch: false } |
| 333 | + ) { |
330 | 334 | const isFetchRequired = |
331 | 335 | !esFilters.onlyDisabledFiltersChanged(this.input.filters, this.prevFilters) || |
332 | 336 | !_.isEqual(this.prevQuery, this.input.query) || |
333 | 337 | !_.isEqual(this.prevTimeRange, this.input.timeRange) || |
334 | | - !_.isEqual(searchScope.sort, this.input.sort || this.savedSearch.sort); |
| 338 | + !_.isEqual(searchScope.sort, this.input.sort || this.savedSearch.sort) || |
| 339 | + this.prevSearchSessionId !== this.input.searchSessionId; |
335 | 340 |
|
336 | 341 | // If there is column or sort data on the panel, that means the original columns or sort settings have |
337 | 342 | // been overridden in a dashboard. |
338 | 343 | searchScope.columns = this.input.columns || this.savedSearch.columns; |
339 | 344 | searchScope.sort = this.input.sort || this.savedSearch.sort; |
340 | 345 | searchScope.sharedItemTitle = this.panelTitle; |
341 | 346 |
|
342 | | - if (isFetchRequired) { |
| 347 | + if (forceFetch || isFetchRequired) { |
343 | 348 | this.filtersSearchSource!.setField('filter', this.input.filters); |
344 | 349 | this.filtersSearchSource!.setField('query', this.input.query); |
| 350 | + |
345 | 351 | this.prevFilters = this.input.filters; |
346 | 352 | this.prevQuery = this.input.query; |
347 | 353 | this.prevTimeRange = this.input.timeRange; |
348 | | - |
| 354 | + this.prevSearchSessionId = this.input.searchSessionId; |
349 | 355 | this.fetch(); |
350 | 356 | } else if (this.searchScope) { |
351 | 357 | // trigger a digest cycle to make sure non-fetch relevant changes are propagated |
|
0 commit comments