mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Logs Explorer] Fix logs side nav default navigation (#198773)
closes https://github.com/elastic/kibana/issues/198766
This commit is contained in:
parent
cfbf9354be
commit
0e4b9e0b60
2 changed files with 23 additions and 27 deletions
|
@ -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 (
|
||||
<CoreProviders core={core} pluginStart={pluginStart} plugins={plugins} theme$={theme$}>
|
||||
<CommonInfraProviders
|
||||
|
@ -95,7 +86,7 @@ const LogsApp: React.FC<{
|
|||
toastsService={core.notifications.toasts}
|
||||
>
|
||||
<Routes>
|
||||
{isLogsExplorerAppAccessible && (
|
||||
{isLogsExplorerAccessible && (
|
||||
<Route
|
||||
path="/"
|
||||
exact
|
||||
|
|
|
@ -29,6 +29,7 @@ import {
|
|||
of,
|
||||
switchMap,
|
||||
map,
|
||||
firstValueFrom,
|
||||
} from 'rxjs';
|
||||
import type { EmbeddableApiContext } from '@kbn/presentation-publishing';
|
||||
import { apiCanAddNewPanel } from '@kbn/presentation-containers';
|
||||
|
@ -231,8 +232,12 @@ export class Plugin implements InfraClientPluginClass {
|
|||
// mount callback should not use setup dependencies, get start dependencies instead
|
||||
const [coreStart, plugins, pluginStart] = await core.getStartServices();
|
||||
|
||||
const isLogsExplorerAccessible = await firstValueFrom(
|
||||
getLogsExplorerAccessible$(coreStart.application)
|
||||
);
|
||||
|
||||
const { renderApp } = await import('./apps/logs_app');
|
||||
return renderApp(coreStart, plugins, pluginStart, params);
|
||||
return renderApp(coreStart, plugins, pluginStart, isLogsExplorerAccessible, params);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue