Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions x-pack/plugins/maps/public/embeddable/map_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
import {
areLayersLoaded,
getGeoFieldNames,
getLayerList,
getMapCenter,
getMapBuffer,
getMapExtent,
Expand Down Expand Up @@ -138,36 +139,6 @@ export class MapEmbeddable
this._savedMap = new SavedMap({ mapEmbeddableInput: initialInput });
this._initializeSaveMap();
this._subscription = this.getUpdated$().subscribe(() => this.onUpdate());
this.setEventHandlers({
onDataLoad: () => {
this.updateOutput({
...this.getOutput(),
loading: true,
rendered: false,
error: undefined,
});
},
onDataLoadEnd: () => {
this.updateOutput({
...this.getOutput(),
loading: false,
// TODO: rendering happens later - separate the rendered and loading events
rendered: true,
});
},
onDataLoadError: (e) => {
this.updateOutput({
...this.getOutput(),
loading: false,
// TODO: rendering happens later - separate the rendered and loading events
rendered: true,
error: {
name: 'EmbeddableError',
message: e.errorMessage,
},
});
},
});
this._controlledBy = `mapEmbeddablePanel${this.id}`;
this._prevFilterByMapExtent =
this.input.filterByMapExtent === undefined ? false : this.input.filterByMapExtent;
Expand Down Expand Up @@ -650,5 +621,30 @@ export class MapEmbeddable
hiddenLayers: hiddenLayerIds,
});
}

const layers = getLayerList(this._savedMap.getStore().getState());
const isLoading = layers.some((layer) => {
return layer.isLayerLoading();
});
const firstLayerWithError = layers.find((layer) => {
return layer.hasErrors();
});
const output = this.getOutput();
if (
output.loading !== isLoading ||
firstLayerWithError?.getErrors() !== output.error?.message
) {
this.updateOutput({
...output,
loading: isLoading,
rendered: !isLoading && firstLayerWithError === undefined,
error: firstLayerWithError
? {
name: 'EmbeddableError',
message: firstLayerWithError.getErrors(),
}
: undefined,
});
}
}
}