x-pack/examples/lens_embeddable_inline_editing_example/README.md
To run this example plugin, use the command yarn start --run-examples.
This plugin contains examples on how to integrate the inline editing capabilities to your Lens embeddable.
Steps:
// my Lens embeddable
<LensComponent {...embeddableInput} onLoad={onLoad} />
const [lensLoadEvent, setLensLoadEvent] = useState<
InlineEditLensEmbeddableContext['lensEvent'] | null
>(null);
// my onLoad callback
const onLoad = useCallback(
(
isLoading: boolean,
adapters: LensChartLoadEvent['adapters'] | undefined,
lensEmbeddableOutput$?: LensChartLoadEvent['embeddableOutput$']
) => {
const adapterTables = adapters?.tables?.tables;
if (adapterTables && !isLoading) {
setLensLoadEvent({
adapters,
embeddableOutput$: lensEmbeddableOutput$,
});
}
},
[]
);
// my trigger options
const triggerOptions = {
attributes: embeddableInput?.attributes,
lensEvent: lensLoadEvent,
onUpdate: (newAttributes: TypedLensByValueInput['attributes']) => {
// onUpdate I need to update my embeddableInput.attributes
},
onApply: () => {
// optional callback when Apply button is clicked
},
onCancel: () => {
// optional callback when Cancel button is clicked
},
};
uiActions.executeTriggerActions('IN_APP_EMBEDDABLE_EDIT_TRIGGER', triggerOptions);
In case you don't want to open a push flyout you can pass an html element to the triggerOptions, the container property. This is going
to render the inline editing component to this container element. In that case you will need an extra handling on your side.
Check the 3rd example for implementation details.