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 8bd243b0723d5..329e059288e3e 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 @@ -57,7 +57,7 @@ const LogsApp: React.FC<{ storage: Storage; theme$: AppMountParameters['theme$']; }> = ({ core, history, pluginStart, plugins, setHeaderActionMenu, storage, theme$ }) => { - const uiCapabilities = core.application.capabilities; + const { logs, discover, fleet } = core.application.capabilities; return ( @@ -74,19 +74,21 @@ const LogsApp: React.FC<{ toastsService={core.notifications.toasts} > - { - plugins.share.url.locators - .get(ALL_DATASETS_LOCATOR_ID) - ?.navigate({}); + {Boolean(discover?.show && fleet?.read) && ( + { + plugins.share.url.locators + .get(ALL_DATASETS_LOCATOR_ID) + ?.navigate({}); - return null; - }} - /> + return null; + }} + /> + )} - {uiCapabilities?.logs?.show && } + {logs?.show && } diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/page_content.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/page_content.tsx index 056c98513c244..5b5965bb2d5ec 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/page_content.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/page_content.tsx @@ -113,6 +113,7 @@ export const LogsPageContent: React.FunctionComponent = () => { )} + ( { + const { infrastructure, logs, discover, fleet } = capabilities; return [ - ...(capabilities.logs.show + ...(logs.show ? [ { label: 'Logs', sortKey: 200, entries: [ - { - label: 'Explorer', - app: 'observability-logs-explorer', - path: '/', - isBetaFeature: true, - }, + ...(discover?.show && fleet?.read + ? [ + { + label: 'Explorer', + app: 'observability-logs-explorer', + path: '/', + isBetaFeature: true, + }, + ] + : []), ...(this.config.featureFlags.logsUIEnabled ? [ { label: 'Stream', app: 'logs', path: '/stream' }, @@ -161,7 +166,7 @@ export class Plugin implements InfraClientPluginClass { }, ] : []), - ...(capabilities.infrastructure.show + ...(infrastructure.show ? [ { label: metricsTitle, diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts index 906caf72a450a..798a03da0ebdf 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts @@ -7,6 +7,8 @@ import { AppMountParameters, + AppStatus, + AppUpdater, CoreSetup, CoreStart, DEFAULT_APP_CATEGORIES, @@ -14,6 +16,7 @@ import { PluginInitializerContext, } from '@kbn/core/public'; import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability'; +import { BehaviorSubject } from 'rxjs'; import { AllDatasetsLocatorDefinition, ObservabilityLogsExplorerLocators, @@ -35,6 +38,7 @@ export class ObservabilityLogsExplorerPlugin { private config: ObservabilityLogsExplorerConfig; private locators?: ObservabilityLogsExplorerLocators; + private appStateUpdater = new BehaviorSubject(() => ({})); constructor(context: PluginInitializerContext) { this.config = context.config.get(); @@ -56,6 +60,7 @@ export class ObservabilityLogsExplorerPlugin ? ['globalSearch', 'sideNav'] : ['globalSearch'], keywords: ['logs', 'log', 'explorer', 'logs explorer'], + updater$: this.appStateUpdater, mount: async (appMountParams: ObservabilityLogsExplorerAppMountParameters) => { const [coreStart, pluginsStart, ownPluginStart] = await core.getStartServices(); const { renderObservabilityLogsExplorer } = await import( @@ -123,7 +128,16 @@ export class ObservabilityLogsExplorerPlugin }; } - public start(_core: CoreStart, _pluginsStart: ObservabilityLogsExplorerStartDeps) { + public start(core: CoreStart, _pluginsStart: ObservabilityLogsExplorerStartDeps) { + const { discover, fleet, logs } = core.application.capabilities; + + if (!(discover?.show && fleet?.read && logs?.show)) { + this.appStateUpdater.next(() => ({ + status: AppStatus.inaccessible, + visibleIn: [], + })); + } + return {}; } }