diff --git a/src/plugins/management_overview/public/application.tsx b/src/plugins/management_overview/public/application.tsx index 26ee63e78252..4252f295ff40 100644 --- a/src/plugins/management_overview/public/application.tsx +++ b/src/plugins/management_overview/public/application.tsx @@ -5,28 +5,27 @@ import ReactDOM from 'react-dom'; import { I18nProvider, FormattedMessage } from '@osd/i18n/react'; -import React from 'react'; +import React, { useMemo } from 'react'; import { EuiFlexGrid, EuiFlexItem, EuiPage, EuiPageBody, EuiSpacer, EuiTitle } from '@elastic/eui'; import useObservable from 'react-use/lib/useObservable'; -import { ApplicationStart, ChromeStart, CoreStart } from '../../../core/public'; +import { ApplicationStart, AppNavLinkStatus, CoreStart } from '../../../core/public'; import { OverviewApp } from '.'; import { OverviewCard } from './components/overview_card'; export interface ManagementOverviewProps { application: ApplicationStart; - chrome: ChromeStart; overviewApps?: OverviewApp[]; } function ManagementOverviewWrapper(props: ManagementOverviewProps) { - const { chrome, application, overviewApps } = props; + const { application, overviewApps } = props; + const applications = useObservable(application.applications$); - const hiddenAppIds = - useObservable(chrome.navLinks.getNavLinks$()) - ?.filter((link) => link.hidden) - .map((link) => link.id) || []; - - const availableApps = overviewApps?.filter((app) => hiddenAppIds.indexOf(app.id) === -1); + const availableApps = useMemo(() => { + return overviewApps?.filter( + (overviewApp) => applications?.get(overviewApp.id)?.navLinkStatus !== AppNavLinkStatus.hidden + ); + }, [applications, overviewApps]); return ( @@ -61,11 +60,7 @@ export function renderApp( ) { ReactDOM.render( - + , element ); diff --git a/src/plugins/management_overview/public/index.ts b/src/plugins/management_overview/public/index.ts index 28eadd8c2f33..9b2bcc8d8f86 100644 --- a/src/plugins/management_overview/public/index.ts +++ b/src/plugins/management_overview/public/index.ts @@ -6,6 +6,6 @@ import { ManagementOverViewPlugin } from './plugin'; export { OverviewApp } from './overview_app'; -export { ManagementOverViewPluginSetup, ManagementOverViewPluginStart } from './plugin'; +export { ManagementOverViewPluginSetup } from './plugin'; export const plugin = () => new ManagementOverViewPlugin();