mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Log Explorer] Remove beta badge when leaving the app (#167065)
## 📓 Summary
Closes #167011
This implementation fixes the persisted beta badge after leaving the Log
Explorer profile, restoring any existing element on the mount point as a
clean-up action.
3214e097
-2c82-4b09-8310-ad09eb4c5a18
Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
This commit is contained in:
parent
7d92c16ec0
commit
7f796659a7
1 changed files with 19 additions and 3 deletions
|
@ -5,10 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import deepEqual from 'fast-deep-equal';
|
||||
import useObservable from 'react-use/lib/useObservable';
|
||||
import { type BehaviorSubject, distinctUntilChanged } from 'rxjs';
|
||||
import { type BehaviorSubject, distinctUntilChanged, filter, take } from 'rxjs';
|
||||
import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public';
|
||||
import { AppMountParameters } from '@kbn/core-application-browser';
|
||||
import {
|
||||
|
@ -111,6 +111,16 @@ const StatefulTopNav = ({
|
|||
}: LogExplorerTopNavMenuProps) => {
|
||||
const { euiTheme } = useEuiTheme();
|
||||
|
||||
/**
|
||||
* Since the breadcrumbsAppendExtension might be set only during a plugin start (e.g. search session)
|
||||
* we retrieve the latest valid extension in order to restore it once we unmount the beta badge.
|
||||
*/
|
||||
const [previousAppendExtension$] = useState(() =>
|
||||
services.chrome.getBreadcrumbsAppendExtension$().pipe(filter(Boolean), take(1))
|
||||
);
|
||||
|
||||
const previousAppendExtension = useObservable(previousAppendExtension$);
|
||||
|
||||
useEffect(() => {
|
||||
const { chrome, i18n, theme } = services;
|
||||
|
||||
|
@ -137,7 +147,13 @@ const StatefulTopNav = ({
|
|||
),
|
||||
});
|
||||
}
|
||||
}, [euiTheme, services]);
|
||||
|
||||
return () => {
|
||||
if (chrome) {
|
||||
chrome.setBreadcrumbsAppendExtension(previousAppendExtension);
|
||||
}
|
||||
};
|
||||
}, [euiTheme, services, previousAppendExtension]);
|
||||
|
||||
return (
|
||||
<HeaderMenuPortal setHeaderActionMenu={setHeaderActionMenu} theme$={theme$}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue