diff --git a/x-pack/plugins/observability_solution/apm/public/application/index.tsx b/x-pack/plugins/observability_solution/apm/public/application/index.tsx index d33a4eec18f6c5..23dde7de81469a 100644 --- a/x-pack/plugins/observability_solution/apm/public/application/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/application/index.tsx @@ -9,7 +9,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; import type { ObservabilityRuleTypeRegistry } from '@kbn/observability-plugin/public'; import { AppMountParameters, CoreStart, APP_WRAPPER_CLASS } from '@kbn/core/public'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; import { ConfigSchema } from '..'; import { ApmPluginSetupDeps, ApmPluginStartDeps, ApmServices } from '../plugin'; import { createCallApmApi } from '../services/rest/create_call_apm_api'; @@ -69,21 +70,23 @@ export const renderApp = ({ element.classList.add(APP_WRAPPER_CLASS); ReactDOM.render( - - - , + + + + + , element ); return () => { diff --git a/x-pack/plugins/observability_solution/apm/tsconfig.json b/x-pack/plugins/observability_solution/apm/tsconfig.json index 4a43f0821c700c..b4ada5182d952e 100644 --- a/x-pack/plugins/observability_solution/apm/tsconfig.json +++ b/x-pack/plugins/observability_solution/apm/tsconfig.json @@ -118,7 +118,9 @@ "@kbn/search-types", "@kbn/logs-data-access-plugin", "@kbn/ebt-tools", - "@kbn/presentation-publishing" + "@kbn/presentation-publishing", + "@kbn/react-kibana-context-render", + "@kbn/react-kibana-context-theme" ], "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/observability_solution/infra/public/apps/common_providers.tsx b/x-pack/plugins/observability_solution/infra/public/apps/common_providers.tsx index 4cd8847695fd5d..90417274245961 100644 --- a/x-pack/plugins/observability_solution/infra/public/apps/common_providers.tsx +++ b/x-pack/plugins/observability_solution/infra/public/apps/common_providers.tsx @@ -8,7 +8,8 @@ import { AppMountParameters, CoreStart } from '@kbn/core/public'; import React, { FC, PropsWithChildren } from 'react'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { NavigationWarningPromptProvider } from '@kbn/observability-shared-plugin/public'; import { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-plugin/public'; @@ -60,7 +61,6 @@ export const CoreProviders: FC> = ({ core, pluginStart, plugins, - theme$, kibanaEnvironment, }) => { const KibanaContextProviderForPlugin = useKibanaContextForPluginProvider( @@ -72,19 +72,19 @@ export const CoreProviders: FC> = ({ const KibanaEnvContextForPluginProvider = useKibanaEnvironmentContextProvider(kibanaEnvironment); return ( - - - - - {children} - - - - + + + + + {children} + + + + ); }; diff --git a/x-pack/plugins/observability_solution/infra/public/apps/legacy_app.tsx b/x-pack/plugins/observability_solution/infra/public/apps/legacy_app.tsx index 9d91edcc8e034e..aa924ad663bc64 100644 --- a/x-pack/plugins/observability_solution/infra/public/apps/legacy_app.tsx +++ b/x-pack/plugins/observability_solution/infra/public/apps/legacy_app.tsx @@ -5,9 +5,9 @@ * 2.0. */ -import { EuiErrorBoundary } from '@elastic/eui'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { createBrowserHistory, History } from 'history'; -import { AppMountParameters } from '@kbn/core/public'; +import { AppMountParameters, CoreStart } from '@kbn/core/public'; import React from 'react'; import ReactDOM from 'react-dom'; import { RouteProps } from 'react-router-dom'; @@ -15,10 +15,15 @@ import { Router, Routes, Route } from '@kbn/shared-ux-router'; // This exists purely to facilitate legacy app/infra URL redirects. // It will be removed in 8.0.0. -export async function renderApp({ element }: AppMountParameters) { +export async function renderApp(core: CoreStart, { element }: AppMountParameters) { const history = createBrowserHistory(); - ReactDOM.render(, element); + ReactDOM.render( + + + , + element + ); return () => { ReactDOM.unmountComponentAtNode(element); @@ -27,72 +32,67 @@ export async function renderApp({ element }: AppMountParameters) { const LegacyApp: React.FunctionComponent<{ history: History }> = ({ history }) => { return ( - - - - { - if (!location) { - return null; - } + + + { + if (!location) { + return null; + } - let nextPath = ''; - let nextBasePath = ''; - let nextSearch; + let nextPath = ''; + let nextBasePath = ''; + let nextSearch; - if ( - location.hash.indexOf('#infrastructure') > -1 || - location.hash.indexOf('#/infrastructure') > -1 - ) { - nextPath = location.hash.replace( - new RegExp( - '#infrastructure/|#/infrastructure/|#/infrastructure|#infrastructure', - 'g' - ), - '' - ); - nextBasePath = location.pathname.replace('app/infra', 'app/metrics'); - } else if ( - location.hash.indexOf('#logs') > -1 || - location.hash.indexOf('#/logs') > -1 - ) { - nextPath = location.hash.replace( - new RegExp('#logs/|#/logs/|#/logs|#logs', 'g'), - '' - ); - nextBasePath = location.pathname.replace('app/infra', 'app/logs'); - } else { - // This covers /app/infra and /app/infra/home (both of which used to render - // the metrics inventory page) - nextPath = 'inventory'; - nextBasePath = location.pathname.replace('app/infra', 'app/metrics'); - nextSearch = undefined; - } + if ( + location.hash.indexOf('#infrastructure') > -1 || + location.hash.indexOf('#/infrastructure') > -1 + ) { + nextPath = location.hash.replace( + new RegExp( + '#infrastructure/|#/infrastructure/|#/infrastructure|#infrastructure', + 'g' + ), + '' + ); + nextBasePath = location.pathname.replace('app/infra', 'app/metrics'); + } else if ( + location.hash.indexOf('#logs') > -1 || + location.hash.indexOf('#/logs') > -1 + ) { + nextPath = location.hash.replace(new RegExp('#logs/|#/logs/|#/logs|#logs', 'g'), ''); + nextBasePath = location.pathname.replace('app/infra', 'app/logs'); + } else { + // This covers /app/infra and /app/infra/home (both of which used to render + // the metrics inventory page) + nextPath = 'inventory'; + nextBasePath = location.pathname.replace('app/infra', 'app/metrics'); + nextSearch = undefined; + } - // app/infra#infrastructure/metrics/:type/:node was changed to app/metrics/detail/:type/:node, this - // accounts for that edge case - nextPath = nextPath.replace('metrics/', 'detail/'); + // app/infra#infrastructure/metrics/:type/:node was changed to app/metrics/detail/:type/:node, this + // accounts for that edge case + nextPath = nextPath.replace('metrics/', 'detail/'); - // Query parameters (location.search) will arrive as part of location.hash and not location.search - const nextPathParts = nextPath.split('?'); - nextPath = nextPathParts[0]; - nextSearch = nextPathParts[1] ? nextPathParts[1] : undefined; + // Query parameters (location.search) will arrive as part of location.hash and not location.search + const nextPathParts = nextPath.split('?'); + nextPath = nextPathParts[0]; + nextSearch = nextPathParts[1] ? nextPathParts[1] : undefined; - const builtPathname = `${nextBasePath}/${nextPath}`; - const builtSearch = nextSearch ? `?${nextSearch}` : ''; + const builtPathname = `${nextBasePath}/${nextPath}`; + const builtSearch = nextSearch ? `?${nextSearch}` : ''; - let nextUrl = `${builtPathname}${builtSearch}`; + let nextUrl = `${builtPathname}${builtSearch}`; - nextUrl = nextUrl.replace('//', '/'); + nextUrl = nextUrl.replace('//', '/'); - window.location.href = nextUrl; + window.location.href = nextUrl; - return null; - }} - /> - - - + return null; + }} + /> + + ); }; diff --git a/x-pack/plugins/observability_solution/infra/public/plugin.ts b/x-pack/plugins/observability_solution/infra/public/plugin.ts index a7965890398209..20a6d85092c866 100644 --- a/x-pack/plugins/observability_solution/infra/public/plugin.ts +++ b/x-pack/plugins/observability_solution/infra/public/plugin.ts @@ -343,9 +343,10 @@ export class Plugin implements InfraClientPluginClass { title: 'infra', visibleIn: [], mount: async (params: AppMountParameters) => { + const [coreStart] = await core.getStartServices(); const { renderApp } = await import('./apps/legacy_app'); - return renderApp(params); + return renderApp(coreStart, params); }, }); diff --git a/x-pack/plugins/observability_solution/infra/public/test_utils/use_global_storybook_theme.tsx b/x-pack/plugins/observability_solution/infra/public/test_utils/use_global_storybook_theme.tsx index a24fd9b549a050..dd0f97038740ab 100644 --- a/x-pack/plugins/observability_solution/infra/public/test_utils/use_global_storybook_theme.tsx +++ b/x-pack/plugins/observability_solution/infra/public/test_utils/use_global_storybook_theme.tsx @@ -10,7 +10,7 @@ import React, { useEffect, useMemo, useState, FC, PropsWithChildren } from 'reac import { BehaviorSubject } from 'rxjs'; import type { CoreTheme } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; type StoryContext = Parameters[1]; @@ -35,7 +35,7 @@ export const GlobalStorybookThemeProviders: FC< > = ({ children, storyContext }) => { const { theme, theme$ } = useGlobalStorybookTheme(storyContext); return ( - + {children} ); diff --git a/x-pack/plugins/observability_solution/infra/tsconfig.json b/x-pack/plugins/observability_solution/infra/tsconfig.json index dfd1a52466a9a1..d43ab3b5ccc463 100644 --- a/x-pack/plugins/observability_solution/infra/tsconfig.json +++ b/x-pack/plugins/observability_solution/infra/tsconfig.json @@ -99,7 +99,9 @@ "@kbn/aiops-log-rate-analysis", "@kbn/react-hooks", "@kbn/search-types", - "@kbn/router-utils" + "@kbn/router-utils", + "@kbn/react-kibana-context-render", + "@kbn/react-kibana-context-theme" ], "exclude": [ "target/**/*" diff --git a/x-pack/plugins/observability_solution/logs_shared/public/test_utils/use_global_storybook_theme.tsx b/x-pack/plugins/observability_solution/logs_shared/public/test_utils/use_global_storybook_theme.tsx index a24fd9b549a050..dd0f97038740ab 100644 --- a/x-pack/plugins/observability_solution/logs_shared/public/test_utils/use_global_storybook_theme.tsx +++ b/x-pack/plugins/observability_solution/logs_shared/public/test_utils/use_global_storybook_theme.tsx @@ -10,7 +10,7 @@ import React, { useEffect, useMemo, useState, FC, PropsWithChildren } from 'reac import { BehaviorSubject } from 'rxjs'; import type { CoreTheme } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; type StoryContext = Parameters[1]; @@ -35,7 +35,7 @@ export const GlobalStorybookThemeProviders: FC< > = ({ children, storyContext }) => { const { theme, theme$ } = useGlobalStorybookTheme(storyContext); return ( - + {children} ); diff --git a/x-pack/plugins/observability_solution/logs_shared/tsconfig.json b/x-pack/plugins/observability_solution/logs_shared/tsconfig.json index cfe5687f0404fe..927c2f0374018e 100644 --- a/x-pack/plugins/observability_solution/logs_shared/tsconfig.json +++ b/x-pack/plugins/observability_solution/logs_shared/tsconfig.json @@ -37,6 +37,7 @@ "@kbn/share-plugin", "@kbn/shared-ux-utility", "@kbn/search-types", - "@kbn/discover-shared-plugin" + "@kbn/discover-shared-plugin", + "@kbn/react-kibana-context-theme" ] } diff --git a/x-pack/plugins/observability_solution/metrics_data_access/public/apps/common_providers.tsx b/x-pack/plugins/observability_solution/metrics_data_access/public/apps/common_providers.tsx index cd2ac05f14778f..1734b49c694f50 100644 --- a/x-pack/plugins/observability_solution/metrics_data_access/public/apps/common_providers.tsx +++ b/x-pack/plugins/observability_solution/metrics_data_access/public/apps/common_providers.tsx @@ -5,25 +5,24 @@ * 2.0. */ -import { AppMountParameters, CoreStart } from '@kbn/core/public'; +import { CoreStart } from '@kbn/core/public'; import React from 'react'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { useKibanaContextForPluginProvider } from '../hooks/use_kibana'; export interface CoreProvidersProps { children?: React.ReactNode; core: CoreStart; - theme$: AppMountParameters['theme$']; } -export const CoreProviders: React.FC = ({ children, core, theme$ }) => { +export const CoreProviders: React.FC = ({ children, core }) => { const KibanaContextProviderForPlugin = useKibanaContextForPluginProvider(core); return ( - - - {children} - - + + + {children} + + ); }; diff --git a/x-pack/plugins/observability_solution/metrics_data_access/public/components/infrastructure_node_metrics_tables/container/create_lazy_container_metrics_table.tsx b/x-pack/plugins/observability_solution/metrics_data_access/public/components/infrastructure_node_metrics_tables/container/create_lazy_container_metrics_table.tsx index d187c88bcbba50..4faa4320aa6a0a 100644 --- a/x-pack/plugins/observability_solution/metrics_data_access/public/components/infrastructure_node_metrics_tables/container/create_lazy_container_metrics_table.tsx +++ b/x-pack/plugins/observability_solution/metrics_data_access/public/components/infrastructure_node_metrics_tables/container/create_lazy_container_metrics_table.tsx @@ -21,7 +21,6 @@ export function createLazyContainerMetricsTable(core: CoreStart, metricsClient: [coreProvidersPropsMock.core]; diff --git a/x-pack/plugins/observability_solution/metrics_data_access/public/test_utils/use_global_storybook_theme.tsx b/x-pack/plugins/observability_solution/metrics_data_access/public/test_utils/use_global_storybook_theme.tsx index b813cfa563a0f9..7ed147138cce3a 100644 --- a/x-pack/plugins/observability_solution/metrics_data_access/public/test_utils/use_global_storybook_theme.tsx +++ b/x-pack/plugins/observability_solution/metrics_data_access/public/test_utils/use_global_storybook_theme.tsx @@ -10,7 +10,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { BehaviorSubject } from 'rxjs'; import type { CoreTheme } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; type StoryContext = Parameters[1]; @@ -34,7 +34,7 @@ export const GlobalStorybookThemeProviders: React.FC<{ }> = ({ children, storyContext }) => { const { theme, theme$ } = useGlobalStorybookTheme(storyContext); return ( - + {children} ); diff --git a/x-pack/plugins/observability_solution/metrics_data_access/tsconfig.json b/x-pack/plugins/observability_solution/metrics_data_access/tsconfig.json index 7c6c2e1bd3d958..b2ba77bff9f379 100644 --- a/x-pack/plugins/observability_solution/metrics_data_access/tsconfig.json +++ b/x-pack/plugins/observability_solution/metrics_data_access/tsconfig.json @@ -34,6 +34,8 @@ "@kbn/i18n-react", "@kbn/logging", "@kbn/core-http-request-handler-context-server", - "@kbn/lens-embeddable-utils" + "@kbn/lens-embeddable-utils", + "@kbn/react-kibana-context-render", + "@kbn/react-kibana-context-theme" ] } diff --git a/x-pack/plugins/observability_solution/observability/public/application/index.tsx b/x-pack/plugins/observability_solution/observability/public/application/index.tsx index 1166755ca14572..9c56ec1bb54ecd 100644 --- a/x-pack/plugins/observability_solution/observability/public/application/index.tsx +++ b/x-pack/plugins/observability_solution/observability/public/application/index.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import { EuiErrorBoundary } from '@elastic/eui'; import React from 'react'; import ReactDOM from 'react-dom'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; @@ -13,6 +12,7 @@ import { i18n } from '@kbn/i18n'; import { Router, Routes, Route } from '@kbn/shared-ux-router'; import { AppMountParameters, APP_WRAPPER_CLASS, CoreStart } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; @@ -66,7 +66,6 @@ export const renderApp = ({ isServerless?: boolean; }) => { const { element, history, theme$ } = appMountParameters; - const i18nCore = core.i18n; const isDarkMode = core.theme.getTheme().darkMode; core.chrome.setHelpExtension({ @@ -87,8 +86,8 @@ export const renderApp = ({ const PresentationContextProvider = plugins.presentationUtil?.ContextProvider ?? React.Fragment; ReactDOM.render( - - + + @@ -113,17 +112,15 @@ export const renderApp = ({ > - - - - - - - - + + + + + + @@ -131,8 +128,8 @@ export const renderApp = ({ - - , + + , element ); return () => { diff --git a/x-pack/plugins/observability_solution/observability/public/pages/overview/components/header_menu/header_menu.tsx b/x-pack/plugins/observability_solution/observability/public/pages/overview/components/header_menu/header_menu.tsx index a7ca5fa38ffc3c..52ca08e40c031d 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/overview/components/header_menu/header_menu.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/overview/components/header_menu/header_menu.tsx @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { usePluginContext } from '../../../../hooks/use_plugin_context'; import { useKibana } from '../../../../utils/kibana_react'; +// FIXME: import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public' import HeaderMenuPortal from './header_menu_portal'; export function HeaderMenu(): React.ReactElement | null { diff --git a/x-pack/plugins/observability_solution/observability/public/test_utils/use_global_storybook_theme.tsx b/x-pack/plugins/observability_solution/observability/public/test_utils/use_global_storybook_theme.tsx index 2930d9de22346e..ea94e2edb6f8be 100644 --- a/x-pack/plugins/observability_solution/observability/public/test_utils/use_global_storybook_theme.tsx +++ b/x-pack/plugins/observability_solution/observability/public/test_utils/use_global_storybook_theme.tsx @@ -10,7 +10,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { BehaviorSubject } from 'rxjs'; import type { CoreTheme } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; type StoryContext = Parameters[1]; @@ -37,7 +37,7 @@ export function GlobalStorybookThemeProviders({ }) { const { theme, theme$ } = useGlobalStorybookTheme(storyContext); return ( - + {children} ); diff --git a/x-pack/plugins/observability_solution/observability/tsconfig.json b/x-pack/plugins/observability_solution/observability/tsconfig.json index fb045f31492dee..b4f617079dc58d 100644 --- a/x-pack/plugins/observability_solution/observability/tsconfig.json +++ b/x-pack/plugins/observability_solution/observability/tsconfig.json @@ -86,7 +86,6 @@ "@kbn/content-management-plugin", "@kbn/deeplinks-observability", "@kbn/core-application-common", - "@kbn/react-kibana-mount", "@kbn/react-kibana-context-theme", "@kbn/shared-ux-link-redirect-app", "@kbn/lens-embeddable-utils", @@ -99,6 +98,8 @@ "@kbn/data-view-field-editor-plugin", "@kbn/cases-components", "@kbn/aiops-log-rate-analysis", + "@kbn/react-kibana-context-render", + "@kbn/react-kibana-mount", ], "exclude": [ "target/**/*" diff --git a/x-pack/plugins/observability_solution/observability_onboarding/public/application/app.tsx b/x-pack/plugins/observability_solution/observability_onboarding/public/application/app.tsx index 5c0bce9030aa7e..2b928b37f471b9 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/public/application/app.tsx +++ b/x-pack/plugins/observability_solution/observability_onboarding/public/application/app.tsx @@ -8,7 +8,9 @@ import { EuiErrorBoundary } from '@elastic/eui'; import { AppMountParameters, APP_WRAPPER_CLASS, CoreStart } from '@kbn/core/public'; import { i18n } from '@kbn/i18n'; -import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public'; import { Router } from '@kbn/shared-ux-router'; @@ -45,7 +47,6 @@ export function ObservabilityOnboardingAppRoot({ appMountParameters: AppMountParameters; } & RenderAppProps) { const { history, setHeaderActionMenu, theme$ } = appMountParameters; - const i18nCore = core.i18n; const plugins = { ...deps }; const renderFeedbackLinkAsPortal = !config.serverless.enabled; @@ -55,31 +56,31 @@ export function ObservabilityOnboardingAppRoot({ }); return ( -
- - +
+ - - + {renderFeedbackLinkAsPortal && ( @@ -90,11 +91,11 @@ export function ObservabilityOnboardingAppRoot({ - - - - -
+ +
+
+
+ ); } diff --git a/x-pack/plugins/observability_solution/observability_onboarding/tsconfig.json b/x-pack/plugins/observability_solution/observability_onboarding/tsconfig.json index b03e6d6ffe6d59..eb31601928b877 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/tsconfig.json +++ b/x-pack/plugins/observability_solution/observability_onboarding/tsconfig.json @@ -36,7 +36,9 @@ "@kbn/shared-ux-link-redirect-app", "@kbn/cloud-experiments-plugin", "@kbn/home-sample-data-tab", - "@kbn/analytics-client" + "@kbn/analytics-client", + "@kbn/react-kibana-context-render", + "@kbn/react-kibana-context-theme" ], "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/observability_solution/observability_shared/public/components/header_menu/header_menu_portal.tsx b/x-pack/plugins/observability_solution/observability_shared/public/components/header_menu/header_menu_portal.tsx index 4f7c4bb817e3e7..fcd71e1e75d420 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/components/header_menu/header_menu_portal.tsx +++ b/x-pack/plugins/observability_solution/observability_shared/public/components/header_menu/header_menu_portal.tsx @@ -7,6 +7,7 @@ import React, { useEffect, useMemo } from 'react'; import { createHtmlPortalNode, InPortal, OutPortal } from 'react-reverse-portal'; +// FIXME use import { toMountPoint } from '@kbn/react-kibana-mount'; import { toMountPoint } from '@kbn/kibana-react-plugin/public'; import type { HeaderMenuPortalProps } from '../../types'; diff --git a/x-pack/plugins/observability_solution/slo/public/application.tsx b/x-pack/plugins/observability_solution/slo/public/application.tsx index 9cf739f5e543a2..aedfba1b1eadae 100644 --- a/x-pack/plugins/observability_solution/slo/public/application.tsx +++ b/x-pack/plugins/observability_solution/slo/public/application.tsx @@ -7,13 +7,13 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { EuiErrorBoundary } from '@elastic/eui'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme'; import { AppMountParameters, APP_WRAPPER_CLASS, CoreStart } from '@kbn/core/public'; import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { Router, Routes, Route } from '@kbn/shared-ux-router'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; @@ -72,7 +72,6 @@ export const renderApp = ({ experimentalFeatures: ExperimentalFeatures; }) => { const { element, history, theme$ } = appMountParameters; - const i18nCore = core.i18n; const isDarkMode = core.theme.getTheme().darkMode; // ensure all divs are .kbnAppWrappers @@ -110,8 +109,8 @@ export const renderApp = ({ }); ReactDOM.render( - - + + @@ -137,16 +136,14 @@ export const renderApp = ({ > - - - - - - - + + + + + @@ -154,8 +151,8 @@ export const renderApp = ({ - - , + + , element ); diff --git a/x-pack/plugins/observability_solution/slo/public/context/plugin_context.tsx b/x-pack/plugins/observability_solution/slo/public/context/plugin_context.tsx index 1f8d6f25e09619..9bdfcb2a9d0e4a 100644 --- a/x-pack/plugins/observability_solution/slo/public/context/plugin_context.tsx +++ b/x-pack/plugins/observability_solution/slo/public/context/plugin_context.tsx @@ -14,7 +14,7 @@ import { ExperimentalFeatures } from '../../common/config'; export interface PluginContextValue { isDev?: boolean; isServerless?: boolean; - appMountParameters?: AppMountParameters; + appMountParameters: AppMountParameters; observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry; ObservabilityPageTemplate: React.ComponentType; experimentalFeatures?: ExperimentalFeatures; @@ -24,6 +24,6 @@ export interface OverviewEmbeddableContextValue { observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry; } -export const PluginContext = createContext( - {} as PluginContextValue | OverviewEmbeddableContextValue -); +export const OverviewEmbeddableContext = createContext(null); + +export const PluginContext = createContext(null); diff --git a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/alerts/handle_explicit_input.tsx b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/alerts/handle_explicit_input.tsx index 0ead7cd58229ee..54af69acbe13d3 100644 --- a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/alerts/handle_explicit_input.tsx +++ b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/alerts/handle_explicit_input.tsx @@ -47,7 +47,7 @@ export async function resolveEmbeddableSloUserInput( /> , - { i18n: coreStart.i18n, theme: coreStart.theme } + coreStart ) ); } catch (error) { diff --git a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/error_budget/error_budget_open_configuration.tsx b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/error_budget/error_budget_open_configuration.tsx index 10b65cf5c342da..fbda743a951b2c 100644 --- a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/error_budget/error_budget_open_configuration.tsx +++ b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/error_budget/error_budget_open_configuration.tsx @@ -42,7 +42,7 @@ export async function openSloConfiguration( /> , - { i18n: coreStart.i18n, theme: coreStart.theme } + coreStart ) ); } catch (error) { diff --git a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_embeddable_factory.tsx b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_embeddable_factory.tsx index a4f26679dd1dde..e0cf5d0b138371 100644 --- a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_embeddable_factory.tsx +++ b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_embeddable_factory.tsx @@ -34,7 +34,7 @@ import { GroupSloCustomInput, } from './types'; import { EDIT_SLO_OVERVIEW_ACTION } from '../../../ui_actions/edit_slo_overview_panel'; -import { PluginContext } from '../../../context/plugin_context'; +import { OverviewEmbeddableContext } from '../../../context/plugin_context'; const queryClient = new QueryClient(); export const getOverviewPanelTitle = () => @@ -191,7 +191,7 @@ export const getOverviewEmbeddableFactory = (deps: SloEmbeddableDeps) => { - + {showAllGroupByInstances ? ( @@ -199,7 +199,7 @@ export const getOverviewEmbeddableFactory = (deps: SloEmbeddableDeps) => { renderOverview() )} - + diff --git a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_overview_open_configuration.tsx b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_overview_open_configuration.tsx index fa0f9992d718eb..df2edd134423de 100644 --- a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_overview_open_configuration.tsx +++ b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/slo_overview_open_configuration.tsx @@ -44,7 +44,7 @@ export async function openSloConfiguration( /> , - { i18n: coreStart.i18n, theme: coreStart.theme } + coreStart ) ); } catch (error) { diff --git a/x-pack/plugins/observability_solution/slo/public/hooks/use_plugin_context.tsx b/x-pack/plugins/observability_solution/slo/public/hooks/use_plugin_context.tsx index f9a302ff64aa70..d0640deb575b21 100644 --- a/x-pack/plugins/observability_solution/slo/public/hooks/use_plugin_context.tsx +++ b/x-pack/plugins/observability_solution/slo/public/hooks/use_plugin_context.tsx @@ -9,6 +9,11 @@ import { useContext } from 'react'; import { PluginContext } from '../context/plugin_context'; import type { PluginContextValue } from '../context/plugin_context'; -export function usePluginContext() { - return useContext(PluginContext) as PluginContextValue; +export function usePluginContext(): PluginContextValue { + const context = useContext(PluginContext); + if (!context) { + throw new Error('Plugin context value is missing!'); + } + + return context; } diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/shared_flyout/get_create_slo_flyout.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/shared_flyout/get_create_slo_flyout.tsx index d73144d089ffd7..265b063928fda7 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/shared_flyout/get_create_slo_flyout.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slo_edit/shared_flyout/get_create_slo_flyout.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { QueryClientProvider } from '@tanstack/react-query'; import { QueryClient } from '@tanstack/react-query'; import { Storage } from '@kbn/kibana-utils-plugin/public'; -import { CoreStart } from '@kbn/core-lifecycle-browser'; +import { AppMountParameters, CoreStart } from '@kbn/core/public'; import { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { RecursivePartial } from '@kbn/utility-types'; @@ -23,6 +23,7 @@ import { SloAddFormFlyout } from './slo_form'; export const getCreateSLOFlyoutLazy = ({ core, plugins, + getAppMountParameters, observabilityRuleTypeRegistry, ObservabilityPageTemplate, isDev, @@ -32,6 +33,7 @@ export const getCreateSLOFlyoutLazy = ({ }: { core: CoreStart; plugins: SloPublicPluginsStart; + getAppMountParameters: () => Promise; observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry; ObservabilityPageTemplate: React.ComponentType; isDev?: boolean; @@ -39,7 +41,7 @@ export const getCreateSLOFlyoutLazy = ({ isServerless?: boolean; experimentalFeatures: ExperimentalFeatures; }) => { - return ({ + return async ({ onClose, initialValues, }: { @@ -47,6 +49,7 @@ export const getCreateSLOFlyoutLazy = ({ initialValues?: RecursivePartial; }) => { const queryClient = new QueryClient(); + const appMountParameters = await getAppMountParameters(); return ( diff --git a/x-pack/plugins/observability_solution/slo/public/plugin.ts b/x-pack/plugins/observability_solution/slo/public/plugin.ts index 5b25f97742c86c..99acdbbc733551 100644 --- a/x-pack/plugins/observability_solution/slo/public/plugin.ts +++ b/x-pack/plugins/observability_solution/slo/public/plugin.ts @@ -14,7 +14,7 @@ import { Plugin, PluginInitializerContext, } from '@kbn/core/public'; -import { BehaviorSubject, firstValueFrom } from 'rxjs'; +import { BehaviorSubject, Subject, firstValueFrom } from 'rxjs'; import { SloPublicPluginsSetup, SloPublicPluginsStart } from './types'; import { PLUGIN_NAME, sloAppId } from '../common'; import type { SloPublicSetup, SloPublicStart } from './types'; @@ -32,6 +32,7 @@ export class SloPlugin implements Plugin { private readonly appUpdater$ = new BehaviorSubject(() => ({})); + private readonly appMountParameters$ = new Subject>(); private experimentalFeatures: ExperimentalFeatures = { ruleFormV2: { enabled: false } }; constructor(private readonly initContext: PluginInitializerContext) { @@ -56,6 +57,7 @@ export class SloPlugin const [coreStart, pluginsStart] = await coreSetup.getStartServices(); const { ruleTypeRegistry, actionTypeRegistry } = pluginsStart.triggersActionsUi; const { observabilityRuleTypeRegistry } = pluginsStart.observability; + this.appMountParameters$.next(params); return renderApp({ appMountParameters: params, @@ -88,7 +90,7 @@ export class SloPlugin registerBurnRateRuleType(pluginsSetup.observability.observabilityRuleTypeRegistry); const assertPlatinumLicense = async () => { - const licensing = await pluginsSetup.licensing; + const licensing = pluginsSetup.licensing; const license = await firstValueFrom(licensing.license$); const hasPlatinumLicense = license.hasAtLeast('platinum'); @@ -164,6 +166,7 @@ export class SloPlugin observabilityRuleTypeRegistry: pluginsStart.observability.observabilityRuleTypeRegistry, ObservabilityPageTemplate: pluginsStart.observabilityShared.navigation.PageTemplate, plugins: { ...pluginsStart, ruleTypeRegistry, actionTypeRegistry }, + getAppMountParameters: () => firstValueFrom(this.appMountParameters$), isServerless: !!pluginsStart.serverless, experimentalFeatures: this.experimentalFeatures, }), diff --git a/x-pack/plugins/observability_solution/slo/tsconfig.json b/x-pack/plugins/observability_solution/slo/tsconfig.json index 34ce93e23f5746..d16328c73a35f3 100644 --- a/x-pack/plugins/observability_solution/slo/tsconfig.json +++ b/x-pack/plugins/observability_solution/slo/tsconfig.json @@ -95,5 +95,6 @@ "@kbn/dashboard-plugin", "@kbn/monaco", "@kbn/code-editor", + "@kbn/react-kibana-context-render" ] }