diff --git a/x-pack/plugins/observability_solution/inventory/.storybook/get_mock_inventory_context.tsx b/x-pack/plugins/observability_solution/inventory/.storybook/get_mock_inventory_context.tsx index d90ce08aab1c6..52ec669a9a75c 100644 --- a/x-pack/plugins/observability_solution/inventory/.storybook/get_mock_inventory_context.tsx +++ b/x-pack/plugins/observability_solution/inventory/.storybook/get_mock_inventory_context.tsx @@ -35,5 +35,10 @@ export function getMockInventoryContext(): InventoryKibanaContext { stream: jest.fn(), }, spaces: {} as unknown as SpacesPluginStart, + kibanaEnvironment: { + isCloudEnv: false, + isServerlessEnv: false, + kibanaVersion: '9.0.0', + }, }; } diff --git a/x-pack/plugins/observability_solution/inventory/kibana.jsonc b/x-pack/plugins/observability_solution/inventory/kibana.jsonc index 28556c7bcc583..1467d294a4f49 100644 --- a/x-pack/plugins/observability_solution/inventory/kibana.jsonc +++ b/x-pack/plugins/observability_solution/inventory/kibana.jsonc @@ -19,7 +19,7 @@ "share" ], "requiredBundles": ["kibanaReact"], - "optionalPlugins": ["spaces"], + "optionalPlugins": ["spaces", "cloud"], "extraPublicDirs": [] } } diff --git a/x-pack/plugins/observability_solution/inventory/public/application.tsx b/x-pack/plugins/observability_solution/inventory/public/application.tsx index 7b611d1d04c22..53616a27de9e7 100644 --- a/x-pack/plugins/observability_solution/inventory/public/application.tsx +++ b/x-pack/plugins/observability_solution/inventory/public/application.tsx @@ -11,27 +11,21 @@ import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import type { InventoryStartDependencies } from './types'; import { InventoryServices } from './services/types'; import { AppRoot } from './components/app_root'; +import { KibanaEnvironment } from './hooks/use_kibana'; -export const renderApp = ({ - coreStart, - pluginsStart, - services, - appMountParameters, -}: { +export const renderApp = (props: { coreStart: CoreStart; pluginsStart: InventoryStartDependencies; services: InventoryServices; -} & { appMountParameters: AppMountParameters }) => { + appMountParameters: AppMountParameters; + kibanaEnvironment: KibanaEnvironment; +}) => { + const { appMountParameters, coreStart } = props; const { element } = appMountParameters; ReactDOM.render( - + , element ); diff --git a/x-pack/plugins/observability_solution/inventory/public/components/app_root/index.tsx b/x-pack/plugins/observability_solution/inventory/public/components/app_root/index.tsx index d46e2b76012d9..6bec4335c7193 100644 --- a/x-pack/plugins/observability_solution/inventory/public/components/app_root/index.tsx +++ b/x-pack/plugins/observability_solution/inventory/public/components/app_root/index.tsx @@ -17,16 +17,19 @@ import { inventoryRouter } from '../../routes/config'; import { InventoryServices } from '../../services/types'; import { InventoryStartDependencies } from '../../types'; import { HeaderActionMenuItems } from './header_action_menu'; +import { KibanaEnvironment } from '../../hooks/use_kibana'; export function AppRoot({ coreStart, pluginsStart, services, appMountParameters, + kibanaEnvironment, }: { coreStart: CoreStart; pluginsStart: InventoryStartDependencies; services: InventoryServices; + kibanaEnvironment: KibanaEnvironment; } & { appMountParameters: AppMountParameters }) { const { history } = appMountParameters; @@ -34,6 +37,7 @@ export function AppRoot({ ...coreStart, ...pluginsStart, ...services, + kibanaEnvironment, }; return ( diff --git a/x-pack/plugins/observability_solution/inventory/public/components/inventory_page_template/index.tsx b/x-pack/plugins/observability_solution/inventory/public/components/inventory_page_template/index.tsx index 29a6ac31348b4..08ff287b58cfd 100644 --- a/x-pack/plugins/observability_solution/inventory/public/components/inventory_page_template/index.tsx +++ b/x-pack/plugins/observability_solution/inventory/public/components/inventory_page_template/index.tsx @@ -7,7 +7,10 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiEmptyPrompt, EuiLoadingLogo } from '@elastic/eui'; -import { TechnicalPreviewBadge } from '@kbn/observability-shared-plugin/public'; +import { + FeatureFeedbackButton, + TechnicalPreviewBadge, +} from '@kbn/observability-shared-plugin/public'; import { useKibana } from '../../hooks/use_kibana'; import { SearchBar } from '../search_bar'; import { getEntityManagerEnablement } from './no_data_config'; @@ -29,9 +32,11 @@ const pageTitle = ( ); +const INVENTORY_FEEDBACK_LINK = 'https://ela.st/feedback-new-inventory'; + export function InventoryPageTemplate({ children }: { children: React.ReactNode }) { const { - services: { observabilityShared, inventoryAPIClient }, + services: { observabilityShared, inventoryAPIClient, kibanaEnvironment }, } = useKibana(); const { PageTemplate: ObservabilityPageTemplate } = observabilityShared.navigation; @@ -73,6 +78,15 @@ export function InventoryPageTemplate({ children }: { children: React.ReactNode , + ], }} noDataConfig={getEntityManagerEnablement({ enabled: isEntityManagerEnabled, diff --git a/x-pack/plugins/observability_solution/inventory/public/hooks/use_kibana.tsx b/x-pack/plugins/observability_solution/inventory/public/hooks/use_kibana.tsx index 0baf2acbc32b8..e70f0aa7326c6 100644 --- a/x-pack/plugins/observability_solution/inventory/public/hooks/use_kibana.tsx +++ b/x-pack/plugins/observability_solution/inventory/public/hooks/use_kibana.tsx @@ -10,7 +10,15 @@ import { type KibanaReactContextValue, useKibana } from '@kbn/kibana-react-plugi import type { InventoryStartDependencies } from '../types'; import type { InventoryServices } from '../services/types'; -export type InventoryKibanaContext = CoreStart & InventoryStartDependencies & InventoryServices; +export interface KibanaEnvironment { + kibanaVersion?: string; + isCloudEnv?: boolean; + isServerlessEnv?: boolean; +} + +export type InventoryKibanaContext = CoreStart & + InventoryStartDependencies & + InventoryServices & { kibanaEnvironment: KibanaEnvironment }; const useTypedKibana = useKibana as () => KibanaReactContextValue; diff --git a/x-pack/plugins/observability_solution/inventory/public/plugin.ts b/x-pack/plugins/observability_solution/inventory/public/plugin.ts index 30e3a1eed3681..4567e8f34a94a 100644 --- a/x-pack/plugins/observability_solution/inventory/public/plugin.ts +++ b/x-pack/plugins/observability_solution/inventory/public/plugin.ts @@ -7,12 +7,12 @@ import { AppMountParameters, + AppStatus, CoreSetup, CoreStart, DEFAULT_APP_CATEGORIES, Plugin, PluginInitializerContext, - AppStatus, } from '@kbn/core/public'; import { INVENTORY_APP_ID } from '@kbn/deeplinks-observability/constants'; import { i18n } from '@kbn/i18n'; @@ -40,10 +40,14 @@ export class InventoryPlugin { logger: Logger; telemetry: TelemetryService; + kibanaVersion: string; + isServerlessEnv: boolean; constructor(context: PluginInitializerContext) { this.logger = context.logger.get(); this.telemetry = new TelemetryService(); + this.kibanaVersion = context.env.packageInfo.version; + this.isServerlessEnv = context.env.packageInfo.buildFlavor === 'serverless'; } setup( coreSetup: CoreSetup, @@ -104,6 +108,9 @@ export class InventoryPlugin this.telemetry.setup({ analytics: coreSetup.analytics }); const telemetry = this.telemetry.start(); + const isCloudEnv = !!pluginsSetup.cloud?.isCloudEnabled; + const isServerlessEnv = pluginsSetup.cloud?.isServerlessEnabled || this.isServerlessEnv; + coreSetup.application.register({ id: INVENTORY_APP_ID, title: i18n.translate('xpack.inventory.appTitle', { @@ -134,6 +141,11 @@ export class InventoryPlugin pluginsStart, services, appMountParameters, + kibanaEnvironment: { + isCloudEnv, + isServerlessEnv, + kibanaVersion: this.kibanaVersion, + }, }); }, }); diff --git a/x-pack/plugins/observability_solution/inventory/public/types.ts b/x-pack/plugins/observability_solution/inventory/public/types.ts index 48fe7e7eed1c7..cb4d7719e3199 100644 --- a/x-pack/plugins/observability_solution/inventory/public/types.ts +++ b/x-pack/plugins/observability_solution/inventory/public/types.ts @@ -17,6 +17,7 @@ import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/publi import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public'; +import type { CloudSetup } from '@kbn/cloud-plugin/public'; import type { SpacesPluginStart } from '@kbn/spaces-plugin/public'; /* eslint-disable @typescript-eslint/no-empty-interface*/ @@ -29,6 +30,7 @@ export interface InventorySetupDependencies { share: SharePluginSetup; data: DataPublicPluginSetup; entityManager: EntityManagerPublicPluginSetup; + cloud?: CloudSetup; } export interface InventoryStartDependencies { diff --git a/x-pack/plugins/observability_solution/inventory/tsconfig.json b/x-pack/plugins/observability_solution/inventory/tsconfig.json index 20b5e2e37232a..6492cd51d067a 100644 --- a/x-pack/plugins/observability_solution/inventory/tsconfig.json +++ b/x-pack/plugins/observability_solution/inventory/tsconfig.json @@ -46,6 +46,7 @@ "@kbn/elastic-agent-utils", "@kbn/custom-icons", "@kbn/ui-theme", - "@kbn/spaces-plugin" + "@kbn/spaces-plugin", + "@kbn/cloud-plugin" ] }