Skip to content

Commit

Permalink
[8.x] [Lens][Embeddable] Use reload$ api for custom component (#203755)…
Browse files Browse the repository at this point in the history
… (#204946)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens][Embeddable] Use reload$ api for custom component
(#203755)](#203755)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-19T13:44:12Z","message":"[Lens][Embeddable]
Use reload$ api for custom component (#203755)\n\n##
Summary\r\n\r\nFixes #203457 \r\n\r\nUse the `lastReloadRequestTime`
prop to trigger a reload in place of the\r\nlegacy `searchSessionId`
system.","sha":"3875d26ae8c9be4b5684b7e582eb237113286f99","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","v9.0.0","backport:prev-minor"],"title":"[Lens][Embeddable]
Use reload$ api for custom
component","number":203755,"url":"https://github.com/elastic/kibana/pull/203755","mergeCommit":{"message":"[Lens][Embeddable]
Use reload$ api for custom component (#203755)\n\n##
Summary\r\n\r\nFixes #203457 \r\n\r\nUse the `lastReloadRequestTime`
prop to trigger a reload in place of the\r\nlegacy `searchSessionId`
system.","sha":"3875d26ae8c9be4b5684b7e582eb237113286f99"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203755","number":203755,"mergeCommit":{"message":"[Lens][Embeddable]
Use reload$ api for custom component (#203755)\n\n##
Summary\r\n\r\nFixes #203457 \r\n\r\nUse the `lastReloadRequestTime`
prop to trigger a reload in place of the\r\nlegacy `searchSessionId`
system.","sha":"3875d26ae8c9be4b5684b7e582eb237113286f99"}}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <[email protected]>
  • Loading branch information
kibanamachine and dej611 authored Dec 19, 2024
1 parent 4393cb2 commit 86d8773
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function LensRenderer({
disabledActions,
searchSessionId,
hidePanelTitles,
lastReloadRequestTime,
...props
}: LensRendererProps) {
// Use the settings interface to store panel settings
Expand All @@ -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(() => {
Expand Down Expand Up @@ -152,6 +158,7 @@ export function LensRenderer({
attributes: props.attributes,
}),
hidePanelTitle: hidePanelTitles$,
reload$, // trigger a reload (replacement for deprepcated searchSessionId)
})}
onApiAvailable={setLensApi}
hidePanelChrome={!showPanelChrome}
Expand Down

0 comments on commit 86d8773

Please sign in to comment.