-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiProvider/ResponseOps] Remove usage of deprecated React rendering utilities #180098
Changes from all commits
16b07c3
1aa01cb
3213e37
53edd51
5c69f2c
2578f8d
492dc19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,18 @@ | |
|
||
import React, { Suspense } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { Router, Routes, Route } from '@kbn/shared-ux-router'; | ||
|
||
import { EuiLoadingSpinner } from '@elastic/eui'; | ||
import { CoreStart } from '@kbn/core/public'; | ||
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 { Storage } from '@kbn/kibana-utils-plugin/public'; | ||
import { ManagementAppMountParams } from '@kbn/management-plugin/public'; | ||
import { EuiLoadingSpinner } from '@elastic/eui'; | ||
import { AlertingPluginStart } from '../plugin'; | ||
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; | ||
import { Route, Router, Routes } from '@kbn/shared-ux-router'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { MAINTENANCE_WINDOW_PATHS } from '../../common'; | ||
import { useLicense } from '../hooks/use_license'; | ||
import { AlertingPluginStart } from '../plugin'; | ||
|
||
const MaintenanceWindowsLazy: React.FC = React.lazy(() => import('../pages/maintenance_windows')); | ||
const MaintenanceWindowsCreateLazy: React.FC = React.lazy( | ||
|
@@ -76,14 +77,13 @@ export const renderApp = ({ | |
mountParams: ManagementAppMountParams; | ||
kibanaVersion: string; | ||
}) => { | ||
const { element, history, theme$ } = mountParams; | ||
const i18nCore = core.i18n; | ||
const isDarkMode = core.theme.getTheme().darkMode; | ||
const { element, history } = mountParams; | ||
const { i18n, theme } = core; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
ReactDOM.render( | ||
<KibanaThemeProvider theme$={theme$}> | ||
<KibanaRenderContextProvider i18n={i18n} theme={theme}> | ||
<KibanaContextProvider | ||
services={{ | ||
...core, | ||
|
@@ -93,16 +93,12 @@ export const renderApp = ({ | |
}} | ||
> | ||
<Router history={history}> | ||
<EuiThemeProvider darkMode={isDarkMode}> | ||
<i18nCore.Context> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The i18n context provider is not explicitly needed since KibnaRenderContextProvider provides it |
||
<QueryClientProvider client={queryClient}> | ||
<App /> | ||
</QueryClientProvider> | ||
</i18nCore.Context> | ||
</EuiThemeProvider> | ||
<QueryClientProvider client={queryClient}> | ||
<App /> | ||
</QueryClientProvider> | ||
</Router> | ||
</KibanaContextProvider> | ||
</KibanaThemeProvider>, | ||
</KibanaRenderContextProvider>, | ||
element | ||
); | ||
return () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import type { ErrorToastOptions } from '@kbn/core/public'; | |
import { EuiButtonEmpty, EuiText, logicalCSS, useEuiTheme } from '@elastic/eui'; | ||
import React, { useMemo } from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { toMountPoint } from '@kbn/kibana-react-plugin/public'; | ||
import { toMountPoint } from '@kbn/react-kibana-mount'; | ||
import { isValidOwner } from '../../common/utils/owner'; | ||
import type { CaseUI } from '../../common'; | ||
import { AttachmentType } from '../../common/types/domain'; | ||
|
@@ -106,7 +106,8 @@ const getErrorMessage = (error: Error | ServerError): string => { | |
|
||
export const useCasesToast = () => { | ||
const { appId } = useApplication(); | ||
const { getUrlForApp, navigateToUrl } = useKibana().services.application; | ||
const { application, i18n, theme } = useKibana().services; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these services available to all plugins? I am asking because Cases are used in a lot of places across Kibana. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, thanks! |
||
const { getUrlForApp, navigateToUrl } = application; | ||
|
||
const toasts = useToasts(); | ||
|
||
|
@@ -147,12 +148,13 @@ export const useCasesToast = () => { | |
return toasts.addSuccess({ | ||
color: 'success', | ||
iconType: 'check', | ||
title: toMountPoint(<TruncatedText text={renderTitle} />), | ||
title: toMountPoint(<TruncatedText text={renderTitle} />, { i18n, theme }), | ||
text: toMountPoint( | ||
<CaseToastSuccessContent | ||
content={renderContent} | ||
onViewCaseClick={url != null ? onViewCaseClick : undefined} | ||
/> | ||
/>, | ||
{ i18n, theme } | ||
), | ||
}); | ||
}, | ||
|
@@ -175,7 +177,7 @@ export const useCasesToast = () => { | |
}); | ||
}, | ||
}), | ||
[appId, getUrlForApp, navigateToUrl, toasts] | ||
[i18n, theme, appId, getUrlForApp, navigateToUrl, toasts] | ||
); | ||
}; | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I placed
KibanaRenderContextProvider
above other context providers, in all changes, for consistency