[Lens][Embeddable] Use reload$ api for custom component (#203755)

## Summary

Fixes #203457 

Use the `lastReloadRequestTime` prop to trigger a reload in place of the
legacy `searchSessionId` system.
This commit is contained in:
Marco Liberati 2024-12-19 14:44:12 +01:00 committed by GitHub
parent 505cc0fbbb
commit 3875d26ae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -61,6 +61,7 @@ export function LensRenderer({
disabledActions,
searchSessionId,
hidePanelTitles,
lastReloadRequestTime,
...props
}: LensRendererProps) {
// Use the settings interface to store panel settings
@ -86,6 +87,11 @@ export function LensRenderer({
const showPanelChrome = Boolean(withDefaultActions) || (extraActions?.length || 0) > 0;
const reload$ = useMemo(() => new BehaviorSubject<void>(undefined), []);
useEffect(() => {
reload$.next();
}, [reload$, lastReloadRequestTime]);
// Re-render on changes
// internally the embeddable will evaluate whether it is worth to actual render or not
useEffect(() => {
@ -152,6 +158,7 @@ export function LensRenderer({
attributes: props.attributes,
}),
hidePanelTitle: hidePanelTitles$,
reload$, // trigger a reload (replacement for deprepcated searchSessionId)
})}
onApiAvailable={setLensApi}
hidePanelChrome={!showPanelChrome}