From 0e4b9e0b60e5fe3346a5336b0f7ccca6e08b9eca Mon Sep 17 00:00:00 2001 From: mohamedhamed-ahmed Date: Mon, 4 Nov 2024 17:06:13 +0000 Subject: [PATCH] [Logs Explorer] Fix logs side nav default navigation (#198773) closes https://github.com/elastic/kibana/issues/198766 --- .../infra/public/apps/logs_app.tsx | 43 ++++++++----------- .../infra/public/plugin.ts | 7 ++- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/apps/logs_app.tsx b/x-pack/plugins/observability_solution/infra/public/apps/logs_app.tsx index 9d5583b0ecf4c..51749d8095481 100644 --- a/x-pack/plugins/observability_solution/infra/public/apps/logs_app.tsx +++ b/x-pack/plugins/observability_solution/infra/public/apps/logs_app.tsx @@ -6,19 +6,13 @@ */ import { History } from 'history'; -import { AppStatus, CoreStart } from '@kbn/core/public'; -import React, { useMemo } from 'react'; +import { CoreStart } from '@kbn/core/public'; +import React from 'react'; import ReactDOM from 'react-dom'; import { Router, Routes, Route } from '@kbn/shared-ux-router'; import { AppMountParameters } from '@kbn/core/public'; import { Storage } from '@kbn/kibana-utils-plugin/public'; -import { - AllDatasetsLocatorParams, - ALL_DATASETS_LOCATOR_ID, - OBSERVABILITY_LOGS_EXPLORER_APP_ID, -} from '@kbn/deeplinks-observability'; -import useObservable from 'react-use/lib/useObservable'; -import { map } from 'rxjs'; +import { AllDatasetsLocatorParams, ALL_DATASETS_LOCATOR_ID } from '@kbn/deeplinks-observability'; import { LinkToLogsPage } from '../pages/link_to/link_to_logs'; import { LogsPage } from '../pages/logs'; import { InfraClientStartDeps, InfraClientStartExports } from '../types'; @@ -30,6 +24,7 @@ export const renderApp = ( core: CoreStart, plugins: InfraClientStartDeps, pluginStart: InfraClientStartExports, + isLogsExplorerAccessible: boolean, { element, history, setHeaderActionMenu, theme$ }: AppMountParameters ) => { const storage = new Storage(window.localStorage); @@ -45,6 +40,7 @@ export const renderApp = ( pluginStart={pluginStart} setHeaderActionMenu={setHeaderActionMenu} theme$={theme$} + isLogsExplorerAccessible={isLogsExplorerAccessible} />, element ); @@ -62,24 +58,19 @@ const LogsApp: React.FC<{ setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; storage: Storage; theme$: AppMountParameters['theme$']; -}> = ({ core, history, pluginStart, plugins, setHeaderActionMenu, storage, theme$ }) => { + isLogsExplorerAccessible: boolean; +}> = ({ + core, + history, + pluginStart, + plugins, + setHeaderActionMenu, + storage, + theme$, + isLogsExplorerAccessible, +}) => { const { logs } = core.application.capabilities; - const isLogsExplorerAppAccessible = useObservable( - useMemo( - () => - core.application.applications$.pipe( - map( - (apps) => - (apps.get(OBSERVABILITY_LOGS_EXPLORER_APP_ID)?.status ?? AppStatus.inaccessible) === - AppStatus.accessible - ) - ), - [core.application.applications$] - ), - false - ); - return ( - {isLogsExplorerAppAccessible && ( + {isLogsExplorerAccessible && (