Skip to content

Commit

Permalink
Prevent duplicated visualization toast errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adri9valle committed Jul 25, 2019
1 parent 9645903 commit 786faf3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions public/kibana-integrations/loader/embedded_visualize_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { RequestHandlerParams, Vis } from 'ui/vis';
import { PipelineDataLoader } from 'ui/visualize/loader/pipeline_data_loader';
import { visualizationLoader } from './visualization_loader';
import { VisualizeDataLoader } from './visualize_data_loader';
import $ from 'jquery';

// @ts-ignore
import { DataAdapter, RequestAdapter } from 'ui/inspector/adapters';
Expand Down Expand Up @@ -88,7 +89,7 @@ export class EmbeddedVisualizeHandler {
* @ignore
*/


private isToast: any;
public readonly data$: Rx.Observable<any>;
public readonly inspectorAdapters: Adapters = {};
private vis: Vis;
Expand Down Expand Up @@ -486,18 +487,22 @@ export class EmbeddedVisualizeHandler {
if (this.dataLoaderParams.searchSource && this.dataLoaderParams.searchSource.cancelQueued) {
this.dataLoaderParams.searchSource.cancelQueued();
}

this.vis.requestError = error;
this.vis.showRequestError =
error.type && ['NO_OP_SEARCH_STRATEGY', 'UNSUPPORTED_QUERY'].includes(error.type);


this.isToast = $(".euiToastHeader__title");

//Do not show notification toast if it's already being shown a similar toast
toastNotifications.addDanger({
title: i18n.translate('common.ui.visualize.dataLoaderError', {
defaultMessage: 'Error in visualization',
}),
text: error.message,
});
if (this.isToast.length === 0 || (this.isToast.length > 0 && this.isToast[0].outerText !== 'Error in visualization')) {
toastNotifications.addDanger({
title: i18n.translate('common.ui.visualize.dataLoaderError', {
defaultMessage: 'Error in visualization',
}),
text: error.message,
});
}
};

private rendererProvider = (response: VisResponseData | null) => {
Expand Down

0 comments on commit 786faf3

Please sign in to comment.