Skip to content

Commit

Permalink
[Canvas] Force embeddables to refresh when renderable reevaluated (el…
Browse files Browse the repository at this point in the history
…astic#67133)

* Force embeddables to refresh when renderable reevaluated

* prettier

* Rename generated property

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
Corey Robertson and elasticmachine authored May 26, 2020
1 parent 5d26740 commit c8b1fc5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@ export const EmbeddableExpressionType = 'embeddable';
export { EmbeddableTypes, EmbeddableInput };

export interface EmbeddableExpression<Input extends EmbeddableInput> {
/**
* The type of the expression result
*/
type: typeof EmbeddableExpressionType;
/**
* The input to be passed to the embeddable
*/
input: Input;
/**
* The type of embeddable
*/
embeddableType: string;
/**
* Timestamp. Needed to get a different result after each time the expression is evaluated
* to force a reload of the embeddables internal data
*/
generatedAt: number;
}

export const embeddableType = (): ExpressionTypeDefinition<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function savedLens(): ExpressionFunctionDefinition<
disableTriggers: true,
},
embeddableType: EmbeddableTypes.lens,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function savedMap(): ExpressionFunctionDefinition<
hiddenLayers: args.hideLayer || [],
},
embeddableType: EmbeddableTypes.map,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function savedSearch(): ExpressionFunctionDefinition<
...buildEmbeddableFilters(filters),
},
embeddableType: EmbeddableTypes.search,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function savedVisualization(): ExpressionFunctionDefinition<
vis: visOptions,
},
embeddableType: EmbeddableTypes.visualization,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const embeddableRendererFactory = (core: CoreStart, plugins: StartDeps) =
});
} else {
embeddablesRegistry[uniqueId].updateInput(input);
embeddablesRegistry[uniqueId].reload();
}
},
});
Expand Down

0 comments on commit c8b1fc5

Please sign in to comment.