From ae91721233bed1372416de598d726a4f75ffdbb6 Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Thu, 10 Oct 2024 10:07:48 +0100 Subject: [PATCH 1/4] [Inventory] Adding feedback button --- .../inventory/kibana.jsonc | 2 +- .../inventory/public/application.tsx | 20 +++++++------------ .../public/components/app_root/index.tsx | 4 ++++ .../inventory_page_template/index.tsx | 18 +++++++++++++++-- .../inventory/public/hooks/use_kibana.tsx | 10 +++++++++- .../inventory/public/plugin.ts | 14 ++++++++++++- .../inventory/public/types.ts | 2 ++ 7 files changed, 52 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/observability_solution/inventory/kibana.jsonc b/x-pack/plugins/observability_solution/inventory/kibana.jsonc index f60cf36183b24..64646a4c040cc 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": [], + "optionalPlugins": ["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 d34be920d68ff..6d1a3dd2c3037 100644 --- a/x-pack/plugins/observability_solution/inventory/public/application.tsx +++ b/x-pack/plugins/observability_solution/inventory/public/application.tsx @@ -12,17 +12,16 @@ import { css } from '@emotion/css'; 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; const appWrapperClassName = css` @@ -33,12 +32,7 @@ export const renderApp = ({ 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 c02a57b45f691..f2c6486aff4a6 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, @@ -85,6 +89,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', { @@ -115,6 +122,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 2393b1b55e2b6..f69f6c3baa586 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'; /* eslint-disable @typescript-eslint/no-empty-interface*/ @@ -28,6 +29,7 @@ export interface InventorySetupDependencies { share: SharePluginSetup; data: DataPublicPluginSetup; entityManager: EntityManagerPublicPluginSetup; + cloud?: CloudSetup; } export interface InventoryStartDependencies { From c2ab66f8f158af23b21965a7c1b03b8e13217849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Marcondes?= <55978943+cauemarcondes@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:19:12 +0100 Subject: [PATCH 2/4] Update x-pack/plugins/observability_solution/inventory/kibana.jsonc Co-authored-by: jennypavlova --- x-pack/plugins/observability_solution/inventory/kibana.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/inventory/kibana.jsonc b/x-pack/plugins/observability_solution/inventory/kibana.jsonc index 64646a4c040cc..fee7f0734648c 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": ["cloud",], + "optionalPlugins": ["cloud"], "extraPublicDirs": [] } } From a494b606ccd7b2177f2daca72e066f11ff3669e2 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:30:55 +0000 Subject: [PATCH 3/4] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/observability_solution/inventory/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/inventory/tsconfig.json b/x-pack/plugins/observability_solution/inventory/tsconfig.json index 54fcfe7e3a11f..f0e3cd016e72a 100644 --- a/x-pack/plugins/observability_solution/inventory/tsconfig.json +++ b/x-pack/plugins/observability_solution/inventory/tsconfig.json @@ -45,6 +45,7 @@ "@kbn/config-schema", "@kbn/elastic-agent-utils", "@kbn/custom-icons", - "@kbn/ui-theme" + "@kbn/ui-theme", + "@kbn/cloud-plugin" ] } From 6451260f06dbf1233064d36f9c633f83831ae3ca Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Mon, 14 Oct 2024 09:08:42 +0100 Subject: [PATCH 4/4] fixing ci --- .../inventory/.storybook/get_mock_inventory_context.tsx | 5 +++++ 1 file changed, 5 insertions(+) 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', + }, }; }