From 2ba6978e24f71fa4d1f4d94a73ac89be5264514a Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Fri, 23 Feb 2024 15:59:20 +0100 Subject: [PATCH] [Infra][Serverless] fix breadcrumb, page template and small layout issues (#177312) closes [176602](https://github.com/elastic/kibana/issues/176602) ## Summary This PR fixes a few small issues that became more evident in the serverless offering ### Serverless - Breadcrumbs image image image - Asset Details Page Template | before | after | | --- | --- | |image|image | The page now uses the `PageTemplate` from `observability-shared`, which is what other pages in observability use. ### Other fixes - Spacing between header and unified search in the Hosts View | before | after | | --- | --- | |image|image | The default spacing is 24px. For some reason, the hosts view had a 12px space between the 2 components. - Breadcrumb (still works as expected) image ### How to test - Start a serverless Kibana, ES instances and run metricbeat with system module enabled - run `yarn es serverless --projectType=oblt` and `yarn serverless-oblt` - Navigate to Inventory pages and APM Settings - Check the changes described above - Start a stateful Kibana instance - Navigate to inventory pages and APM Settings - Check the changes described above --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../deeplinks/observability/deep_links.ts | 7 +- x-pack/plugins/infra/kibana.jsonc | 14 ++- .../asset_details/template/page.tsx | 89 +++++++++++-------- .../plugins/infra/public/hooks/use_kibana.tsx | 6 +- .../public/hooks/use_metrics_breadcrumbs.tsx | 37 +++++++- .../hooks/use_parent_breadcrumb_resolver.ts | 9 +- .../search_bar/unified_search_bar.tsx | 2 +- .../public/pages/metrics/hosts/index.tsx | 6 +- .../components/survey_kubernetes.tsx | 6 +- .../components/survey_section.tsx | 6 +- .../metric_detail/asset_detail_page.tsx | 38 ++------ .../pages/metrics/metric_detail/index.tsx | 2 +- .../metric_detail/metric_detail_page.tsx | 23 ++--- .../pages/metrics/metric_detail/types.ts | 6 -- .../pages/metrics/metrics_explorer/index.tsx | 6 +- x-pack/plugins/infra/public/plugin.ts | 6 ++ x-pack/plugins/infra/public/types.ts | 2 + x-pack/plugins/infra/tsconfig.json | 1 + .../public/navigation_tree.ts | 12 +++ 19 files changed, 171 insertions(+), 107 deletions(-) rename x-pack/plugins/infra/public/{pages/metrics/metric_detail => }/hooks/use_parent_breadcrumb_resolver.ts (88%) diff --git a/packages/deeplinks/observability/deep_links.ts b/packages/deeplinks/observability/deep_links.ts index 2a682a352cb46..0dee18d5b0ae5 100644 --- a/packages/deeplinks/observability/deep_links.ts +++ b/packages/deeplinks/observability/deep_links.ts @@ -43,7 +43,12 @@ export type ObservabilityOverviewLinkId = | 'rules' | 'slos'; -export type MetricsLinkId = 'inventory' | 'metrics-explorer' | 'hosts' | 'settings'; +export type MetricsLinkId = + | 'inventory' + | 'metrics-explorer' + | 'hosts' + | 'settings' + | 'assetDetails'; export type ApmLinkId = | 'services' diff --git a/x-pack/plugins/infra/kibana.jsonc b/x-pack/plugins/infra/kibana.jsonc index 5faf928f7d959..dbabc92fd69c7 100644 --- a/x-pack/plugins/infra/kibana.jsonc +++ b/x-pack/plugins/infra/kibana.jsonc @@ -36,7 +36,17 @@ "visTypeTimeseries", "apmDataAccess" ], - "optionalPlugins": ["spaces", "ml", "home", "embeddable", "osquery", "cloud", "profilingDataAccess", "licenseManagement"], + "optionalPlugins": [ + "spaces", + "ml", + "home", + "embeddable", + "osquery", + "cloud", + "profilingDataAccess", + "licenseManagement", + "serverless" + ], "requiredBundles": [ "unifiedSearch", "observability", @@ -46,7 +56,7 @@ "kibanaReact", "ml", "embeddable", - "controls", + "controls" ] } } diff --git a/x-pack/plugins/infra/public/components/asset_details/template/page.tsx b/x-pack/plugins/infra/public/components/asset_details/template/page.tsx index 260114bb8b11f..07d91a5e0e862 100644 --- a/x-pack/plugins/infra/public/components/asset_details/template/page.tsx +++ b/x-pack/plugins/infra/public/components/asset_details/template/page.tsx @@ -5,10 +5,12 @@ * 2.0. */ -import { EuiFlexGroup, EuiPageTemplate } from '@elastic/eui'; +import { EuiFlexGroup } from '@elastic/eui'; import { css } from '@emotion/react'; import { i18n } from '@kbn/i18n'; import React, { useEffect, useMemo } from 'react'; +import { useMetricsBreadcrumbs } from '../../../hooks/use_metrics_breadcrumbs'; +import { useParentBreadcrumbResolver } from '../../../hooks/use_parent_breadcrumb_resolver'; import { useKibanaContextForPlugin } from '../../../hooks/use_kibana'; import { useKibanaHeader } from '../../../hooks/use_kibana_header'; import { InfraLoadingPanel } from '../../loading'; @@ -24,16 +26,36 @@ import { getIntegrationsAvailable } from '../utils'; export const Page = ({ tabs = [], links = [] }: ContentTemplateProps) => { const { loading } = useAssetDetailsRenderPropsContext(); const { metadata, loading: metadataLoading } = useMetadataStateContext(); - const { rightSideItems, tabEntries, breadcrumbs } = usePageHeader(tabs, links); + const { rightSideItems, tabEntries, breadcrumbs: headerBreadcrumbs } = usePageHeader(tabs, links); const { asset } = useAssetDetailsRenderPropsContext(); const { actionMenuHeight } = useKibanaHeader(); const trackOnlyOnce = React.useRef(false); const { activeTabId } = useTabSwitcherContext(); const { - services: { telemetry }, + services: { + telemetry, + observabilityShared: { + navigation: { PageTemplate }, + }, + }, } = useKibanaContextForPlugin(); + const parentBreadcrumbResolver = useParentBreadcrumbResolver(); + const breadcrumbOptions = parentBreadcrumbResolver.getBreadcrumbOptions(asset.type); + useMetricsBreadcrumbs( + [ + { + ...breadcrumbOptions.link, + text: breadcrumbOptions.text, + }, + { + text: asset.name, + }, + ], + { deeperContextServerless: true } + ); + useEffect(() => { if (trackOnlyOnce.current) { return; @@ -63,44 +85,35 @@ export const Page = ({ tabs = [], links = [] }: ContentTemplateProps) => { [actionMenuHeight] ); - return loading ? ( - - - - ) : ( - - - - - - - - + {loading ? ( + + + + ) : ( + + )} + ); }; diff --git a/x-pack/plugins/infra/public/hooks/use_kibana.tsx b/x-pack/plugins/infra/public/hooks/use_kibana.tsx index 25ef6595c734a..e62d6fbbc4e3c 100644 --- a/x-pack/plugins/infra/public/hooks/use_kibana.tsx +++ b/x-pack/plugins/infra/public/hooks/use_kibana.tsx @@ -6,7 +6,7 @@ */ import type { PropsOf } from '@elastic/eui'; -import React, { useMemo, createElement, createContext } from 'react'; +import React, { useMemo, createElement, createContext, useContext } from 'react'; import { CoreStart } from '@kbn/core/public'; import { createKibanaReactContext, @@ -73,6 +73,10 @@ export const useKibanaEnvironmentContextProvider = (kibanaEnvironment?: KibanaEn return Provider; }; +export function useKibanaEnvironmentContext() { + return useContext(KibanaEnvironmentContext); +} + export const createLazyComponentWithKibanaContext = >( coreSetup: InfraClientCoreSetup, lazyComponentFactory: () => Promise<{ default: T }> diff --git a/x-pack/plugins/infra/public/hooks/use_metrics_breadcrumbs.tsx b/x-pack/plugins/infra/public/hooks/use_metrics_breadcrumbs.tsx index 4679d4fe67f7e..defc8b3210f48 100644 --- a/x-pack/plugins/infra/public/hooks/use_metrics_breadcrumbs.tsx +++ b/x-pack/plugins/infra/public/hooks/use_metrics_breadcrumbs.tsx @@ -5,11 +5,42 @@ * 2.0. */ +import { useEffect, useMemo } from 'react'; import { ChromeBreadcrumb } from '@kbn/core/public'; -import { useBreadcrumbs } from './use_breadcrumbs'; +import { useBreadcrumbs, useLinkProps } from '@kbn/observability-shared-plugin/public'; import { METRICS_APP } from '../../common/constants'; import { metricsTitle } from '../translations'; +import { useKibanaContextForPlugin } from './use_kibana'; -export const useMetricsBreadcrumbs = (extraCrumbs: ChromeBreadcrumb[]) => { - useBreadcrumbs(METRICS_APP, metricsTitle, extraCrumbs); +export const useMetricsBreadcrumbs = ( + extraCrumbs: ChromeBreadcrumb[], + options?: { deeperContextServerless: boolean } +) => { + const { + services: { serverless }, + } = useKibanaContextForPlugin(); + const appLinkProps = useLinkProps({ app: METRICS_APP }); + + const breadcrumbs = useMemo( + () => [ + { + ...appLinkProps, + text: metricsTitle, + }, + ...extraCrumbs, + ], + [appLinkProps, extraCrumbs] + ); + + useBreadcrumbs(breadcrumbs); + + useEffect(() => { + // For deeper context breadcrumbs in serveless, the `serverless` plugin provides its own breadcrumb service. + // https://docs.elastic.dev/kibana-dev-docs/serverless-project-navigation#breadcrumbs + if (serverless && options?.deeperContextServerless) { + // The initial path is already set in the breadcrumbs + const [, ...serverlessBreadcrumbs] = breadcrumbs; + serverless.setBreadcrumbs(serverlessBreadcrumbs); + } + }, [breadcrumbs, options?.deeperContextServerless, serverless]); }; diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_parent_breadcrumb_resolver.ts b/x-pack/plugins/infra/public/hooks/use_parent_breadcrumb_resolver.ts similarity index 88% rename from x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_parent_breadcrumb_resolver.ts rename to x-pack/plugins/infra/public/hooks/use_parent_breadcrumb_resolver.ts index a0d5160e87472..532d3dbe00adb 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_parent_breadcrumb_resolver.ts +++ b/x-pack/plugins/infra/public/hooks/use_parent_breadcrumb_resolver.ts @@ -8,13 +8,18 @@ import { InventoryItemType } from '@kbn/metrics-data-access-plugin/common/inventory_models/types'; import { useLinkProps } from '@kbn/observability-shared-plugin/public'; import { useLocation } from 'react-router-dom'; -import { hostsTitle, inventoryTitle } from '../../../../translations'; -import { BreadcrumbOptions } from '../types'; +import type { LinkProps } from '@kbn/observability-shared-plugin/public/hooks/use_link_props'; +import { hostsTitle, inventoryTitle } from '../translations'; interface LocationStateProps { originPathname: string; } +interface BreadcrumbOptions { + text: string; + link: LinkProps; +} + export function useParentBreadcrumbResolver() { const hostsLinkProps = useLinkProps({ app: 'metrics', diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/search_bar/unified_search_bar.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/search_bar/unified_search_bar.tsx index 4c5b5fef264c5..e21ca872726f5 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/search_bar/unified_search_bar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/search_bar/unified_search_bar.tsx @@ -111,7 +111,7 @@ const StickyContainer = ({ children }: { children: React.ReactNode }) => { top: calc(${actionMenuHeight}px + var(--euiFixedHeadersOffset, 0)); z-index: ${euiTheme.levels.navigation}; background: ${euiTheme.colors.emptyShade}; - padding: ${euiTheme.size.m} ${euiTheme.size.l} 0px; + padding: ${euiTheme.size.l} ${euiTheme.size.l} 0px; margin: -${euiTheme.size.l} -${euiTheme.size.l} 0px; min-height: calc(${euiTheme.size.xxxl} * 2); `} diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/index.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/index.tsx index 4e97a99e37553..80dc5a3977c75 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/index.tsx @@ -6,12 +6,12 @@ */ import { EuiErrorBoundary } from '@elastic/eui'; -import React, { useContext } from 'react'; +import React from 'react'; import { useTrackPageview, FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; import { APP_WRAPPER_CLASS } from '@kbn/core/public'; import { css } from '@emotion/react'; import { i18n } from '@kbn/i18n'; -import { KibanaEnvironmentContext } from '../../../hooks/use_kibana'; +import { useKibanaEnvironmentContext } from '../../../hooks/use_kibana'; import { SourceErrorPage } from '../../../components/source_error_page'; import { SourceLoadingPage } from '../../../components/source_loading_page'; import { useSourceContext } from '../../../containers/metrics_source'; @@ -29,7 +29,7 @@ const HOSTS_FEEDBACK_LINK = export const HostsPage = () => { const { isLoading, loadSourceFailureMessage, loadSource, source } = useSourceContext(); - const { kibanaVersion, isCloudEnv, isServerlessEnv } = useContext(KibanaEnvironmentContext); + const { kibanaVersion, isCloudEnv, isServerlessEnv } = useKibanaEnvironmentContext(); useTrackPageview({ app: 'infra_metrics', path: 'hosts' }); useTrackPageview({ app: 'infra_metrics', path: 'hosts', delay: 15000 }); diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_kubernetes.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_kubernetes.tsx index ce36a396b150f..4dd620553df51 100644 --- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_kubernetes.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_kubernetes.tsx @@ -6,11 +6,11 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiGlobalToastList } from '@elastic/eui'; -import React, { useContext } from 'react'; +import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import useLocalStorage from 'react-use/lib/useLocalStorage'; import { FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; -import { KibanaEnvironmentContext } from '../../../../hooks/use_kibana'; +import { useKibanaEnvironmentContext } from '../../../../hooks/use_kibana'; const KUBERNETES_TOAST_STORAGE_KEY = 'kubernetesToastKey'; const KUBERNETES_FEEDBACK_LINK = 'https://ela.st/k8s-feedback'; @@ -19,7 +19,7 @@ export const SurveyKubernetes = () => { const [isToastSeen, setIsToastSeen] = useLocalStorage(KUBERNETES_TOAST_STORAGE_KEY, false); const markToastAsSeen = () => setIsToastSeen(true); - const { kibanaVersion, isCloudEnv, isServerlessEnv } = useContext(KibanaEnvironmentContext); + const { kibanaVersion, isCloudEnv, isServerlessEnv } = useKibanaEnvironmentContext(); return ( <> diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_section.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_section.tsx index d32fd722c8391..6bdfc9dbfe2e3 100644 --- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_section.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/survey_section.tsx @@ -5,9 +5,9 @@ * 2.0. */ -import React, { useContext } from 'react'; +import React from 'react'; import { FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; -import { KibanaEnvironmentContext } from '../../../../hooks/use_kibana'; +import { useKibanaEnvironmentContext } from '../../../../hooks/use_kibana'; import { useWaffleOptionsContext } from '../hooks/use_waffle_options'; import { SurveyKubernetes } from './survey_kubernetes'; @@ -16,7 +16,7 @@ const INVENTORY_FEEDBACK_LINK = 'https://ela.st/survey-infra-inventory?usp=pp_ur export const SurveySection = () => { const { nodeType } = useWaffleOptionsContext(); - const { kibanaVersion, isCloudEnv, isServerlessEnv } = useContext(KibanaEnvironmentContext); + const { kibanaVersion, isCloudEnv, isServerlessEnv } = useKibanaEnvironmentContext(); return ( <> diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/asset_detail_page.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/asset_detail_page.tsx index 7414d2ab4bf93..c89c9bafed5f4 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/asset_detail_page.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/asset_detail_page.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { useRouteMatch } from 'react-router-dom'; import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; -import { useMetricsBreadcrumbs } from '../../../hooks/use_metrics_breadcrumbs'; import { NoRemoteCluster } from '../../../components/empty_states'; import { SourceErrorPage } from '../../../components/source_error_page'; import { SourceLoadingPage } from '../../../components/source_loading_page'; @@ -16,7 +15,6 @@ import { useSourceContext } from '../../../containers/metrics_source'; import { AssetDetails } from '../../../components/asset_details/asset_details'; import { MetricsPageTemplate } from '../page_template'; import { commonFlyoutTabs } from '../../../common/asset_details_config/asset_details_tabs'; -import { useParentBreadcrumbResolver } from './hooks/use_parent_breadcrumb_resolver'; export const AssetDetailPage = () => { const { isLoading, loadSourceFailureMessage, loadSource, source } = useSourceContext(); @@ -26,19 +24,6 @@ export const AssetDetailPage = () => { const { metricIndicesExist, remoteClustersExist } = source?.status ?? {}; - const parentBreadcrumbResolver = useParentBreadcrumbResolver(); - - const breadcrumbOptions = parentBreadcrumbResolver.getBreadcrumbOptions(nodeType); - useMetricsBreadcrumbs([ - { - ...breadcrumbOptions.link, - text: breadcrumbOptions.text, - }, - { - text: nodeId, - }, - ]); - if (isLoading || !source) return ; if (!remoteClustersExist) { @@ -55,21 +40,14 @@ export const AssetDetailPage = () => { return ; return ( - - - + metricAlias={source.configuration.metricAlias} + /> ); }; diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx index 24fb24af5c982..04405fee76b2d 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx @@ -16,7 +16,7 @@ import { MetricsTimeProvider } from './hooks/use_metrics_time'; export const NodeDetail = () => { const { params: { type: nodeType }, - } = useRouteMatch<{ type: InventoryItemType }>(); + } = useRouteMatch<{ type: InventoryItemType; node: string }>(); return ( diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/metric_detail_page.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/metric_detail_page.tsx index 9e51d316dd0ec..39553f849842f 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/metric_detail_page.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/metric_detail_page.tsx @@ -11,7 +11,7 @@ import { useRouteMatch } from 'react-router-dom'; import { findInventoryModel } from '@kbn/metrics-data-access-plugin/common'; import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; import { useMetricsBreadcrumbs } from '../../../hooks/use_metrics_breadcrumbs'; -import { useParentBreadcrumbResolver } from './hooks/use_parent_breadcrumb_resolver'; +import { useParentBreadcrumbResolver } from '../../../hooks/use_parent_breadcrumb_resolver'; import { useMetadata } from '../../../components/asset_details/hooks/use_metadata'; import { useSourceContext } from '../../../containers/metrics_source'; import { InfraLoadingPanel } from '../../../components/loading'; @@ -53,15 +53,18 @@ export const MetricDetailPage = () => { }); const breadcrumbOptions = parentBreadcrumbResolver.getBreadcrumbOptions(nodeType); - useMetricsBreadcrumbs([ - { - ...breadcrumbOptions.link, - text: breadcrumbOptions.text, - }, - { - text: name, - }, - ]); + useMetricsBreadcrumbs( + [ + { + ...breadcrumbOptions.link, + text: breadcrumbOptions.text, + }, + { + text: name, + }, + ], + { deeperContextServerless: true } + ); const [sideNav, setSideNav] = useState([]); diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts index 545b09c2fe00e..2cf5c8844d726 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts @@ -8,7 +8,6 @@ import rt from 'io-ts'; import { EuiTheme } from '@kbn/kibana-react-plugin/common'; import { InventoryFormatterTypeRT } from '@kbn/metrics-data-access-plugin/common'; -import { LinkProps } from '@kbn/observability-shared-plugin/public/hooks/use_link_props'; import { MetricsTimeInput } from './hooks/use_metrics_time'; import { NodeDetailsMetricData } from '../../../../common/http_api/node_details_api'; @@ -62,8 +61,3 @@ export type VisSectionProps = rt.TypeOf & { isLiveStreaming?: boolean; stopLiveStreaming?: () => void; }; - -export interface BreadcrumbOptions { - text: string; - link: LinkProps; -} diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx index d7764c14c4364..b1cea81cec052 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx @@ -7,9 +7,9 @@ import { EuiErrorBoundary } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React, { useContext, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { useTrackPageview, FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public'; -import { KibanaEnvironmentContext } from '../../../hooks/use_kibana'; +import { useKibanaEnvironmentContext } from '../../../hooks/use_kibana'; import { SourceLoadingPage } from '../../../components/source_loading_page'; import { useMetricsExplorerViews } from '../../../hooks/use_metrics_explorer_views'; import { MetricsSourceConfigurationProperties } from '../../../../common/metrics_sources'; @@ -52,7 +52,7 @@ export const MetricsExplorerPage = ({ source, derivedIndexPattern }: MetricsExpl } = useMetricsExplorerState(source, derivedIndexPattern, enabled); const { currentView } = useMetricsExplorerViews(); const { source: sourceContext, metricIndicesExist } = useSourceContext(); - const { kibanaVersion, isCloudEnv, isServerlessEnv } = useContext(KibanaEnvironmentContext); + const { kibanaVersion, isCloudEnv, isServerlessEnv } = useKibanaEnvironmentContext(); useTrackPageview({ app: 'infra_metrics', path: 'metrics_explorer' }); useTrackPageview({ app: 'infra_metrics', path: 'metrics_explorer', delay: 15000 }); diff --git a/x-pack/plugins/infra/public/plugin.ts b/x-pack/plugins/infra/public/plugin.ts index b406f29fccd4d..9a42e728bacda 100644 --- a/x-pack/plugins/infra/public/plugin.ts +++ b/x-pack/plugins/infra/public/plugin.ts @@ -290,6 +290,12 @@ export class Plugin implements InfraClientPluginClass { }), path: '/settings', }, + { + id: 'assetDetails', + title: '', // Internal deep link, not shown in the UI. Title is dynamically set in the app. + path: '/detail', + visibleIn: [], + }, ]; }; diff --git a/x-pack/plugins/infra/public/types.ts b/x-pack/plugins/infra/public/types.ts index fe125a278d8cf..f2069c215687f 100644 --- a/x-pack/plugins/infra/public/types.ts +++ b/x-pack/plugins/infra/public/types.ts @@ -47,6 +47,7 @@ import { LicensingPluginSetup, LicensingPluginStart } from '@kbn/licensing-plugi import { ObservabilityAIAssistantPluginStart } from '@kbn/observability-ai-assistant-plugin/public'; import type { CloudSetup } from '@kbn/cloud-plugin/public'; import type { LicenseManagementUIPluginSetup } from '@kbn/license-management-plugin/public'; +import type { ServerlessPluginStart } from '@kbn/serverless/public'; import type { UnwrapPromise } from '../common/utility_types'; import { InventoryViewsServiceStart } from './services/inventory_views'; import { MetricsExplorerViewsServiceStart } from './services/metrics_explorer_views'; @@ -100,6 +101,7 @@ export interface InfraClientStartDeps { share: SharePluginStart; spaces: SpacesPluginStart; storage: IStorageWrapper; + serverless?: ServerlessPluginStart; triggersActionsUi: TriggersAndActionsUIPublicPluginStart; uiActions: UiActionsStart; unifiedSearch: UnifiedSearchPublicPluginStart; diff --git a/x-pack/plugins/infra/tsconfig.json b/x-pack/plugins/infra/tsconfig.json index acce31a2e36fe..a14063ef6aec7 100644 --- a/x-pack/plugins/infra/tsconfig.json +++ b/x-pack/plugins/infra/tsconfig.json @@ -86,6 +86,7 @@ "@kbn/core-ui-settings-browser", "@kbn/core-saved-objects-api-server", "@kbn/securitysolution-io-ts-utils", + "@kbn/serverless", "@kbn/core-lifecycle-server", "@kbn/elastic-agent-utils" ], diff --git a/x-pack/plugins/serverless_observability/public/navigation_tree.ts b/x-pack/plugins/serverless_observability/public/navigation_tree.ts index dd36baefdb103..4a1a180f0cc2a 100644 --- a/x-pack/plugins/serverless_observability/public/navigation_tree.ts +++ b/x-pack/plugins/serverless_observability/public/navigation_tree.ts @@ -155,6 +155,10 @@ export const navigationTree: NavigationTreeDefinition = { return pathNameSerialized.startsWith(prepend('/app/apm/dependencies')); }, }, + { + link: 'apm:settings', + sideNavStatus: 'hidden', // only to be considered in the breadcrumbs + }, ], }, { @@ -176,6 +180,14 @@ export const navigationTree: NavigationTreeDefinition = { return pathNameSerialized.startsWith(prepend('/app/metrics/hosts')); }, }, + { + link: 'metrics:settings', + sideNavStatus: 'hidden', // only to be considered in the breadcrumbs + }, + { + link: 'metrics:assetDetails', + sideNavStatus: 'hidden', // only to be considered in the breadcrumbs + }, ], }, {