Skip to content

Commit

Permalink
[Infra UI] Enable infra nav in serverless (#167049)
Browse files Browse the repository at this point in the history
## Summary

This PR adds the `Infrastructure` item to the serverless side-nav 

_infra enabled_
<img width="1200" alt="image"
src="https://github.com/elastic/kibana/assets/2767137/baaf95ae-2960-4cdc-8d90-c95018d2fa24">


_infra disabled_
<img width="1200" alt="image"
src="https://github.com/elastic/kibana/assets/2767137/386635b3-d095-4f62-9831-a37a723b69c6">

Stateful Kibana isn't affected by this change.

### How to test

- Start a local es instance: `yarn es serverless --kill --clean
--license trial --ssl`
- Enable `infra` in the `serverless.oblt.dev.yml` file:
  - `xpack.infra.enabled: true`
- Start a local kibana instance: `yarn serverless-oblt --ssl` and see if
the side nav contains the Infrastructure item
- Disable infra and check if the side nav does not contain the
infrastructure item.

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
crespocarlos and kibanamachine authored Oct 4, 2023
1 parent 48be97b commit 4c5c6de
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/deeplinks/observability/deep_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type ObservabilityOverviewLinkId =
| 'rules'
| 'slos';

export type MetricsLinkId = 'inventory' | 'metrics-explorer' | 'metrics-hosts' | 'settings';
export type MetricsLinkId = 'inventory' | 'metrics-explorer' | 'hosts' | 'settings';

export type ApmLinkId =
| 'services'
Expand Down
21 changes: 13 additions & 8 deletions x-pack/plugins/infra/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
*/

import {
AppMountParameters,
AppUpdater,
CoreStart,
type AppMountParameters,
type AppUpdater,
type CoreStart,
type AppDeepLink,
AppNavLinkStatus,
DEFAULT_APP_CATEGORIES,
PluginInitializerContext,
} from '@kbn/core/public';
Expand All @@ -17,7 +19,7 @@ import { enableInfrastructureHostsView } from '@kbn/observability-plugin/public'
import { ObservabilityTriggerId } from '@kbn/observability-shared-plugin/common';
import { BehaviorSubject, combineLatest, from } from 'rxjs';
import { map } from 'rxjs/operators';
import { InfraPublicConfig } from '../common/plugin_config_types';
import type { InfraPublicConfig } from '../common/plugin_config_types';
import { createInventoryMetricRuleType } from './alerting/inventory';
import { createLogThresholdRuleType } from './alerting/log_threshold';
import { createMetricThresholdRuleType } from './alerting/metric_threshold';
Expand All @@ -27,7 +29,7 @@ import { createLazyPodMetricsTable } from './components/infrastructure_node_metr
import { LOG_STREAM_EMBEDDABLE } from './components/log_stream/log_stream_embeddable';
import { LogStreamEmbeddableFactoryDefinition } from './components/log_stream/log_stream_embeddable_factory';
import {
InfraLocators,
type InfraLocators,
LogsLocatorDefinition,
NodeLogsLocatorDefinition,
} from '../common/locators';
Expand All @@ -36,7 +38,7 @@ import { registerFeatures } from './register_feature';
import { InventoryViewsService } from './services/inventory_views';
import { MetricsExplorerViewsService } from './services/metrics_explorer_views';
import { TelemetryService } from './services/telemetry';
import {
import type {
InfraClientCoreSetup,
InfraClientCoreStart,
InfraClientPluginClass,
Expand Down Expand Up @@ -220,20 +222,22 @@ export class Plugin implements InfraClientPluginClass {
});

// !! Need to be kept in sync with the routes in x-pack/plugins/infra/public/pages/metrics/index.tsx
const infraDeepLinks = [
const infraDeepLinks: AppDeepLink[] = [
{
id: 'inventory',
title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', {
defaultMessage: 'Inventory',
}),
path: '/inventory',
navLinkStatus: AppNavLinkStatus.visible,
},
{
id: 'metrics-hosts',
id: 'hosts',
title: i18n.translate('xpack.infra.homePage.metricsHostsTabTitle', {
defaultMessage: 'Hosts',
}),
path: '/hosts',
navLinkStatus: AppNavLinkStatus.visible,
},
...(this.config.featureFlags.metricsExplorerEnabled
? [
Expand All @@ -254,6 +258,7 @@ export class Plugin implements InfraClientPluginClass {
path: '/settings',
},
];

core.application.register({
id: 'metrics',
title: i18n.translate('xpack.infra.metrics.pluginTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ const navigationTree: NavigationTreeDefinition = {
},
],
},
{
id: 'metrics',
title: i18n.translate('xpack.serverlessObservability.nav.infrastructure', {
defaultMessage: 'Infrastructure',
}),
accordionProps: {
arrowProps: { css: { display: 'none' } },
},
children: [
{
link: 'metrics:inventory',
getIsActive: ({ pathNameSerialized, prepend }) => {
return pathNameSerialized.startsWith(prepend('/app/metrics/inventory'));
},
},
{
link: 'metrics:hosts',
getIsActive: ({ pathNameSerialized, prepend }) => {
return pathNameSerialized.startsWith(prepend('/app/metrics/hosts'));
},
},
],
},
{
id: 'groups-spacer-2',
isGroupTitle: true,
Expand Down

0 comments on commit 4c5c6de

Please sign in to comment.