Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export class RenderCompleteDispatcher {
}

public setEl(el?: HTMLElement) {
this.el = el;
this.count = 0;
if (this.el !== el) {
this.el = el;
this.count = 0;
}
if (el) this.dispatchInProgress();
}

Expand All @@ -61,7 +63,8 @@ export class RenderCompleteDispatcher {
public dispatchError() {
if (!this.el) return;
this.count++;
this.el.setAttribute('data-render-complete', 'false');
this.el.setAttribute('data-render-complete', 'true');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vadimkibana for followup work, we could accept an optional Error parameter, and use it to update the contents of a data-render-error attribute with a message. WDYT?

this.el.setAttribute('data-loading', 'false');
this.el.setAttribute('data-rendering-count', String(this.count));
}

Expand Down
15 changes: 12 additions & 3 deletions x-pack/plugins/lens/public/embeddable/embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ export class Embeddable
}

onContainerStateChanged(containerState: LensEmbeddableInput) {
if (this.handleContainerStateChanged(containerState) || this.errors?.length) this.reload();
if (this.handleContainerStateChanged(containerState)) {
this.reload();
}
}

handleContainerStateChanged(containerState: LensEmbeddableInput): boolean {
Expand Down Expand Up @@ -705,12 +707,19 @@ export class Embeddable

this.domNode.setAttribute('data-shared-item', '');

const error = this.getError();

this.updateOutput({
...this.getOutput(),
loading: true,
error: this.getError(),
error,
});
this.renderComplete.dispatchInProgress();

if (error) {
this.renderComplete.dispatchError();
} else {
this.renderComplete.dispatchInProgress();
}

const input = this.getInput();

Expand Down