From 3ff8159af830ef20da7537f17b12b2f6415fafe8 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Fri, 6 Dec 2024 15:06:59 -0700 Subject: [PATCH] [KibanaRootContextProvider] destructure the params to KibanaEuiProvider (#203303) ## Summary Addresses: https://github.com/elastic/kibana/pull/202606#discussion_r1871947907 This discards the > unused portions of core, before adding them to the context value, but still allow people to pass the entire construct if we were to need something else cc @clintandrewhall ---- ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. **none** ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. **none** --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- packages/react/kibana_context/render/render_provider.tsx | 8 ++++++-- packages/react/kibana_context/root/root_provider.test.tsx | 6 ------ packages/react/kibana_context/root/root_provider.tsx | 3 ++- packages/react/kibana_context/root/tsconfig.json | 1 - 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/react/kibana_context/render/render_provider.tsx b/packages/react/kibana_context/render/render_provider.tsx index a597311c0e17a..233abb42834b9 100644 --- a/packages/react/kibana_context/render/render_provider.tsx +++ b/packages/react/kibana_context/render/render_provider.tsx @@ -25,9 +25,13 @@ export type KibanaRenderContextProviderProps = Omit > = ({ children, ...props }) => { + const { analytics, i18n, theme, userProfile, colorMode, modify } = props; return ( - - + + {children} diff --git a/packages/react/kibana_context/root/root_provider.test.tsx b/packages/react/kibana_context/root/root_provider.test.tsx index 312b366797a36..405823a9b823c 100644 --- a/packages/react/kibana_context/root/root_provider.test.tsx +++ b/packages/react/kibana_context/root/root_provider.test.tsx @@ -15,8 +15,6 @@ import { useEuiTheme } from '@elastic/eui'; import type { UseEuiTheme } from '@elastic/eui'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { KibanaTheme } from '@kbn/react-kibana-context-common'; -import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser'; -import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks'; import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks'; import { I18nStart } from '@kbn/core-i18n-browser'; import type { UserProfileService } from '@kbn/core-user-profile-browser'; @@ -26,12 +24,10 @@ import { KibanaRootContextProvider } from './root_provider'; describe('KibanaRootContextProvider', () => { let euiTheme: UseEuiTheme | undefined; let i18nMock: I18nStart; - let analytics: AnalyticsServiceStart; let userProfile: UserProfileService; beforeEach(() => { euiTheme = undefined; - analytics = analyticsServiceMock.createAnalyticsServiceStart(); i18nMock = i18nServiceMock.createStartContract(); userProfile = userProfileServiceMock.createStart(); }); @@ -66,7 +62,6 @@ describe('KibanaRootContextProvider', () => { const wrapper = mountWithIntl( { const wrapper = mountWithIntl( {children}; } else { + const { theme, userProfile, globalStyles, colorMode, modify } = props; return ( - + {children} ); diff --git a/packages/react/kibana_context/root/tsconfig.json b/packages/react/kibana_context/root/tsconfig.json index 6c67c97861c11..a7606025552b8 100644 --- a/packages/react/kibana_context/root/tsconfig.json +++ b/packages/react/kibana_context/root/tsconfig.json @@ -22,7 +22,6 @@ "@kbn/core-i18n-browser", "@kbn/core-base-common", "@kbn/core-analytics-browser", - "@kbn/core-analytics-browser-mocks", "@kbn/core-user-profile-browser", "@kbn/core-user-profile-browser-mocks", ]