From 2c6d4f053812008dc11335c119f5f0ee39fc1910 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Thu, 27 Apr 2023 17:01:53 -0400 Subject: [PATCH 1/7] [serverless] Create Observability Serverless plugin --- .github/CODEOWNERS | 1 + config/serverless.oblt.yml | 17 +++++++++- docs/developer/plugin-list.asciidoc | 4 +++ package.json | 1 + packages/kbn-optimizer/limits.yml | 1 + tsconfig.base.json | 2 ++ .../page_template/lazy_page_template.tsx | 28 ++++++++++----- .../page_template/page_template.test.tsx | 1 + .../shared/page_template/page_template.tsx | 8 +++-- x-pack/plugins/observability/tsconfig.json | 7 ++-- .../page_template/lazy_page_template.tsx | 29 +++++++++++----- .../page_template/page_template.test.tsx | 3 ++ .../page_template/page_template.tsx | 8 +++-- .../observability_shared/public/plugin.ts | 3 +- .../serverless_observability/.gitignore | 2 ++ .../serverless_observability/README.mdx | 3 ++ .../serverless_observability/common/index.ts | 9 +++++ .../serverless_observability/kibana.jsonc | 22 ++++++++++++ .../serverless_observability/package.json | 11 ++++++ .../serverless_observability/public/index.ts | 19 +++++++++++ .../serverless_observability/public/plugin.ts | 34 +++++++++++++++++++ .../serverless_observability/public/types.ts | 28 +++++++++++++++ .../serverless_observability/server/config.ts | 23 +++++++++++++ .../serverless_observability/server/index.ts | 23 +++++++++++++ .../serverless_observability/server/plugin.ts | 26 ++++++++++++++ .../serverless_observability/server/types.ts | 11 ++++++ .../serverless_observability/tsconfig.json | 23 +++++++++++++ yarn.lock | 4 +++ 28 files changed, 327 insertions(+), 24 deletions(-) create mode 100644 x-pack/plugins/serverless_observability/.gitignore create mode 100755 x-pack/plugins/serverless_observability/README.mdx create mode 100644 x-pack/plugins/serverless_observability/common/index.ts create mode 100644 x-pack/plugins/serverless_observability/kibana.jsonc create mode 100644 x-pack/plugins/serverless_observability/package.json create mode 100644 x-pack/plugins/serverless_observability/public/index.ts create mode 100644 x-pack/plugins/serverless_observability/public/plugin.ts create mode 100644 x-pack/plugins/serverless_observability/public/types.ts create mode 100644 x-pack/plugins/serverless_observability/server/config.ts create mode 100644 x-pack/plugins/serverless_observability/server/index.ts create mode 100644 x-pack/plugins/serverless_observability/server/plugin.ts create mode 100644 x-pack/plugins/serverless_observability/server/types.ts create mode 100644 x-pack/plugins/serverless_observability/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d76ed31b2b2b1..feb79fee692f2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -573,6 +573,7 @@ packages/kbn-securitysolution-utils @elastic/security-solution-platform packages/kbn-server-http-tools @elastic/kibana-core packages/kbn-server-route-repository @elastic/apm-ui x-pack/plugins/serverless @elastic/appex-sharedux +x-pack/plugins/serverless_observability @elastic/appex-sharedux @elastic/observability-ui packages/serverless/project_switcher @elastic/appex-sharedux packages/serverless/storybook/config @elastic/appex-sharedux packages/serverless/types @elastic/appex-sharedux diff --git a/config/serverless.oblt.yml b/config/serverless.oblt.yml index dd62007fa0dfb..5b9bb95c22cce 100644 --- a/config/serverless.oblt.yml +++ b/config/serverless.oblt.yml @@ -1,3 +1,18 @@ -uiSettings.overrides.defaultRoute: /app/observability/overview +# Observability Project config + +## Disable plugins +enterpriseSearch.enabled: false +xpack.cloudSecurityPosture.enabled: false +xpack.securitySolution.enabled: false + +## Enable the Serverless Obsersability plugin +xpack.serverless.observability.enabled: true + +## Configure plugins xpack.infra.logs.app_target: discover + +## Set the home route +uiSettings.overrides.defaultRoute: /app/observability/overview + +## Set the dev project switch current type xpack.serverless.plugin.developer.projectSwitcher.currentType: 'observability' diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 412a9e8b5569e..6be97fa216c90 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -710,6 +710,10 @@ Kibana. | +|{kib-repo}blob/{branch}/x-pack/plugins/serverless_observability/README.md[serverlessObservability] +|A witty, fitting description to come. + + |{kib-repo}blob/{branch}/x-pack/plugins/session_view/README.md[sessionView] |Session View is meant to provide a visualization into what is going on in a particular Linux environment where the agent is running. It looks likes a terminal emulator; however, it is a tool for introspecting process activity and understanding user and service behaviour in your Linux servers and infrastructure. It is a time-ordered series of process executions displayed in a tree over time. diff --git a/package.json b/package.json index c43034fb928df..241de0602f449 100644 --- a/package.json +++ b/package.json @@ -575,6 +575,7 @@ "@kbn/server-http-tools": "link:packages/kbn-server-http-tools", "@kbn/server-route-repository": "link:packages/kbn-server-route-repository", "@kbn/serverless": "link:x-pack/plugins/serverless", + "@kbn/serverless-observability": "link:x-pack/plugins/serverless_observability", "@kbn/serverless-project-switcher": "link:packages/serverless/project_switcher", "@kbn/serverless-types": "link:packages/serverless/types", "@kbn/session-notifications-plugin": "link:test/plugin_functional/plugins/session_notifications", diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index af6396c11e063..d035c93b021db 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -116,6 +116,7 @@ pageLoadAssetSize: security: 65433 securitySolution: 66738 serverless: 16573 + serverlessObservability: 16582 sessionView: 77750 share: 71239 snapshotRestore: 79032 diff --git a/tsconfig.base.json b/tsconfig.base.json index f333d6f58b34f..755d55257fb9c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1140,6 +1140,8 @@ "@kbn/server-route-repository/*": ["packages/kbn-server-route-repository/*"], "@kbn/serverless": ["x-pack/plugins/serverless"], "@kbn/serverless/*": ["x-pack/plugins/serverless/*"], + "@kbn/serverless-observability": ["x-pack/plugins/serverless_observability"], + "@kbn/serverless-observability/*": ["x-pack/plugins/serverless_observability/*"], "@kbn/serverless-project-switcher": ["packages/serverless/project_switcher"], "@kbn/serverless-project-switcher/*": ["packages/serverless/project_switcher/*"], "@kbn/serverless-storybook-config": ["packages/serverless/storybook/config"], diff --git a/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx b/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx index 7c61cae4f2c73..e1a54802b2cb5 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx @@ -6,6 +6,7 @@ */ import React from 'react'; +import useObservable from 'react-use/lib/useObservable'; import type { ObservabilityPageTemplateDependencies, WrappedPageTemplateProps, @@ -15,12 +16,23 @@ export const LazyObservabilityPageTemplate = React.lazy(() => import('./page_tem export type LazyObservabilityPageTemplateProps = WrappedPageTemplateProps; -export function createLazyObservabilityPageTemplate( - injectedDeps: ObservabilityPageTemplateDependencies -) { - return (pageTemplateProps: LazyObservabilityPageTemplateProps) => ( - - - - ); +export function createLazyObservabilityPageTemplate({ + getChromeStyle$, + ...injectedDeps +}: ObservabilityPageTemplateDependencies) { + return (pageTemplateProps: LazyObservabilityPageTemplateProps) => { + const chromeStyle = useObservable(getChromeStyle$()); + const { showSolutionNav: showSolutionNavProp, ...props } = pageTemplateProps; + let showSolutionNav = showSolutionNavProp; + + if (chromeStyle === 'project') { + showSolutionNav = false; + } + + return ( + + + + ); + }; } diff --git a/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx b/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx index 2a5324ddb5397..16999680ee828 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx @@ -56,6 +56,7 @@ describe('Page template', () => { navigationSections$: navigationRegistry.sections$, getPageTemplateServices, guidedOnboardingApi: guidedOnboardingMock.createStart().guidedOnboardingApi, + getChromeStyle$: () => of('classic'), }); const component = shallow( diff --git a/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx b/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx index aa6f99d862a4c..13a49ac40ad55 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx @@ -22,6 +22,7 @@ import type { KibanaPageTemplateProps, KibanaPageTemplateKibanaDependencies, } from '@kbn/shared-ux-page-kibana-template'; +import type { ChromeStart } from '@kbn/core-chrome-browser'; import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; import { ObservabilityAppServices } from '../../../application/types'; import type { NavigationSection } from '../../../services/navigation_registry'; @@ -53,9 +54,13 @@ export interface ObservabilityPageTemplateDependencies { navigationSections$: Observable; getPageTemplateServices: () => KibanaPageTemplateKibanaDependencies; guidedOnboardingApi: GuidedOnboardingPluginStart['guidedOnboardingApi']; + getChromeStyle$: ChromeStart['getChromeStyle$']; } -export type ObservabilityPageTemplateProps = ObservabilityPageTemplateDependencies & +export type ObservabilityPageTemplateProps = Omit< + ObservabilityPageTemplateDependencies, + 'getChromeStyle$' +> & WrappedPageTemplateProps; export function ObservabilityPageTemplate({ @@ -76,7 +81,6 @@ export function ObservabilityPageTemplate({ const sections = useObservable(navigationSections$, []); const currentAppId = useObservable(currentAppId$, undefined); const { pathname: currentPath } = useLocation(); - const { services } = useKibana(); const sideNavItems = useMemo>>( diff --git a/x-pack/plugins/observability/tsconfig.json b/x-pack/plugins/observability/tsconfig.json index 016404e8d9d58..6aeaacdd6da60 100644 --- a/x-pack/plugins/observability/tsconfig.json +++ b/x-pack/plugins/observability/tsconfig.json @@ -72,7 +72,10 @@ "@kbn/core-theme-browser", "@kbn/core-elasticsearch-server", "@kbn/observability-shared-plugin", - "@kbn/exploratory-view-plugin" + "@kbn/exploratory-view-plugin", + "@kbn/core-chrome-browser" ], - "exclude": ["target/**/*"] + "exclude": [ + "target/**/*" + ] } diff --git a/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx b/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx index 7c61cae4f2c73..f414128a3a609 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx @@ -6,6 +6,8 @@ */ import React from 'react'; +import useObservable from 'react-use/lib/useObservable'; + import type { ObservabilityPageTemplateDependencies, WrappedPageTemplateProps, @@ -15,12 +17,23 @@ export const LazyObservabilityPageTemplate = React.lazy(() => import('./page_tem export type LazyObservabilityPageTemplateProps = WrappedPageTemplateProps; -export function createLazyObservabilityPageTemplate( - injectedDeps: ObservabilityPageTemplateDependencies -) { - return (pageTemplateProps: LazyObservabilityPageTemplateProps) => ( - - - - ); +export function createLazyObservabilityPageTemplate({ + getChromeStyle$, + ...injectedDeps +}: ObservabilityPageTemplateDependencies) { + return (pageTemplateProps: LazyObservabilityPageTemplateProps) => { + const chromeStyle = useObservable(getChromeStyle$()); + const { showSolutionNav: showSolutionNavProp, ...props } = pageTemplateProps; + let showSolutionNav = showSolutionNavProp; + + if (chromeStyle === 'project') { + showSolutionNav = false; + } + + return ( + + + + ); + }; } diff --git a/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx b/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx index b33925ed09e4b..b5861f502c23e 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx @@ -56,6 +56,7 @@ describe('Page template', () => { navigationSections$: navigationRegistry.sections$, getPageTemplateServices, guidedOnboardingApi: guidedOnboardingMock.createStart().guidedOnboardingApi, + getChromeStyle$: () => of('classic'), }); const component = shallow( @@ -85,6 +86,7 @@ describe('Page template', () => { }} getPageTemplateServices={getPageTemplateServices} guidedOnboardingApi={guidedOnboardingMock.createStart().guidedOnboardingApi} + getChromeStyle$={() => of('classic')} >
Test structure
@@ -107,6 +109,7 @@ describe('Page template', () => { }} getPageTemplateServices={getPageTemplateServices} guidedOnboardingApi={guidedOnboardingMock.createStart().guidedOnboardingApi} + getChromeStyle$={() => of('classic')} >
Test structure
diff --git a/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx b/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx index 696cda97e3e53..f462b926288ea 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx @@ -12,7 +12,7 @@ import React, { useMemo } from 'react'; import { matchPath, useLocation } from 'react-router-dom'; import useObservable from 'react-use/lib/useObservable'; import type { Observable } from 'rxjs'; -import type { ApplicationStart } from '@kbn/core/public'; +import type { ApplicationStart, ChromeStart } from '@kbn/core/public'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { KibanaPageTemplate, @@ -85,9 +85,13 @@ export interface ObservabilityPageTemplateDependencies { navigationSections$: Observable; getPageTemplateServices: () => KibanaPageTemplateKibanaDependencies; guidedOnboardingApi: GuidedOnboardingPluginStart['guidedOnboardingApi']; + getChromeStyle$: ChromeStart['getChromeStyle$']; } -export type ObservabilityPageTemplateProps = ObservabilityPageTemplateDependencies & +export type ObservabilityPageTemplateProps = Omit< + ObservabilityPageTemplateDependencies, + 'getChromeStyle$' +> & WrappedPageTemplateProps; export function ObservabilityPageTemplate({ diff --git a/x-pack/plugins/observability_shared/public/plugin.ts b/x-pack/plugins/observability_shared/public/plugin.ts index 527d33e8a502e..0559ae580de2c 100644 --- a/x-pack/plugins/observability_shared/public/plugin.ts +++ b/x-pack/plugins/observability_shared/public/plugin.ts @@ -30,7 +30,7 @@ export class ObservabilitySharedPlugin implements Plugin { } public start(core: CoreStart, plugins: ObservabilitySharedStart) { - const { application } = core; + const { application, chrome } = core; const PageTemplate = createLazyObservabilityPageTemplate({ currentAppId$: application.currentAppId$, @@ -39,6 +39,7 @@ export class ObservabilitySharedPlugin implements Plugin { navigationSections$: this.navigationRegistry.sections$, guidedOnboardingApi: plugins.guidedOnboarding.guidedOnboardingApi, getPageTemplateServices: () => ({ coreStart: core }), + getChromeStyle$: chrome.getChromeStyle$, }); return { diff --git a/x-pack/plugins/serverless_observability/.gitignore b/x-pack/plugins/serverless_observability/.gitignore new file mode 100644 index 0000000000000..c3dca1b96fcc2 --- /dev/null +++ b/x-pack/plugins/serverless_observability/.gitignore @@ -0,0 +1,2 @@ +/build +/target diff --git a/x-pack/plugins/serverless_observability/README.mdx b/x-pack/plugins/serverless_observability/README.mdx new file mode 100755 index 0000000000000..fa2dde090f4b7 --- /dev/null +++ b/x-pack/plugins/serverless_observability/README.mdx @@ -0,0 +1,3 @@ +# Serverless Observability project plugin + +This plugin contains configuration and code used to create a Serverless Observability project. It leverages universal configuration and other APIs in the [`serverless`](../serverless/README.mdx) plugin to configure Kibana. \ No newline at end of file diff --git a/x-pack/plugins/serverless_observability/common/index.ts b/x-pack/plugins/serverless_observability/common/index.ts new file mode 100644 index 0000000000000..d6a5ea767034c --- /dev/null +++ b/x-pack/plugins/serverless_observability/common/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export const PLUGIN_ID = 'serverlessObservability'; +export const PLUGIN_NAME = 'serverlessObservability'; diff --git a/x-pack/plugins/serverless_observability/kibana.jsonc b/x-pack/plugins/serverless_observability/kibana.jsonc new file mode 100644 index 0000000000000..abce6cd9e8350 --- /dev/null +++ b/x-pack/plugins/serverless_observability/kibana.jsonc @@ -0,0 +1,22 @@ +{ + "type": "plugin", + "id": "@kbn/serverless-observability", + "owner": "@elastic/appex-sharedux", + "description": "Serverless customizations for observability.", + "plugin": { + "id": "serverlessObservability", + "server": true, + "browser": true, + "configPath": [ + "xpack", + "serverless", + "observability" + ], + "requiredPlugins": [ + "serverless", + "observability" + ], + "optionalPlugins": [], + "requiredBundles": [] + } +} diff --git a/x-pack/plugins/serverless_observability/package.json b/x-pack/plugins/serverless_observability/package.json new file mode 100644 index 0000000000000..64b310d7eabae --- /dev/null +++ b/x-pack/plugins/serverless_observability/package.json @@ -0,0 +1,11 @@ +{ + "name": "@kbn/serverless-observability", + "version": "1.0.0", + "license": "Elastic License 2.0", + "private": true, + "scripts": { + "build": "yarn plugin-helpers build", + "plugin-helpers": "node ../../../scripts/plugin_helpers", + "kbn": "node ../../../scripts/kbn" + } +} \ No newline at end of file diff --git a/x-pack/plugins/serverless_observability/public/index.ts b/x-pack/plugins/serverless_observability/public/index.ts new file mode 100644 index 0000000000000..a785b68735375 --- /dev/null +++ b/x-pack/plugins/serverless_observability/public/index.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ServerlessObservabilityPlugin } from './plugin'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. +export function plugin() { + return new ServerlessObservabilityPlugin(); +} + +export type { + ServerlessObservabilityPluginSetup, + ServerlessObservabilityPluginStart, +} from './types'; diff --git a/x-pack/plugins/serverless_observability/public/plugin.ts b/x-pack/plugins/serverless_observability/public/plugin.ts new file mode 100644 index 0000000000000..7745257114008 --- /dev/null +++ b/x-pack/plugins/serverless_observability/public/plugin.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import { + ServerlessObservabilityPluginSetup, + ServerlessObservabilityPluginStart, + ServerlessObservabilityPluginSetupDependencies, + ServerlessObservabilityPluginStartDependencies, +} from './types'; + +export class ServerlessObservabilityPlugin + implements Plugin +{ + public setup( + _core: CoreSetup, + _setupDeps: ServerlessObservabilityPluginSetupDependencies + ): ServerlessObservabilityPluginSetup { + return {}; + } + + public start( + _core: CoreStart, + { serverless }: ServerlessObservabilityPluginStartDependencies + ): ServerlessObservabilityPluginStart { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless_observability/public/types.ts b/x-pack/plugins/serverless_observability/public/types.ts new file mode 100644 index 0000000000000..e0fca61302ad7 --- /dev/null +++ b/x-pack/plugins/serverless_observability/public/types.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ServerlessPluginSetup, ServerlessPluginStart } from '@kbn/serverless/public'; +import { + ObservabilityPublicSetup, + ObservabilityPublicStart, +} from '@kbn/observability-plugin/public'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginStart {} + +export interface ServerlessObservabilityPluginSetupDependencies { + observability: ObservabilityPublicSetup; + serverless: ServerlessPluginSetup; +} + +export interface ServerlessObservabilityPluginStartDependencies { + observability: ObservabilityPublicStart; + serverless: ServerlessPluginStart; +} diff --git a/x-pack/plugins/serverless_observability/server/config.ts b/x-pack/plugins/serverless_observability/server/config.ts new file mode 100644 index 0000000000000..599a9f2bd7769 --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/config.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { schema, TypeOf } from '@kbn/config-schema'; +import { PluginConfigDescriptor } from '@kbn/core/server'; + +export * from './types'; + +const configSchema = schema.object({ + enabled: schema.boolean({ defaultValue: false }), +}); + +type ConfigType = TypeOf; + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; + +export type ServerlessObservabilityConfig = TypeOf; diff --git a/x-pack/plugins/serverless_observability/server/index.ts b/x-pack/plugins/serverless_observability/server/index.ts new file mode 100644 index 0000000000000..c45e363a429bf --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { PluginInitializerContext } from '@kbn/core/server'; + +import { ServerlessObservabilityPlugin } from './plugin'; +export { config } from './config'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. + +export function plugin(initializerContext: PluginInitializerContext) { + return new ServerlessObservabilityPlugin(initializerContext); +} + +export type { + ServerlessObservabilityPluginSetup, + ServerlessObservabilityPluginStart, +} from './types'; diff --git a/x-pack/plugins/serverless_observability/server/plugin.ts b/x-pack/plugins/serverless_observability/server/plugin.ts new file mode 100644 index 0000000000000..8b28ba2b0a4ac --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/plugin.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { PluginInitializerContext, Plugin } from '@kbn/core/server'; + +import { ServerlessObservabilityPluginSetup, ServerlessObservabilityPluginStart } from './types'; + +export class ServerlessObservabilityPlugin + implements Plugin +{ + constructor(_initializerContext: PluginInitializerContext) {} + + public setup() { + return {}; + } + + public start() { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/serverless_observability/server/types.ts b/x-pack/plugins/serverless_observability/server/types.ts new file mode 100644 index 0000000000000..f8a587103e886 --- /dev/null +++ b/x-pack/plugins/serverless_observability/server/types.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginSetup {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ServerlessObservabilityPluginStart {} diff --git a/x-pack/plugins/serverless_observability/tsconfig.json b/x-pack/plugins/serverless_observability/tsconfig.json new file mode 100644 index 0000000000000..8c9ec19e4736a --- /dev/null +++ b/x-pack/plugins/serverless_observability/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + "../../../typings/**/*" + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/config-schema", + "@kbn/observability-plugin", + "@kbn/serverless", + ] +} diff --git a/yarn.lock b/yarn.lock index d8fe1cb566adc..4f70f8c4f195d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5012,6 +5012,10 @@ "@kbn/server-route-repository@link:packages/kbn-server-route-repository": version "0.0.0" uid "" + +"@kbn/serverless-observability@link:x-pack/plugins/serverless_observability": + version "0.0.0" + uid "" "@kbn/serverless-project-switcher@link:packages/serverless/project_switcher": version "0.0.0" From febe85b0dad4aba35eb2903af4c5c733492e85ce Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:12:35 +0000 Subject: [PATCH 2/7] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index feb79fee692f2..e8d16fb7b08a0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -573,7 +573,7 @@ packages/kbn-securitysolution-utils @elastic/security-solution-platform packages/kbn-server-http-tools @elastic/kibana-core packages/kbn-server-route-repository @elastic/apm-ui x-pack/plugins/serverless @elastic/appex-sharedux -x-pack/plugins/serverless_observability @elastic/appex-sharedux @elastic/observability-ui +x-pack/plugins/serverless_observability @elastic/appex-sharedux packages/serverless/project_switcher @elastic/appex-sharedux packages/serverless/storybook/config @elastic/appex-sharedux packages/serverless/types @elastic/appex-sharedux From b1136b2bcd0c962acea22db1b4cb2379366d5d08 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:19:31 +0000 Subject: [PATCH 3/7] [CI] Auto-commit changed files from 'node scripts/build_plugin_list_docs' --- docs/developer/plugin-list.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 6be97fa216c90..6748c203cfab4 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -710,8 +710,8 @@ Kibana. | -|{kib-repo}blob/{branch}/x-pack/plugins/serverless_observability/README.md[serverlessObservability] -|A witty, fitting description to come. +|{kib-repo}blob/{branch}/x-pack/plugins/serverless_observability/README.mdx[serverlessObservability] +|This plugin contains configuration and code used to create a Serverless Observability project. It leverages universal configuration and other APIs in the serverless plugin to configure Kibana. |{kib-repo}blob/{branch}/x-pack/plugins/session_view/README.md[sessionView] From 04eafecba142b0939e2daacc797d0c7e2e58c77e Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Thu, 27 Apr 2023 19:36:27 -0400 Subject: [PATCH 4/7] Fix test --- .../public/components/page_template/page_template.test.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx b/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx index b5861f502c23e..44f1416990da3 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx @@ -86,7 +86,6 @@ describe('Page template', () => { }} getPageTemplateServices={getPageTemplateServices} guidedOnboardingApi={guidedOnboardingMock.createStart().guidedOnboardingApi} - getChromeStyle$={() => of('classic')} >
Test structure
@@ -109,7 +108,6 @@ describe('Page template', () => { }} getPageTemplateServices={getPageTemplateServices} guidedOnboardingApi={guidedOnboardingMock.createStart().guidedOnboardingApi} - getChromeStyle$={() => of('classic')} >
Test structure
From 0eaed17a11c258a3300cc1b2d2c694f559557f44 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Fri, 28 Apr 2023 10:51:29 -0400 Subject: [PATCH 5/7] Addressing feedback --- .../page_template/lazy_page_template.tsx | 28 ++++++------------- .../page_template/page_template.test.tsx | 1 - .../shared/page_template/page_template.tsx | 8 ++---- x-pack/plugins/observability/tsconfig.json | 7 ++--- .../page_template/lazy_page_template.tsx | 10 ++----- .../page_template/page_template.test.tsx | 4 +-- .../page_template/page_template.tsx | 8 +++--- .../observability_shared/public/plugin.ts | 13 +++++++-- .../serverless_observability/kibana.jsonc | 2 +- .../serverless_observability/public/plugin.ts | 3 +- .../serverless_observability/public/types.ts | 10 +++---- 11 files changed, 40 insertions(+), 54 deletions(-) diff --git a/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx b/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx index e1a54802b2cb5..7c61cae4f2c73 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/lazy_page_template.tsx @@ -6,7 +6,6 @@ */ import React from 'react'; -import useObservable from 'react-use/lib/useObservable'; import type { ObservabilityPageTemplateDependencies, WrappedPageTemplateProps, @@ -16,23 +15,12 @@ export const LazyObservabilityPageTemplate = React.lazy(() => import('./page_tem export type LazyObservabilityPageTemplateProps = WrappedPageTemplateProps; -export function createLazyObservabilityPageTemplate({ - getChromeStyle$, - ...injectedDeps -}: ObservabilityPageTemplateDependencies) { - return (pageTemplateProps: LazyObservabilityPageTemplateProps) => { - const chromeStyle = useObservable(getChromeStyle$()); - const { showSolutionNav: showSolutionNavProp, ...props } = pageTemplateProps; - let showSolutionNav = showSolutionNavProp; - - if (chromeStyle === 'project') { - showSolutionNav = false; - } - - return ( - - - - ); - }; +export function createLazyObservabilityPageTemplate( + injectedDeps: ObservabilityPageTemplateDependencies +) { + return (pageTemplateProps: LazyObservabilityPageTemplateProps) => ( + + + + ); } diff --git a/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx b/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx index 16999680ee828..2a5324ddb5397 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/page_template.test.tsx @@ -56,7 +56,6 @@ describe('Page template', () => { navigationSections$: navigationRegistry.sections$, getPageTemplateServices, guidedOnboardingApi: guidedOnboardingMock.createStart().guidedOnboardingApi, - getChromeStyle$: () => of('classic'), }); const component = shallow( diff --git a/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx b/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx index 13a49ac40ad55..aa6f99d862a4c 100644 --- a/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx +++ b/x-pack/plugins/observability/public/components/shared/page_template/page_template.tsx @@ -22,7 +22,6 @@ import type { KibanaPageTemplateProps, KibanaPageTemplateKibanaDependencies, } from '@kbn/shared-ux-page-kibana-template'; -import type { ChromeStart } from '@kbn/core-chrome-browser'; import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; import { ObservabilityAppServices } from '../../../application/types'; import type { NavigationSection } from '../../../services/navigation_registry'; @@ -54,13 +53,9 @@ export interface ObservabilityPageTemplateDependencies { navigationSections$: Observable; getPageTemplateServices: () => KibanaPageTemplateKibanaDependencies; guidedOnboardingApi: GuidedOnboardingPluginStart['guidedOnboardingApi']; - getChromeStyle$: ChromeStart['getChromeStyle$']; } -export type ObservabilityPageTemplateProps = Omit< - ObservabilityPageTemplateDependencies, - 'getChromeStyle$' -> & +export type ObservabilityPageTemplateProps = ObservabilityPageTemplateDependencies & WrappedPageTemplateProps; export function ObservabilityPageTemplate({ @@ -81,6 +76,7 @@ export function ObservabilityPageTemplate({ const sections = useObservable(navigationSections$, []); const currentAppId = useObservable(currentAppId$, undefined); const { pathname: currentPath } = useLocation(); + const { services } = useKibana(); const sideNavItems = useMemo>>( diff --git a/x-pack/plugins/observability/tsconfig.json b/x-pack/plugins/observability/tsconfig.json index 6aeaacdd6da60..016404e8d9d58 100644 --- a/x-pack/plugins/observability/tsconfig.json +++ b/x-pack/plugins/observability/tsconfig.json @@ -72,10 +72,7 @@ "@kbn/core-theme-browser", "@kbn/core-elasticsearch-server", "@kbn/observability-shared-plugin", - "@kbn/exploratory-view-plugin", - "@kbn/core-chrome-browser" + "@kbn/exploratory-view-plugin" ], - "exclude": [ - "target/**/*" - ] + "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx b/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx index f414128a3a609..8a9a4207c1c95 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx @@ -18,17 +18,13 @@ export const LazyObservabilityPageTemplate = React.lazy(() => import('./page_tem export type LazyObservabilityPageTemplateProps = WrappedPageTemplateProps; export function createLazyObservabilityPageTemplate({ - getChromeStyle$, + isSidebarEnabled$, ...injectedDeps }: ObservabilityPageTemplateDependencies) { return (pageTemplateProps: LazyObservabilityPageTemplateProps) => { - const chromeStyle = useObservable(getChromeStyle$()); + const isSidebarEnabled = useObservable(isSidebarEnabled$); const { showSolutionNav: showSolutionNavProp, ...props } = pageTemplateProps; - let showSolutionNav = showSolutionNavProp; - - if (chromeStyle === 'project') { - showSolutionNav = false; - } + const showSolutionNav = !!showSolutionNavProp && isSidebarEnabled; return ( diff --git a/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx b/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx index 44f1416990da3..3ea28007c207d 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/page_template.test.tsx @@ -9,7 +9,7 @@ import { I18nProvider } from '@kbn/i18n-react'; import { render } from '@testing-library/react'; import { shallow } from 'enzyme'; import React from 'react'; -import { of } from 'rxjs'; +import { BehaviorSubject, of } from 'rxjs'; import { getKibanaPageTemplateKibanaDependenciesMock as getPageTemplateServices } from '@kbn/shared-ux-page-kibana-template-mocks'; import { guidedOnboardingMock } from '@kbn/guided-onboarding-plugin/public/mocks'; @@ -56,7 +56,7 @@ describe('Page template', () => { navigationSections$: navigationRegistry.sections$, getPageTemplateServices, guidedOnboardingApi: guidedOnboardingMock.createStart().guidedOnboardingApi, - getChromeStyle$: () => of('classic'), + isSidebarEnabled$: new BehaviorSubject(true), }); const component = shallow( diff --git a/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx b/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx index f462b926288ea..f2f94ed74e565 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/page_template.tsx @@ -11,8 +11,8 @@ import { i18n } from '@kbn/i18n'; import React, { useMemo } from 'react'; import { matchPath, useLocation } from 'react-router-dom'; import useObservable from 'react-use/lib/useObservable'; -import type { Observable } from 'rxjs'; -import type { ApplicationStart, ChromeStart } from '@kbn/core/public'; +import type { BehaviorSubject, Observable } from 'rxjs'; +import type { ApplicationStart } from '@kbn/core/public'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { KibanaPageTemplate, @@ -85,12 +85,12 @@ export interface ObservabilityPageTemplateDependencies { navigationSections$: Observable; getPageTemplateServices: () => KibanaPageTemplateKibanaDependencies; guidedOnboardingApi: GuidedOnboardingPluginStart['guidedOnboardingApi']; - getChromeStyle$: ChromeStart['getChromeStyle$']; + isSidebarEnabled$: BehaviorSubject; } export type ObservabilityPageTemplateProps = Omit< ObservabilityPageTemplateDependencies, - 'getChromeStyle$' + 'isSidebarEnabled$' > & WrappedPageTemplateProps; diff --git a/x-pack/plugins/observability_shared/public/plugin.ts b/x-pack/plugins/observability_shared/public/plugin.ts index 0559ae580de2c..7a0ee7a452dde 100644 --- a/x-pack/plugins/observability_shared/public/plugin.ts +++ b/x-pack/plugins/observability_shared/public/plugin.ts @@ -5,6 +5,8 @@ * 2.0. */ +import { BehaviorSubject } from 'rxjs'; + import type { CoreStart, Plugin } from '@kbn/core/public'; import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; import { createNavigationRegistry } from './components/page_template/helpers/navigation_registry'; @@ -13,6 +15,7 @@ import { updateGlobalNavigation } from './services/update_global_navigation'; export interface ObservabilitySharedStart { guidedOnboarding: GuidedOnboardingPluginStart; + setIsSidebarEnabled: (isEnabled: boolean) => void; } export type ObservabilitySharedPluginSetup = ReturnType; @@ -20,6 +23,11 @@ export type ObservabilitySharedPluginStart = ReturnType; + + constructor() { + this.isSidebarEnabled$ = new BehaviorSubject(true); + } public setup() { return { @@ -30,7 +38,7 @@ export class ObservabilitySharedPlugin implements Plugin { } public start(core: CoreStart, plugins: ObservabilitySharedStart) { - const { application, chrome } = core; + const { application } = core; const PageTemplate = createLazyObservabilityPageTemplate({ currentAppId$: application.currentAppId$, @@ -39,7 +47,7 @@ export class ObservabilitySharedPlugin implements Plugin { navigationSections$: this.navigationRegistry.sections$, guidedOnboardingApi: plugins.guidedOnboarding.guidedOnboardingApi, getPageTemplateServices: () => ({ coreStart: core }), - getChromeStyle$: chrome.getChromeStyle$, + isSidebarEnabled$: this.isSidebarEnabled$, }); return { @@ -47,6 +55,7 @@ export class ObservabilitySharedPlugin implements Plugin { PageTemplate, }, updateGlobalNavigation, + setIsSidebarEnabled: (isEnabled: boolean) => this.isSidebarEnabled$.next(isEnabled), }; } diff --git a/x-pack/plugins/serverless_observability/kibana.jsonc b/x-pack/plugins/serverless_observability/kibana.jsonc index abce6cd9e8350..12d528dd33ac2 100644 --- a/x-pack/plugins/serverless_observability/kibana.jsonc +++ b/x-pack/plugins/serverless_observability/kibana.jsonc @@ -14,7 +14,7 @@ ], "requiredPlugins": [ "serverless", - "observability" + "observabilityShared" ], "optionalPlugins": [], "requiredBundles": [] diff --git a/x-pack/plugins/serverless_observability/public/plugin.ts b/x-pack/plugins/serverless_observability/public/plugin.ts index 7745257114008..48da91bb4ea26 100644 --- a/x-pack/plugins/serverless_observability/public/plugin.ts +++ b/x-pack/plugins/serverless_observability/public/plugin.ts @@ -25,8 +25,9 @@ export class ServerlessObservabilityPlugin public start( _core: CoreStart, - { serverless }: ServerlessObservabilityPluginStartDependencies + { observabilityShared }: ServerlessObservabilityPluginStartDependencies ): ServerlessObservabilityPluginStart { + observabilityShared.setIsSidebarEnabled(false); return {}; } diff --git a/x-pack/plugins/serverless_observability/public/types.ts b/x-pack/plugins/serverless_observability/public/types.ts index e0fca61302ad7..417a9c1701c84 100644 --- a/x-pack/plugins/serverless_observability/public/types.ts +++ b/x-pack/plugins/serverless_observability/public/types.ts @@ -7,9 +7,9 @@ import { ServerlessPluginSetup, ServerlessPluginStart } from '@kbn/serverless/public'; import { - ObservabilityPublicSetup, - ObservabilityPublicStart, -} from '@kbn/observability-plugin/public'; + ObservabilitySharedPluginSetup, + ObservabilitySharedPluginStart, +} from '@kbn/observability-shared-plugin/public'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ServerlessObservabilityPluginSetup {} @@ -18,11 +18,11 @@ export interface ServerlessObservabilityPluginSetup {} export interface ServerlessObservabilityPluginStart {} export interface ServerlessObservabilityPluginSetupDependencies { - observability: ObservabilityPublicSetup; + observabilityShared: ObservabilitySharedPluginSetup; serverless: ServerlessPluginSetup; } export interface ServerlessObservabilityPluginStartDependencies { - observability: ObservabilityPublicStart; + observabilityShared: ObservabilitySharedPluginStart; serverless: ServerlessPluginStart; } From 5f1e63f4cc90a1e416bcd8f8ec0c5f1b4cb71c21 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 28 Apr 2023 14:58:14 +0000 Subject: [PATCH 6/7] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/serverless_observability/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/serverless_observability/tsconfig.json b/x-pack/plugins/serverless_observability/tsconfig.json index 8c9ec19e4736a..d3cc73ef6a7a6 100644 --- a/x-pack/plugins/serverless_observability/tsconfig.json +++ b/x-pack/plugins/serverless_observability/tsconfig.json @@ -17,7 +17,7 @@ "kbn_references": [ "@kbn/core", "@kbn/config-schema", - "@kbn/observability-plugin", "@kbn/serverless", + "@kbn/observability-shared-plugin", ] } From cf0f9a57e27c0428bd8f321ad3cc94e1115ef97a Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Fri, 28 Apr 2023 13:49:46 -0400 Subject: [PATCH 7/7] Fix typo --- .../public/components/page_template/lazy_page_template.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx b/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx index 8a9a4207c1c95..e61254fa10ca6 100644 --- a/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx +++ b/x-pack/plugins/observability_shared/public/components/page_template/lazy_page_template.tsx @@ -24,7 +24,7 @@ export function createLazyObservabilityPageTemplate({ return (pageTemplateProps: LazyObservabilityPageTemplateProps) => { const isSidebarEnabled = useObservable(isSidebarEnabled$); const { showSolutionNav: showSolutionNavProp, ...props } = pageTemplateProps; - const showSolutionNav = !!showSolutionNavProp && isSidebarEnabled; + const showSolutionNav = !!showSolutionNavProp || isSidebarEnabled; return (