[KibanaReact] Use settings service in useUiSetting hook (#154710)

## Summary

Fixes: https://github.com/elastic/kibana/issues/149347

This PR replaces deprecated `uiSettings` client with `settings.client`
in `useUiSetting` hook. As a result, all consumers of the hook need to
provide `settings` service to Kibana context. The majority of this PR is
providing the `settings` as a dependency to affected plugins. It would
be great if sometime in the future we could get rid of `uiSettings`
entirely.

`CodeEditor` is one of the components relying on this hook, which caused
a lot of the changes in this PR.

If you have been tagged for review it means your code is using
`useUiSetting` hook directly, or is consuming `CodeEditor` component. I
have been focused on updating plugins that had failing functional tests,
but would appreciate a manual pass on this as well.

xoxo


### Checklist

Delete any items that are not applicable to this PR.

~ [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~
~- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials~
- [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
~- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard
accessibility](https://webaim.org/techniques/keyboard/))~
~- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~
~- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~
~- [ ] 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)~


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Maja Grubic <maja.grubic@elastic.co>
Co-authored-by: Patryk Kopyciński <contact@patrykkopycinski.com>
This commit is contained in:
Maja Grubic 2023-05-12 09:47:56 +02:00 committed by GitHub
parent 521811e0a1
commit 069550d72a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 268 additions and 64 deletions

View file

@ -23,6 +23,7 @@ import { ExpressionsStart } from '@kbn/expressions-plugin/public';
import { Start as InspectorStart } from '@kbn/inspector-plugin/public';
import { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
import { SettingsStart } from '@kbn/core-ui-settings-browser';
import { RunExpressionsExample } from './run_expressions';
import { RenderExpressionsExample } from './render_expressions';
import { ActionsExpressionsExample } from './actions_and_expressions';
@ -33,10 +34,14 @@ interface Props {
inspector: InspectorStart;
actions: UiActionsStart;
uiSettings: IUiSettingsClient;
settings: SettingsStart;
}
const ExpressionsExplorer = ({ expressions, inspector, actions, uiSettings }: Props) => {
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ uiSettings });
const ExpressionsExplorer = ({ expressions, inspector, actions, uiSettings, settings }: Props) => {
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings,
settings,
});
return (
<KibanaReactContextProvider>
<EuiPage>

View file

@ -57,6 +57,7 @@ export class ExpressionsExplorerPlugin implements Plugin<void, void, SetupDeps,
inspector: depsStart.inspector,
actions: depsStart.uiActions,
uiSettings: core.uiSettings,
settings: core.settings,
},
params
);

View file

@ -21,5 +21,6 @@
"@kbn/developer-examples-plugin",
"@kbn/i18n",
"@kbn/i18n-react",
"@kbn/core-ui-settings-browser",
]
}