[Discover] Remove usage of deprecated React rendering utilities (#181623)

## Summary

Partially addresses https://github.com/elastic/kibana-team/issues/805

These changes come up from searching in the code and finding where
certain kinds of deprecated AppEx-SharedUX modules are imported.
**Reviewers: Please interact with critical paths through the UI
components touched in this PR, ESPECIALLY in terms of testing dark mode
and i18n.**

This focuses on code within **Discover**. Due to related type-safety
needs there are also some minor changes in the **Data** plugin.

<img width="1196" alt="image"
src="7f8d3707-94f0-4746-8dd5-dd858ce027f9">

Note: this also makes inclusion of `i18n` and `analytics` dependencies
consistent. Analytics is an optional dependency for the SharedUX
modules, which wrap `KibanaErrorBoundaryProvider` and is designed to
capture telemetry about errors that are caught in the error boundary.

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Julia Rechkunova <julia.rechkunova@gmail.com>
This commit is contained in:
Tim Sullivan 2024-04-26 11:48:06 -07:00 committed by GitHub
parent a05355713e
commit bc87224b41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 468 additions and 584 deletions

View file

@ -16,8 +16,6 @@
"share",
"unifiedSearch"
],
"requiredBundles": [
"kibanaReact"
]
"requiredBundles": []
}
}

View file

@ -39,7 +39,7 @@ const LINKS: ExampleLink[] = [
];
export const renderApp = (
{ notifications, savedObjects, http, application }: CoreStart,
{ notifications, savedObjects, http, application, ...startServices }: CoreStart,
{ data, navigation, unifiedSearch }: AppPluginStartDependencies,
{ element, history }: AppMountParameters
) => {
@ -60,6 +60,7 @@ export const renderApp = (
data={data}
http={http}
unifiedSearch={unifiedSearch}
{...startServices}
/>
</Route>
<Route path={LINKS[1].path}>

View file

@ -36,7 +36,7 @@ import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';
import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import React, { useEffect, useState } from 'react';
@ -44,9 +44,8 @@ import { lastValueFrom } from 'rxjs';
import { PLUGIN_ID, PLUGIN_NAME, SERVER_SEARCH_ROUTE_PATH } from '../../common';
import { IMyStrategyResponse } from '../../common/types';
interface SearchExamplesAppDeps {
notifications: CoreStart['notifications'];
http: CoreStart['http'];
interface SearchExamplesAppDeps
extends Pick<CoreStart, 'notifications' | 'http' | 'analytics' | 'i18n' | 'theme'> {
navigation: NavigationPublicPluginStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
@ -86,6 +85,7 @@ export const SearchExamplesApp = ({
navigation,
data,
unifiedSearch,
...startServices
}: SearchExamplesAppDeps) => {
const { IndexPatternSelect } = unifiedSearch.ui;
const [getCool, setGetCool] = useState<boolean>(false);
@ -234,7 +234,7 @@ export const SearchExamplesApp = ({
notifications.toasts.addSuccess(
{
title: 'Query result',
text: toMountPoint(message),
text: toMountPoint(message, startServices),
},
{
toastLifeTimeMs: 300000,
@ -243,7 +243,7 @@ export const SearchExamplesApp = ({
if (res.warning) {
notifications.toasts.addWarning({
title: 'Warning',
text: toMountPoint(res.warning),
text: toMountPoint(res.warning, startServices),
});
}
}
@ -337,7 +337,7 @@ export const SearchExamplesApp = ({
notifications.toasts.addSuccess(
{
title: 'Query result',
text: toMountPoint(message),
text: toMountPoint(message, startServices),
},
{
toastLifeTimeMs: 300000,

View file

@ -20,7 +20,6 @@
"@kbn/data-views-plugin",
"@kbn/inspector-plugin",
"@kbn/kibana-utils-plugin",
"@kbn/kibana-react-plugin",
"@kbn/navigation-plugin",
"@kbn/share-plugin",
"@kbn/developer-examples-plugin",
@ -34,5 +33,6 @@
"@kbn/shared-ux-router",
"@kbn/search-response-warnings",
"@kbn/shared-ux-link-redirect-app",
"@kbn/react-kibana-mount",
]
}