From e04f7a34e01977fb59881f605b4ebf17e1990b9a Mon Sep 17 00:00:00 2001 From: Katerina Date: Wed, 18 Sep 2024 20:50:22 +0300 Subject: [PATCH] [Inventory] Remove inventory dependency from observability plugin (#193251) ## Summary closes https://github.com/elastic/kibana/issues/193200 - Remove inventory dependency from observability plugin - Register inventory in different section in classic stateful sidenav https://github.com/user-attachments/assets/6c9c28bc-7483-4deb-b95a-67585a92f89f (cherry picked from commit be2d64196270f683548747ec3ff0a365be666f94) --- .../inventory/public/plugin.tsx | 26 +++++++++++++++++++ .../observability/kibana.jsonc | 14 +++------- .../observability/public/navigation_tree.ts | 19 +++----------- .../observability/public/plugin.ts | 17 ------------ .../observability/tsconfig.json | 9 +++---- 5 files changed, 36 insertions(+), 49 deletions(-) diff --git a/x-pack/plugins/observability_solution/inventory/public/plugin.tsx b/x-pack/plugins/observability_solution/inventory/public/plugin.tsx index 355309939ea6c..0cb7df9552c74 100644 --- a/x-pack/plugins/observability_solution/inventory/public/plugin.tsx +++ b/x-pack/plugins/observability_solution/inventory/public/plugin.tsx @@ -7,6 +7,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { i18n } from '@kbn/i18n'; +import { from, map } from 'rxjs'; import { AppMountParameters, APP_WRAPPER_CLASS, @@ -49,6 +50,31 @@ export class InventoryPlugin ): InventoryPublicSetup { const inventoryAPIClient = createCallInventoryAPI(coreSetup); + pluginsSetup.observabilityShared.navigation.registerSections( + from(coreSetup.getStartServices()).pipe( + map(([coreStart, pluginsStart]) => { + return [ + { + label: '', + sortKey: 101, + entries: [ + { + label: i18n.translate('xpack.inventory.inventoryLinkTitle', { + defaultMessage: 'Inventory', + }), + app: INVENTORY_APP_ID, + path: '/', + matchPath(currentPath: string) { + return ['/', ''].some((testPath) => currentPath.startsWith(testPath)); + }, + }, + ], + }, + ]; + }) + ) + ); + coreSetup.application.register({ id: INVENTORY_APP_ID, title: i18n.translate('xpack.inventory.appTitle', { diff --git a/x-pack/plugins/observability_solution/observability/kibana.jsonc b/x-pack/plugins/observability_solution/observability/kibana.jsonc index 3697fa0ff628a..859e7340a799d 100644 --- a/x-pack/plugins/observability_solution/observability/kibana.jsonc +++ b/x-pack/plugins/observability_solution/observability/kibana.jsonc @@ -6,10 +6,7 @@ "id": "observability", "server": true, "browser": true, - "configPath": [ - "xpack", - "observability" - ], + "configPath": ["xpack", "observability"], "requiredPlugins": [ "aiops", "alerting", @@ -52,8 +49,7 @@ "serverless", "guidedOnboarding", "observabilityAIAssistant", - "investigate", - "inventory" + "investigate" ], "requiredBundles": [ "data", @@ -61,10 +57,8 @@ "kibanaUtils", "unifiedSearch", "stackAlerts", - "spaces", + "spaces" ], - "extraPublicDirs": [ - "common" - ] + "extraPublicDirs": ["common"] } } diff --git a/x-pack/plugins/observability_solution/observability/public/navigation_tree.ts b/x-pack/plugins/observability_solution/observability/public/navigation_tree.ts index 67062d2230235..6d63c9c89eaf1 100644 --- a/x-pack/plugins/observability_solution/observability/public/navigation_tree.ts +++ b/x-pack/plugins/observability_solution/observability/public/navigation_tree.ts @@ -49,22 +49,6 @@ export function createNavTree(pluginsStart: ObservabilityPublicPluginsStart) { return pathNameSerialized.startsWith(prepend('/app/dashboards')); }, }, - ...(pluginsStart.inventory - ? [ - { - link: 'inventory' as const, - getIsActive: ({ - pathNameSerialized, - prepend, - }: { - pathNameSerialized: string; - prepend: (path: string) => string; - }) => { - return pathNameSerialized.startsWith(prepend('/app/observability/inventory')); - }, - }, - ] - : []), { link: 'observability-overview:alerts', }, @@ -83,6 +67,9 @@ export function createNavTree(pluginsStart: ObservabilityPublicPluginsStart) { { link: 'slo', }, + { + link: 'inventory', + }, { id: 'aiMl', title: i18n.translate('xpack.observability.obltNav.ml.aiAndMlGroupTitle', { diff --git a/x-pack/plugins/observability_solution/observability/public/plugin.ts b/x-pack/plugins/observability_solution/observability/public/plugin.ts index a22638213adbf..a4b0d8e57ce4b 100644 --- a/x-pack/plugins/observability_solution/observability/public/plugin.ts +++ b/x-pack/plugins/observability_solution/observability/public/plugin.ts @@ -48,11 +48,9 @@ import { BehaviorSubject, from, map, mergeMap } from 'rxjs'; import type { AiopsPluginStart } from '@kbn/aiops-plugin/public/types'; import type { DataViewFieldEditorStart } from '@kbn/data-view-field-editor-plugin/public'; -import { INVENTORY_APP_ID } from '@kbn/deeplinks-observability/constants'; import type { EmbeddableSetup } from '@kbn/embeddable-plugin/public'; import type { ExploratoryViewPublicStart } from '@kbn/exploratory-view-plugin/public'; import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; -import type { InventoryPublicSetup, InventoryPublicStart } from '@kbn/inventory-plugin/public'; import type { InvestigatePublicStart } from '@kbn/investigate-plugin/public'; import type { LicenseManagementUIPluginSetup } from '@kbn/license-management-plugin/public'; import type { LicensingPluginStart } from '@kbn/licensing-plugin/public'; @@ -126,7 +124,6 @@ export interface ObservabilityPublicPluginsSetup { licensing: LicensingPluginSetup; serverless?: ServerlessPluginSetup; presentationUtil?: PresentationUtilPluginStart; - inventory?: InventoryPublicSetup; } export interface ObservabilityPublicPluginsStart { actionTypeRegistry: ActionTypeRegistryContract; @@ -165,7 +162,6 @@ export interface ObservabilityPublicPluginsStart { dataViewFieldEditor: DataViewFieldEditorStart; toastNotifications: ToastsStart; investigate?: InvestigatePublicStart; - inventory?: InventoryPublicStart; } export type ObservabilityPublicStart = ReturnType; @@ -361,18 +357,6 @@ export class Plugin ] : []; - const inventoryLink = pluginsSetup.inventory - ? [ - { - label: i18n.translate('xpack.observability.inventoryLinkTitle', { - defaultMessage: 'Inventory', - }), - app: INVENTORY_APP_ID, - path: '', - }, - ] - : []; - const isAiAssistantEnabled = pluginsStart.observabilityAIAssistant?.service.isEnabled(); @@ -436,7 +420,6 @@ export class Plugin sortKey: 100, entries: [ ...overviewLink, - ...inventoryLink, ...alertsLink, ...sloLink, ...casesLink, diff --git a/x-pack/plugins/observability_solution/observability/tsconfig.json b/x-pack/plugins/observability_solution/observability/tsconfig.json index 873a87c11d1a4..d7a33cb6492cb 100644 --- a/x-pack/plugins/observability_solution/observability/tsconfig.json +++ b/x-pack/plugins/observability_solution/observability/tsconfig.json @@ -9,7 +9,7 @@ "public/**/*.json", "server/**/*", "typings/**/*", - "../../../../typings/**/*", + "../../../../typings/**/*" ], "kbn_references": [ "@kbn/rule-data-utils", @@ -94,7 +94,6 @@ "@kbn/home-plugin", "@kbn/data-view-field-editor-plugin", "@kbn/guided-onboarding-plugin", - "@kbn/inventory-plugin", "@kbn/investigate-plugin", "@kbn/license-management-plugin", "@kbn/presentation-util-plugin", @@ -114,9 +113,7 @@ "@kbn/io-ts-utils", "@kbn/core-ui-settings-server-mocks", "@kbn/es-types", - "@kbn/logging-mocks", + "@kbn/logging-mocks" ], - "exclude": [ - "target/**/*" - ] + "exclude": ["target/**/*"] }