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

View file

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

View file

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

View file

@ -72,11 +72,12 @@ export const getFieldEditorOpener =
apiService, apiService,
}: Dependencies) => }: Dependencies) =>
(options: OpenFieldEditorOptions): CloseEditor => { (options: OpenFieldEditorOptions): CloseEditor => {
const { uiSettings, overlays, docLinks, notifications } = core; const { uiSettings, overlays, docLinks, notifications, settings } = core;
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings, uiSettings,
docLinks, docLinks,
http: core.http, http: core.http,
settings,
}); });
let overlayRef: OverlayRef | null = null; let overlayRef: OverlayRef | null = null;

View file

@ -40,7 +40,7 @@ export async function mountManagementSection(
params: ManagementAppMountParams params: ManagementAppMountParams
) { ) {
const [ const [
{ application, chrome, uiSettings, notifications, overlays, http, docLinks, theme }, { application, chrome, uiSettings, settings, notifications, overlays, http, docLinks, theme },
{ {
data, data,
dataViewFieldEditor, dataViewFieldEditor,
@ -63,6 +63,7 @@ export async function mountManagementSection(
application, application,
chrome, chrome,
uiSettings, uiSettings,
settings,
notifications, notifications,
overlays, overlays,
unifiedSearch, unifiedSearch,

View file

@ -57,7 +57,7 @@ const docLinks = {
const createIndexPatternManagmentContext = (): { const createIndexPatternManagmentContext = (): {
[key in keyof IndexPatternManagmentContext]: any; [key in keyof IndexPatternManagmentContext]: any;
} => { } => {
const { application, chrome, uiSettings, notifications, overlays, theme } = const { application, chrome, uiSettings, notifications, overlays, theme, settings } =
coreMock.createStart(); coreMock.createStart();
const { http } = coreMock.createSetup(); const { http } = coreMock.createSetup();
const data = dataPluginMock.createStartContract(); const data = dataPluginMock.createStartContract();
@ -70,6 +70,7 @@ const createIndexPatternManagmentContext = (): {
application, application,
chrome, chrome,
uiSettings, uiSettings,
settings,
notifications, notifications,
overlays, overlays,
http, http,

View file

@ -26,12 +26,14 @@ import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { SpacesPluginStart } from '@kbn/spaces-plugin/public'; import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { IndexPatternManagementStart } from '.'; import { IndexPatternManagementStart } from '.';
export interface IndexPatternManagmentContext { export interface IndexPatternManagmentContext {
application: ApplicationStart; application: ApplicationStart;
chrome: ChromeStart; chrome: ChromeStart;
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
notifications: NotificationsStart; notifications: NotificationsStart;
overlays: OverlayStart; overlays: OverlayStart;
http: HttpSetup; http: HttpSetup;

View file

@ -33,6 +33,7 @@
"@kbn/utility-types-jest", "@kbn/utility-types-jest",
"@kbn/config-schema", "@kbn/config-schema",
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/core-ui-settings-browser",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -47,6 +47,7 @@ import type { SavedObjectsTaggingApi } from '@kbn/saved-objects-tagging-oss-plug
import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { LensPublicStart } from '@kbn/lens-plugin/public'; import type { LensPublicStart } from '@kbn/lens-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { getHistory } from './kibana_services'; import { getHistory } from './kibana_services';
import { DiscoverStartPlugins } from './plugin'; import { DiscoverStartPlugins } from './plugin';
import { DiscoverContextAppLocator } from './application/context/services/locator'; import { DiscoverContextAppLocator } from './application/context/services/locator';
@ -83,6 +84,7 @@ export interface DiscoverServices {
toastNotifications: ToastsStart; toastNotifications: ToastsStart;
notifications: NotificationsStart; notifications: NotificationsStart;
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void; trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
dataViewFieldEditor: IndexPatternFieldEditorStart; dataViewFieldEditor: IndexPatternFieldEditorStart;
dataViewEditor: DataViewEditorStart; dataViewEditor: DataViewEditorStart;
@ -137,6 +139,7 @@ export const buildServices = memoize(function (
toastNotifications: core.notifications.toasts, toastNotifications: core.notifications.toasts,
notifications: core.notifications, notifications: core.notifications,
uiSettings: core.uiSettings, uiSettings: core.uiSettings,
settings: core.settings,
storage, storage,
trackUiMetric: usageCollection?.reportUiCounter.bind(usageCollection, 'discover'), trackUiMetric: usageCollection?.reportUiCounter.bind(usageCollection, 'discover'),
dataViewFieldEditor: plugins.dataViewFieldEditor, dataViewFieldEditor: plugins.dataViewFieldEditor,

View file

@ -17,6 +17,11 @@ import { buildDataTableRecord } from '../../utils/build_data_record';
import { EsHitRecord } from '../../types'; import { EsHitRecord } from '../../types';
const mockServices = { const mockServices = {
settings: {
client: {
get: (key: string) => key === 'discover:maxDocFieldsDisplayed' && 200,
},
},
uiSettings: { uiSettings: {
get: (key: string) => key === 'discover:maxDocFieldsDisplayed' && 200, get: (key: string) => key === 'discover:maxDocFieldsDisplayed' && 200,
}, },

View file

@ -105,6 +105,7 @@ export class InspectorPublicPlugin implements Plugin<Setup, Start> {
http: core.http, http: core.http,
uiSettings: core.uiSettings, uiSettings: core.uiSettings,
share: startDeps.share, share: startDeps.share,
settings: core.settings,
}} }}
/>, />,
{ theme$: core.theme.theme$ } { theme$: core.theme.theme$ }

View file

@ -15,6 +15,8 @@ import type { ApplicationStart, HttpSetup, IUiSettingsClient } from '@kbn/core/p
import { SharePluginStart } from '@kbn/share-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public';
import { sharePluginMock } from '@kbn/share-plugin/public/mocks'; import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
import { applicationServiceMock } from '@kbn/core/public/mocks'; import { applicationServiceMock } from '@kbn/core/public/mocks';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
describe('InspectorPanel', () => { describe('InspectorPanel', () => {
let adapters: Adapters; let adapters: Adapters;
@ -24,11 +26,13 @@ describe('InspectorPanel', () => {
http: {}, http: {},
share: sharePluginMock.createStartContract(), share: sharePluginMock.createStartContract(),
uiSettings: {}, uiSettings: {},
settings: settingsServiceMock.createStartContract(),
} as unknown as { } as unknown as {
application: ApplicationStart; application: ApplicationStart;
http: HttpSetup; http: HttpSetup;
share: SharePluginStart; share: SharePluginStart;
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
}; };
beforeEach(() => { beforeEach(() => {

View file

@ -21,6 +21,7 @@ import {
import { ApplicationStart, HttpStart, IUiSettingsClient } from '@kbn/core/public'; import { ApplicationStart, HttpStart, IUiSettingsClient } from '@kbn/core/public';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { InspectorViewDescription } from '../types'; import { InspectorViewDescription } from '../types';
import { Adapters } from '../../common'; import { Adapters } from '../../common';
import { InspectorViewChooser } from './inspector_view_chooser'; import { InspectorViewChooser } from './inspector_view_chooser';
@ -46,6 +47,7 @@ interface InspectorPanelProps {
http: HttpStart; http: HttpStart;
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
share: SharePluginStart; share: SharePluginStart;
settings: SettingsStart;
}; };
} }

View file

@ -12,6 +12,8 @@
"@kbn/test-jest-helpers", "@kbn/test-jest-helpers",
"@kbn/i18n-react", "@kbn/i18n-react",
"@kbn/monaco", "@kbn/monaco",
"@kbn/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-browser",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -22,8 +22,8 @@ useObservableSpy.mockImplementation((observable, def) => def);
const mock = (): [KibanaServices, Subject<any>] => { const mock = (): [KibanaServices, Subject<any>] => {
const core = coreMock.createStart(); const core = coreMock.createStart();
const get = core.uiSettings.get; const get = core.settings.client.get;
const get$ = core.uiSettings.get$; const get$ = core.settings.client.get$;
const subject = new Subject(); const subject = new Subject();
get.mockImplementation(() => 'bar'); get.mockImplementation(() => 'bar');
@ -73,8 +73,8 @@ describe('useUiSetting', () => {
const strong = container!.querySelector('strong'); const strong = container!.querySelector('strong');
expect(strong!.textContent).toBe('bar'); expect(strong!.textContent).toBe('bar');
expect(core.uiSettings!.get).toHaveBeenCalledTimes(1); expect(core.settings!.client.get).toHaveBeenCalledTimes(1);
expect((core.uiSettings!.get as any).mock.calls[0][0]).toBe('foo'); expect((core.settings!.client.get as any).mock.calls[0][0]).toBe('foo');
}); });
test('calls uiSettings.get() method with correct key and default value', async () => { test('calls uiSettings.get() method with correct key and default value', async () => {
@ -88,9 +88,10 @@ describe('useUiSetting', () => {
container container
); );
expect(core.uiSettings!.get).toHaveBeenCalledTimes(1); expect(core.uiSettings!.get).toHaveBeenCalledTimes(0);
expect((core.uiSettings!.get as any).mock.calls[0][0]).toBe('foo'); expect(core.settings!.client.get).toHaveBeenCalledTimes(1);
expect((core.uiSettings!.get as any).mock.calls[0][1]).toBe('DEFAULT'); expect((core.settings!.client.get as any).mock.calls[0][0]).toBe('foo');
expect((core.settings!.client.get as any).mock.calls[0][1]).toBe('DEFAULT');
}); });
}); });
@ -183,8 +184,8 @@ describe('useUiSetting$', () => {
const strong = container!.querySelector('strong'); const strong = container!.querySelector('strong');
expect(strong!.textContent).toBe('bar'); expect(strong!.textContent).toBe('bar');
expect(core.uiSettings!.get).toHaveBeenCalledTimes(1); expect(core.settings!.client.get).toHaveBeenCalledTimes(1);
expect((core.uiSettings!.get as any).mock.calls[0][0]).toBe('foo'); expect((core.settings!.client.get as any).mock.calls[0][0]).toBe('foo');
}); });
test('calls Core with correct arguments', async () => { test('calls Core with correct arguments', async () => {
@ -198,7 +199,7 @@ describe('useUiSetting$', () => {
container container
); );
expect(core.uiSettings!.get).toHaveBeenCalledWith('non_existing', 'DEFAULT'); expect(core.settings!.client.get).toHaveBeenCalledWith('non_existing', 'DEFAULT');
}); });
test('subscribes to observable using useObservable', async () => { test('subscribes to observable using useObservable', async () => {
@ -235,7 +236,7 @@ describe('useUiSetting$', () => {
Simulate.click(container!.querySelector('button')!, {}); Simulate.click(container!.querySelector('button')!, {});
}); });
expect(core.uiSettings!.set).toHaveBeenCalledTimes(1); expect(core.settings!.client.set).toHaveBeenCalledTimes(1);
expect(core.uiSettings!.set).toHaveBeenCalledWith('a', 'c'); expect(core.settings!.client.set).toHaveBeenCalledWith('a', 'c');
}); });
}); });

View file

@ -20,13 +20,15 @@ import { useKibana } from '../context';
* ``` * ```
*/ */
export const useUiSetting = <T>(key: string, defaultValue?: T): T => { export const useUiSetting = <T>(key: string, defaultValue?: T): T => {
const { services } = useKibana(); const {
services: { settings },
} = useKibana();
if (typeof services.uiSettings !== 'object') { if (!settings) {
throw new TypeError('uiSettings service not available in kibana-react context.'); throw new TypeError('uiSettings service not available in kibana-react context.');
} }
return services.uiSettings.get(key, defaultValue); return settings.client.get(key, defaultValue);
}; };
/** /**
@ -39,13 +41,15 @@ export const useUiSetting = <T>(key: string, defaultValue?: T): T => {
* ``` * ```
*/ */
export const useGlobalUiSetting = <T>(key: string, defaultValue?: T): T => { export const useGlobalUiSetting = <T>(key: string, defaultValue?: T): T => {
const { services } = useKibana(); const {
services: { settings },
} = useKibana();
if (typeof services.settings !== 'object') { if (!settings) {
throw new TypeError('uiSettings service not available in kibana-react context.'); throw new TypeError('uiSettings service not available in kibana-react context.');
} }
return services.settings.globalClient.get(key, defaultValue); return settings.globalClient.get(key, defaultValue);
}; };
type Setter<T> = (newValue: T) => Promise<boolean>; type Setter<T> = (newValue: T) => Promise<boolean>;
@ -64,18 +68,20 @@ type Setter<T> = (newValue: T) => Promise<boolean>;
* ``` * ```
*/ */
export const useUiSetting$ = <T>(key: string, defaultValue?: T): [T, Setter<T>] => { export const useUiSetting$ = <T>(key: string, defaultValue?: T): [T, Setter<T>] => {
const { services } = useKibana(); const {
services: { settings },
} = useKibana();
if (typeof services.uiSettings !== 'object') { if (!settings) {
throw new TypeError('uiSettings service not available in kibana-react context.'); throw new TypeError('uiSettings service not available in kibana-react context.');
} }
const observable$ = useMemo( const observable$ = useMemo(
() => services.uiSettings!.get$(key, defaultValue), () => settings!.client.get$(key, defaultValue),
[key, defaultValue, services.uiSettings] [key, defaultValue, settings]
); );
const value = useObservable<T>(observable$, services.uiSettings!.get(key, defaultValue)); const value = useObservable<T>(observable$, settings!.client.get(key, defaultValue));
const set = useCallback((newValue: T) => services.uiSettings!.set(key, newValue), [key]); const set = useCallback((newValue: T) => settings!.client.set(key, newValue), [key]);
return [value, set]; return [value, set];
}; };
@ -94,24 +100,20 @@ export const useUiSetting$ = <T>(key: string, defaultValue?: T): [T, Setter<T>]
* ``` * ```
*/ */
export const useGlobalUiSetting$ = <T>(key: string, defaultValue?: T): [T, Setter<T>] => { export const useGlobalUiSetting$ = <T>(key: string, defaultValue?: T): [T, Setter<T>] => {
const { services } = useKibana(); const {
services: { settings },
} = useKibana();
if (typeof services.settings !== 'object') { if (!settings) {
throw new TypeError('uiSettings service not available in kibana-react context.'); throw new TypeError('uiSettings service not available in kibana-react context.');
} }
const observable$ = useMemo( const observable$ = useMemo(
() => services.settings!.globalClient.get$(key, defaultValue), () => settings!.globalClient.get$(key, defaultValue),
[key, defaultValue, services.settings!.globalClient] [key, defaultValue, settings!.globalClient]
);
const value = useObservable<T>(
observable$,
services.settings!.globalClient.get(key, defaultValue)
);
const set = useCallback(
(newValue: T) => services.settings!.globalClient.set(key, newValue),
[key]
); );
const value = useObservable<T>(observable$, settings!.globalClient.get(key, defaultValue));
const set = useCallback((newValue: T) => settings!.globalClient.set(key, newValue), [key]);
return [value, set]; return [value, set];
}; };

View file

@ -4,6 +4,34 @@ exports[`SavedObjectEdition should render normally 1`] = `
<Provider <Provider
services={ services={
Object { Object {
"settings": Object {
"client": Object {
"get": [MockFunction],
"get$": [MockFunction],
"getAll": [MockFunction],
"getUpdate$": [MockFunction],
"getUpdateErrors$": [MockFunction],
"isCustom": [MockFunction],
"isDeclared": [MockFunction],
"isDefault": [MockFunction],
"isOverridden": [MockFunction],
"remove": [MockFunction],
"set": [MockFunction],
},
"globalClient": Object {
"get": [MockFunction],
"get$": [MockFunction],
"getAll": [MockFunction],
"getUpdate$": [MockFunction],
"getUpdateErrors$": [MockFunction],
"isCustom": [MockFunction],
"isDeclared": [MockFunction],
"isDefault": [MockFunction],
"isOverridden": [MockFunction],
"remove": [MockFunction],
"set": [MockFunction],
},
},
"uiSettings": Object { "uiSettings": Object {
"get": [MockFunction], "get": [MockFunction],
"get$": [MockFunction], "get$": [MockFunction],

View file

@ -28,6 +28,7 @@ import {
SavedObjectEditionProps, SavedObjectEditionProps,
SavedObjectEditionState, SavedObjectEditionState,
} from './saved_object_view'; } from './saved_object_view';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
const resolvePromises = () => new Promise((resolve) => process.nextTick(resolve)); const resolvePromises = () => new Promise((resolve) => process.nextTick(resolve));
@ -40,6 +41,7 @@ describe('SavedObjectEdition', () => {
let history: ReturnType<typeof scopedHistoryMock.create>; let history: ReturnType<typeof scopedHistoryMock.create>;
let applications: ReturnType<typeof applicationServiceMock.createStartContract>; let applications: ReturnType<typeof applicationServiceMock.createStartContract>;
let docLinks: ReturnType<typeof docLinksServiceMock.createStartContract>; let docLinks: ReturnType<typeof docLinksServiceMock.createStartContract>;
let settings: ReturnType<typeof settingsServiceMock.createStartContract>;
const shallowRender = (overrides: Partial<SavedObjectEditionProps> = {}) => { const shallowRender = (overrides: Partial<SavedObjectEditionProps> = {}) => {
return shallowWithI18nProvider( return shallowWithI18nProvider(
@ -56,6 +58,7 @@ describe('SavedObjectEdition', () => {
overlays = overlayServiceMock.createStartContract(); overlays = overlayServiceMock.createStartContract();
notifications = notificationServiceMock.createStartContract(); notifications = notificationServiceMock.createStartContract();
uiSettings = uiSettingsServiceMock.createStartContract(); uiSettings = uiSettingsServiceMock.createStartContract();
settings = settingsServiceMock.createStartContract();
history = scopedHistoryMock.create(); history = scopedHistoryMock.create();
docLinks = docLinksServiceMock.createStartContract(); docLinks = docLinksServiceMock.createStartContract();
applications = applicationServiceMock.createStartContract(); applications = applicationServiceMock.createStartContract();
@ -82,6 +85,7 @@ describe('SavedObjectEdition', () => {
history, history,
uiSettings, uiSettings,
docLinks: docLinks.links, docLinks: docLinks.links,
settings,
}; };
bulkDeleteObjectsMock.mockResolvedValue([{}]); bulkDeleteObjectsMock.mockResolvedValue([{}]);

View file

@ -20,10 +20,12 @@ import {
IUiSettingsClient, IUiSettingsClient,
DocLinksStart, DocLinksStart,
} from '@kbn/core/public'; } from '@kbn/core/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { Header, Inspect, NotFoundErrors } from './components'; import { Header, Inspect, NotFoundErrors } from './components';
import { bulkDeleteObjects, bulkGetObjects } from '../../lib'; import { bulkDeleteObjects, bulkGetObjects } from '../../lib';
import { SavedObjectWithMetadata } from '../../types'; import { SavedObjectWithMetadata } from '../../types';
import './saved_object_view.scss'; import './saved_object_view.scss';
export interface SavedObjectEditionProps { export interface SavedObjectEditionProps {
id: string; id: string;
savedObjectType: string; savedObjectType: string;
@ -35,6 +37,7 @@ export interface SavedObjectEditionProps {
history: ScopedHistory; history: ScopedHistory;
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
docLinks: DocLinksStart['links']; docLinks: DocLinksStart['links'];
settings: SettingsStart;
} }
export interface SavedObjectEditionState { export interface SavedObjectEditionState {
type: string; type: string;
@ -91,12 +94,12 @@ export class SavedObjectEdition extends Component<
} }
render() { render() {
const { capabilities, notFoundType, http, uiSettings, docLinks } = this.props; const { capabilities, notFoundType, http, uiSettings, docLinks, settings } = this.props;
const { object } = this.state; const { object } = this.state;
const { delete: canDelete } = capabilities.savedObjectsManagement as Record<string, boolean>; const { delete: canDelete } = capabilities.savedObjectsManagement as Record<string, boolean>;
const canView = this.canViewInApp(capabilities, object); const canView = this.canViewInApp(capabilities, object);
return ( return (
<KibanaContextProvider services={{ uiSettings }}> <KibanaContextProvider services={{ uiSettings, settings }}>
<EuiFlexGroup <EuiFlexGroup
direction="column" direction="column"
data-test-subject="savedObjectsEdit" data-test-subject="savedObjectsEdit"

View file

@ -64,6 +64,7 @@ const SavedObjectsEditionPage = ({
uiSettings={coreStart.uiSettings} uiSettings={coreStart.uiSettings}
history={history} history={history}
docLinks={docLinks} docLinks={docLinks}
settings={coreStart.settings}
/> />
</RedirectAppLinks> </RedirectAppLinks>
); );

View file

@ -26,6 +26,8 @@
"@kbn/core-custom-branding-browser-mocks", "@kbn/core-custom-branding-browser-mocks",
"@kbn/core-custom-branding-browser", "@kbn/core-custom-branding-browser",
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-browser",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -22,6 +22,9 @@ describe('TextBasedLanguagesEditor', () => {
const services = { const services = {
uiSettings, uiSettings,
settings: {
client: uiSettings,
},
}; };
function renderTextBasedLanguagesEditorComponent(testProps: TextBasedLanguagesEditorProps) { function renderTextBasedLanguagesEditorComponent(testProps: TextBasedLanguagesEditorProps) {

View file

@ -89,6 +89,7 @@ function wrapSearchBarInContext(testProps: any) {
const services = { const services = {
uiSettings: startMock.uiSettings, uiSettings: startMock.uiSettings,
settings: startMock.settings,
savedObjects: startMock.savedObjects, savedObjects: startMock.savedObjects,
notifications: startMock.notifications, notifications: startMock.notifications,
http: startMock.http, http: startMock.http,

View file

@ -6,7 +6,6 @@
*/ */
import { IExternalUrl } from '@kbn/core/public'; import { IExternalUrl } from '@kbn/core/public';
import { uiSettingsServiceMock } from '@kbn/core/public/mocks';
import { UrlDrilldown, ActionContext, Config } from './url_drilldown'; import { UrlDrilldown, ActionContext, Config } from './url_drilldown';
import { import {
IEmbeddable, IEmbeddable,
@ -18,6 +17,7 @@ import { DatatableColumnType } from '@kbn/expressions-plugin/common';
import { of } from '@kbn/kibana-utils-plugin/common'; import { of } from '@kbn/kibana-utils-plugin/common';
import { createPoint, rowClickData, TestEmbeddable } from './test/data'; import { createPoint, rowClickData, TestEmbeddable } from './test/data';
import { ROW_CLICK_TRIGGER } from '@kbn/ui-actions-plugin/public'; import { ROW_CLICK_TRIGGER } from '@kbn/ui-actions-plugin/public';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
const mockDataPoints = [ const mockDataPoints = [
{ {
@ -84,7 +84,7 @@ const createDrilldown = (isExternalUrlValid: boolean = true) => {
getSyntaxHelpDocsLink: () => 'http://localhost:5601/docs', getSyntaxHelpDocsLink: () => 'http://localhost:5601/docs',
getVariablesHelpDocsLink: () => 'http://localhost:5601/docs', getVariablesHelpDocsLink: () => 'http://localhost:5601/docs',
navigateToUrl: mockNavigateToUrl, navigateToUrl: mockNavigateToUrl,
uiSettings: uiSettingsServiceMock.createSetupContract(), settings: settingsServiceMock.createSetupContract(),
}); });
return drilldown; return drilldown;
}; };

View file

@ -6,7 +6,7 @@
*/ */
import React from 'react'; import React from 'react';
import { IExternalUrl, IUiSettingsClient } from '@kbn/core/public'; import { IExternalUrl } from '@kbn/core/public';
import { import {
ChartActionContext, ChartActionContext,
CONTEXT_MENU_TRIGGER, CONTEXT_MENU_TRIGGER,
@ -30,6 +30,7 @@ import {
UiActionsEnhancedBaseActionFactoryContext as BaseActionFactoryContext, UiActionsEnhancedBaseActionFactoryContext as BaseActionFactoryContext,
} from '@kbn/ui-actions-enhanced-plugin/public'; } from '@kbn/ui-actions-enhanced-plugin/public';
import type { SerializedAction } from '@kbn/ui-actions-enhanced-plugin/common/types'; import type { SerializedAction } from '@kbn/ui-actions-enhanced-plugin/common/types';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { txtUrlDrilldownDisplayName } from './i18n'; import { txtUrlDrilldownDisplayName } from './i18n';
import { getEventVariableList, getEventScopeValues } from './variables/event_variables'; import { getEventVariableList, getEventScopeValues } from './variables/event_variables';
import { getContextVariableList, getContextScopeValues } from './variables/context_variables'; import { getContextVariableList, getContextScopeValues } from './variables/context_variables';
@ -50,7 +51,7 @@ interface UrlDrilldownDeps {
navigateToUrl: (url: string) => Promise<void>; navigateToUrl: (url: string) => Promise<void>;
getSyntaxHelpDocsLink: () => string; getSyntaxHelpDocsLink: () => string;
getVariablesHelpDocsLink: () => string; getVariablesHelpDocsLink: () => string;
uiSettings: IUiSettingsClient; settings: SettingsStart;
} }
export type ActionContext = ChartActionContext<EmbeddableWithQueryInput>; export type ActionContext = ChartActionContext<EmbeddableWithQueryInput>;
@ -122,7 +123,7 @@ export class UrlDrilldown implements Drilldown<Config, ActionContext, ActionFact
return ( return (
<KibanaContextProvider <KibanaContextProvider
services={{ services={{
uiSettings: this.deps.uiSettings, settings: this.deps.settings,
}} }}
> >
<UrlDrilldownCollectConfig <UrlDrilldownCollectConfig

View file

@ -48,7 +48,7 @@ export class UrlDrilldownPlugin
startServices().core.docLinks.links.dashboard.urlDrilldownTemplateSyntax, startServices().core.docLinks.links.dashboard.urlDrilldownTemplateSyntax,
getVariablesHelpDocsLink: () => getVariablesHelpDocsLink: () =>
startServices().core.docLinks.links.dashboard.urlDrilldownVariables, startServices().core.docLinks.links.dashboard.urlDrilldownVariables,
uiSettings: core.uiSettings, settings: core.settings,
}) })
); );

View file

@ -16,7 +16,9 @@
"@kbn/es-query", "@kbn/es-query",
"@kbn/monaco", "@kbn/monaco",
"@kbn/std", "@kbn/std",
"@kbn/image-embeddable-plugin" "@kbn/image-embeddable-plugin",
"@kbn/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-browser"
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -84,6 +84,12 @@ function mountDatePicker(initialParams: {
get: (key: string) => [], get: (key: string) => [],
get$: (key: string) => of(true), get$: (key: string) => of(true),
}, },
settings: {
client: {
get: (key: string) => [],
get$: (key: string) => of(true),
},
},
}} }}
> >
<DatePickerContextProvider> <DatePickerContextProvider>

View file

@ -30,6 +30,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
import { casesPluginMock } from '@kbn/cases-plugin/public/mocks'; import { casesPluginMock } from '@kbn/cases-plugin/public/mocks';
import { DataViewSpec } from '@kbn/data-views-plugin/public'; import { DataViewSpec } from '@kbn/data-views-plugin/public';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { rumFieldFormats } from './configurations/rum/field_formats'; import { rumFieldFormats } from './configurations/rum/field_formats';
import { ExploratoryViewPublicPluginsStart } from '../../../plugin'; import { ExploratoryViewPublicPluginsStart } from '../../../plugin';
import * as useAppDataViewHook from './hooks/use_app_data_view'; import * as useAppDataViewHook from './hooks/use_app_data_view';
@ -128,6 +129,14 @@ export const mockCore: () => Partial<CoreStart & ExploratoryViewPublicPluginsSta
get: getSetting, get: getSetting,
get$: setSetting$, get$: setSetting$,
}, },
settings: {
...settingsServiceMock.createStartContract(),
client: {
...settingsServiceMock.createStartContract().client,
get: getSetting,
get$: setSetting$,
},
},
lens: lensPluginMock.createStartContract(), lens: lensPluginMock.createStartContract(),
data: dataPluginMock.createStartContract(), data: dataPluginMock.createStartContract(),
dataViews: dataViewPluginMocks.createStartContract(), dataViews: dataViewPluginMocks.createStartContract(),

View file

@ -44,6 +44,7 @@
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/core-application-browser", "@kbn/core-application-browser",
"@kbn/observability-shared-plugin", "@kbn/observability-shared-plugin",
"@kbn/core-ui-settings-browser-mocks"
], ],
"exclude": ["target/**/*"] "exclude": ["target/**/*"]
} }

View file

@ -4,6 +4,9 @@ exports[`Should render error when upload fails from elasticsearch request failur
<Provider <Provider
services={ services={
Object { Object {
"settings": Object {
"get": [MockFunction],
},
"uiSettings": Object { "uiSettings": Object {
"get": [MockFunction], "get": [MockFunction],
}, },
@ -98,6 +101,9 @@ exports[`Should render error when upload fails from http request timeout 1`] = `
<Provider <Provider
services={ services={
Object { Object {
"settings": Object {
"get": [MockFunction],
},
"uiSettings": Object { "uiSettings": Object {
"get": [MockFunction], "get": [MockFunction],
}, },
@ -192,6 +198,9 @@ exports[`Should render success 1`] = `
<Provider <Provider
services={ services={
Object { Object {
"settings": Object {
"get": [MockFunction],
},
"uiSettings": Object { "uiSettings": Object {
"get": [MockFunction], "get": [MockFunction],
}, },
@ -349,6 +358,9 @@ exports[`Should render warning when some features failed import 1`] = `
<Provider <Provider
services={ services={
Object { Object {
"settings": Object {
"get": [MockFunction],
},
"uiSettings": Object { "uiSettings": Object {
"get": [MockFunction], "get": [MockFunction],
}, },

View file

@ -33,6 +33,11 @@ jest.mock('../kibana_services', () => ({
get: jest.fn(), get: jest.fn(),
}; };
}, },
getSettings: () => {
return {
get: jest.fn(),
};
},
})); }));
test('Should render success', () => { test('Should render success', () => {

View file

@ -20,12 +20,13 @@ import {
EuiTitle, EuiTitle,
} from '@elastic/eui'; } from '@elastic/eui';
import { CodeEditor, KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { CodeEditor, KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { getDocLinks, getHttp, getUiSettings } from '../kibana_services'; import { getDocLinks, getHttp, getUiSettings, getSettings } from '../kibana_services';
import { ImportResults } from '../importer'; import { ImportResults } from '../importer';
import { getPartialImportMessage } from './utils'; import { getPartialImportMessage } from './utils';
const services = { const services = {
uiSettings: getUiSettings(), uiSettings: getUiSettings(),
settings: getSettings(),
}; };
interface Props { interface Props {

View file

@ -19,4 +19,5 @@ export const getDocLinks = () => coreStart.docLinks;
export const getDataViewsService = () => pluginsStart.data.dataViews; export const getDataViewsService = () => pluginsStart.data.dataViews;
export const getHttp = () => coreStart.http; export const getHttp = () => coreStart.http;
export const getSavedObjectsClient = () => coreStart.savedObjects.client; export const getSavedObjectsClient = () => coreStart.savedObjects.client;
export const getUiSettings = () => coreStart.uiSettings; export const getUiSettings = () => coreStart.settings.client;
export const getSettings = () => coreStart.settings;

View file

@ -19,6 +19,7 @@ import {
import { GlobalFlyout } from '@kbn/es-ui-shared-plugin/public'; import { GlobalFlyout } from '@kbn/es-ui-shared-plugin/public';
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { MAJOR_VERSION } from '../../../common'; import { MAJOR_VERSION } from '../../../common';
import { AppContextProvider } from '../../../public/application/app_context'; import { AppContextProvider } from '../../../public/application/app_context';
import { httpService } from '../../../public/application/services/http'; import { httpService } from '../../../public/application/services/http';
@ -60,6 +61,7 @@ export const kibanaVersion = new SemVer(MAJOR_VERSION);
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings: uiSettingsServiceMock.createSetupContract(), uiSettings: uiSettingsServiceMock.createSetupContract(),
settings: settingsServiceMock.createStartContract(),
kibanaVersion: { kibanaVersion: {
get: () => kibanaVersion, get: () => kibanaVersion,
}, },

View file

@ -21,6 +21,7 @@ import {
} from '@kbn/core/public'; } from '@kbn/core/public';
import { SharePluginStart } from '@kbn/share-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { ExtensionsService } from '../services'; import { ExtensionsService } from '../services';
import { UiMetricService, NotificationService, HttpService } from './services'; import { UiMetricService, NotificationService, HttpService } from './services';
@ -46,6 +47,7 @@ export interface AppDependencies {
history: ScopedHistory; history: ScopedHistory;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
url: SharePluginStart['url']; url: SharePluginStart['url'];
docLinks: DocLinksStart; docLinks: DocLinksStart;
kibanaVersion: SemVer; kibanaVersion: SemVer;

View file

@ -63,6 +63,7 @@ export async function mountManagementSection(
chrome: { docTitle }, chrome: { docTitle },
uiSettings, uiSettings,
executionContext, executionContext,
settings,
} = core; } = core;
const { url } = startDependencies.share; const { url } = startDependencies.share;
@ -96,6 +97,7 @@ export async function mountManagementSection(
history, history,
setBreadcrumbs, setBreadcrumbs,
uiSettings, uiSettings,
settings,
url, url,
docLinks, docLinks,
kibanaVersion, kibanaVersion,

View file

@ -32,6 +32,8 @@
"@kbn/config-schema", "@kbn/config-schema",
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/core-http-router-server-mocks", "@kbn/core-http-router-server-mocks",
"@kbn/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-browser",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -15,6 +15,8 @@ import { NotificationsSetup, IUiSettingsClient, CoreTheme } from '@kbn/core/publ
import { ManagementAppMountParams } from '@kbn/management-plugin/public'; import { ManagementAppMountParams } from '@kbn/management-plugin/public';
import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { SharePluginStart } from '@kbn/share-plugin/public';
import type { FileUploadPluginStart } from '@kbn/file-upload-plugin/public'; import type { FileUploadPluginStart } from '@kbn/file-upload-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { KibanaContextProvider, KibanaThemeProvider } from '../shared_imports'; import { KibanaContextProvider, KibanaThemeProvider } from '../shared_imports';
import { ILicense } from '../types'; import { ILicense } from '../types';
@ -40,6 +42,7 @@ export interface AppServices {
notifications: NotificationsSetup; notifications: NotificationsSetup;
history: ManagementAppMountParams['history']; history: ManagementAppMountParams['history'];
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
share: SharePluginStart; share: SharePluginStart;
fileUpload: FileUploadPluginStart; fileUpload: FileUploadPluginStart;
application: ApplicationStart; application: ApplicationStart;

View file

@ -47,6 +47,7 @@ export async function mountManagementSection(
notifications, notifications,
history, history,
uiSettings: coreStart.uiSettings, uiSettings: coreStart.uiSettings,
settings: coreStart.settings,
share: depsStart.share, share: depsStart.share,
fileUpload: depsStart.fileUpload, fileUpload: depsStart.fileUpload,
application, application,

View file

@ -29,6 +29,7 @@
"@kbn/test-jest-helpers", "@kbn/test-jest-helpers",
"@kbn/config-schema", "@kbn/config-schema",
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/core-ui-settings-browser",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -124,6 +124,7 @@ export async function getLensServices(
chrome: coreStart.chrome, chrome: coreStart.chrome,
overlays: coreStart.overlays, overlays: coreStart.overlays,
uiSettings: coreStart.uiSettings, uiSettings: coreStart.uiSettings,
settings: coreStart.settings,
application: coreStart.application, application: coreStart.application,
notifications: coreStart.notifications, notifications: coreStart.notifications,
savedObjectStore: new SavedObjectIndexStore(startDependencies.contentManagement.client), savedObjectStore: new SavedObjectIndexStore(startDependencies.contentManagement.client),

View file

@ -45,6 +45,7 @@ import type { ChartsPluginSetup } from '@kbn/charts-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { DocLinksStart } from '@kbn/core-doc-links-browser'; import type { DocLinksStart } from '@kbn/core-doc-links-browser';
import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { SharePluginStart } from '@kbn/share-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import type { import type {
DatasourceMap, DatasourceMap,
EditorFrameInstance, EditorFrameInstance,
@ -149,6 +150,7 @@ export interface LensAppServices {
data: DataPublicPluginStart; data: DataPublicPluginStart;
inspector: LensInspector; inspector: LensInspector;
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
uiActions: UiActionsStart; uiActions: UiActionsStart;
application: ApplicationStart; application: ApplicationStart;
notifications: NotificationsStart; notifications: NotificationsStart;

View file

@ -168,7 +168,7 @@ export function getFormBasedDatasource({
dataViewFieldEditor: IndexPatternFieldEditorStart; dataViewFieldEditor: IndexPatternFieldEditorStart;
uiActions: UiActionsStart; uiActions: UiActionsStart;
}) { }) {
const uiSettings = core.uiSettings; const { uiSettings, settings } = core;
const DATASOURCE_ID = 'formBased'; const DATASOURCE_ID = 'formBased';
@ -535,6 +535,7 @@ export function getFormBasedDatasource({
appName: 'lens', appName: 'lens',
storage, storage,
uiSettings, uiSettings,
settings,
data, data,
fieldFormats, fieldFormats,
savedObjects: core.savedObjects, savedObjects: core.savedObjects,
@ -564,6 +565,7 @@ export function getFormBasedDatasource({
appName: 'lens', appName: 'lens',
storage, storage,
uiSettings, uiSettings,
settings,
data, data,
fieldFormats, fieldFormats,
savedObjects: core.savedObjects, savedObjects: core.savedObjects,

View file

@ -29,6 +29,7 @@ import type { EmbeddableStateTransfer } from '@kbn/embeddable-plugin/public';
import { presentationUtilPluginMock } from '@kbn/presentation-util-plugin/public/mocks'; import { presentationUtilPluginMock } from '@kbn/presentation-util-plugin/public/mocks';
import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import type { LensAttributeService } from '../lens_attribute_service'; import type { LensAttributeService } from '../lens_attribute_service';
import type { import type {
LensByValueInput, LensByValueInput,
@ -139,6 +140,7 @@ export function makeDefaultServices(
chrome: core.chrome, chrome: core.chrome,
overlays: core.overlays, overlays: core.overlays,
uiSettings: core.uiSettings, uiSettings: core.uiSettings,
settings: settingsServiceMock.createStartContract(),
executionContext: core.executionContext, executionContext: core.executionContext,
navigation: navigationStartMock, navigation: navigationStartMock,
notifications: core.notifications, notifications: core.notifications,

View file

@ -66,6 +66,7 @@
"@kbn/safer-lodash-set", "@kbn/safer-lodash-set",
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/dom-drag-drop", "@kbn/dom-drag-drop",
"@kbn/core-ui-settings-browser-mocks",
"@kbn/visualization-ui-components", "@kbn/visualization-ui-components",
"@kbn/content-management-plugin", "@kbn/content-management-plugin",
"@kbn/core-saved-objects-api-server", "@kbn/core-saved-objects-api-server",

View file

@ -18,6 +18,7 @@ const kibanaServices = {
application: { getUrlForApp: () => {}, navigateToApp: () => {} }, application: { getUrlForApp: () => {}, navigateToApp: () => {} },
chrome: { setBreadcrumbs, docTitle: { change: setTitle } }, chrome: { setBreadcrumbs, docTitle: { change: setTitle } },
uiSettings: { get: () => true }, uiSettings: { get: () => true },
settings: { client: { get: () => true } },
} as unknown as Partial<CoreStart>; } as unknown as Partial<CoreStart>;
const KibanaContext = createKibanaReactContext(kibanaServices); const KibanaContext = createKibanaReactContext(kibanaServices);

View file

@ -20,6 +20,7 @@ interface AppDependencies {
http: HttpSetup; http: HttpSetup;
I18nContext: CoreStart['i18n']['Context']; I18nContext: CoreStart['i18n']['Context'];
uiSettings: CoreSetup['uiSettings']; uiSettings: CoreSetup['uiSettings'];
settings: CoreStart['settings'];
links: Links; links: Links;
chrome: ChromeStart; chrome: ChromeStart;
theme$: Observable<CoreTheme>; theme$: Observable<CoreTheme>;
@ -27,13 +28,14 @@ interface AppDependencies {
export function renderApp( export function renderApp(
element: HTMLElement | null, element: HTMLElement | null,
{ http, I18nContext, uiSettings, links, chrome, theme$ }: AppDependencies { http, I18nContext, uiSettings, links, chrome, theme$, settings }: AppDependencies
) { ) {
if (!element) { if (!element) {
return () => undefined; return () => undefined;
} }
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings, uiSettings,
settings,
}); });
render( render(
<I18nContext> <I18nContext>

View file

@ -56,6 +56,7 @@ export class PainlessLabUIPlugin implements Plugin<void, void, PluginDependencie
notifications, notifications,
docLinks, docLinks,
chrome, chrome,
settings,
} = core; } = core;
const license = await firstValueFrom(licensing.license$); const license = await firstValueFrom(licensing.license$);
@ -75,6 +76,7 @@ export class PainlessLabUIPlugin implements Plugin<void, void, PluginDependencie
links: getLinks(docLinks), links: getLinks(docLinks),
chrome, chrome,
theme$, theme$,
settings,
}); });
return () => { return () => {

View file

@ -22,8 +22,11 @@ export const getRuntimeFieldEditorLoader =
(coreSetup: CoreSetup) => async (): Promise<LoadEditorResponse> => { (coreSetup: CoreSetup) => async (): Promise<LoadEditorResponse> => {
const { RuntimeFieldEditorFlyoutContent } = await import('./components'); const { RuntimeFieldEditorFlyoutContent } = await import('./components');
const [core] = await coreSetup.getStartServices(); const [core] = await coreSetup.getStartServices();
const { uiSettings, theme, overlays, docLinks } = core; const { uiSettings, theme, overlays, docLinks, settings } = core;
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ uiSettings }); const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings,
settings,
});
let overlayRef: OverlayRef | null = null; let overlayRef: OverlayRef | null = null;

View file

@ -97,6 +97,7 @@ export const createStartServicesMock = (
core: ReturnType<typeof coreMock.createStart> = coreMock.createStart() core: ReturnType<typeof coreMock.createStart> = coreMock.createStart()
): StartServices => { ): StartServices => {
core.uiSettings.get.mockImplementation(createUseUiSettingMock()); core.uiSettings.get.mockImplementation(createUseUiSettingMock());
core.settings.client.get.mockImplementation(createUseUiSettingMock());
const { storage } = createSecuritySolutionStorageMock(); const { storage } = createSecuritySolutionStorageMock();
const apm = mockApm(); const apm = mockApm();
const data = dataPluginMock.createStartContract(); const data = dataPluginMock.createStartContract();

View file

@ -131,7 +131,7 @@ export class Simulator {
// Used for `KibanaContextProvider` // Used for `KibanaContextProvider`
const coreStart = coreMock.createStart(); const coreStart = coreMock.createStart();
coreStart.uiSettings.get.mockImplementation(uiSetting); coreStart.settings.client.get.mockImplementation(uiSetting);
this.sideEffectSimulator = sideEffectSimulatorFactory(); this.sideEffectSimulator = sideEffectSimulatorFactory();

View file

@ -20,7 +20,7 @@ describe(`useFormattedDate, when the "dateFormat" UI setting is "${uiSetting(
return <span data-test-subj="useFormattedDateTest">{useFormattedDate(date)}</span>; return <span data-test-subj="useFormattedDateTest">{useFormattedDate(date)}</span>;
} }
const mockCoreStart = coreMock.createStart(); const mockCoreStart = coreMock.createStart();
mockCoreStart.uiSettings.get.mockImplementation(uiSetting); mockCoreStart.settings.client.get.mockImplementation(uiSetting);
it.each([ it.each([
['randomString', 'an invalid string', 'Invalid Date'], ['randomString', 'an invalid string', 'Invalid Date'],

View file

@ -64,6 +64,7 @@ const appDependencies = {
const kibanaContextDependencies = { const kibanaContextDependencies = {
uiSettings: core.uiSettings, uiSettings: core.uiSettings,
settings: core.settings,
}; };
export const setupEnvironment = () => { export const setupEnvironment = () => {

View file

@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { CoreStart, ScopedHistory, CoreTheme, IUiSettingsClient } from '@kbn/core/public'; import { CoreStart, ScopedHistory, CoreTheme, IUiSettingsClient } from '@kbn/core/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { ClientConfigType } from '../types'; import { ClientConfigType } from '../types';
import { HttpService, UiMetricService } from './services'; import { HttpService, UiMetricService } from './services';
@ -19,6 +20,7 @@ export interface AppDependencies {
core: CoreStart; core: CoreStart;
services: { services: {
uiSettings: IUiSettingsClient; uiSettings: IUiSettingsClient;
settings: SettingsStart;
httpService: HttpService; httpService: HttpService;
uiMetricService: UiMetricService; uiMetricService: UiMetricService;
i18n: typeof i18n; i18n: typeof i18n;

View file

@ -28,6 +28,7 @@ export async function mountManagementSection(
const [core] = await coreSetup.getStartServices(); const [core] = await coreSetup.getStartServices();
const { const {
chrome: { docTitle }, chrome: { docTitle },
settings,
} = core; } = core;
docTitleService.setup(docTitle.change); docTitleService.setup(docTitle.change);
@ -38,6 +39,7 @@ export async function mountManagementSection(
config, config,
services: { services: {
uiSettings: coreSetup.uiSettings, uiSettings: coreSetup.uiSettings,
settings,
httpService, httpService,
uiMetricService: services.uiMetricService, uiMetricService: services.uiMetricService,
i18n, i18n,

View file

@ -30,6 +30,7 @@
"@kbn/analytics", "@kbn/analytics",
"@kbn/config-schema", "@kbn/config-schema",
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/core-ui-settings-browser",
"@kbn/core-http-router-server-mocks", "@kbn/core-http-router-server-mocks",
], ],
"exclude": [ "exclude": [

View file

@ -129,6 +129,14 @@ export const mockCore: () => Partial<CoreStart> = () => {
get: getSetting, get: getSetting,
get$: setSetting$, get$: setSetting$,
}, },
settings: {
client: {
...defaultCore.settings.client,
get: getSetting,
get$: setSetting$,
},
globalClient: defaultCore.settings.globalClient,
},
usageCollection: { usageCollection: {
reportUiCounter: () => {}, reportUiCounter: () => {},
}, },

View file

@ -127,6 +127,14 @@ export const mockCore: () => Partial<CoreStart> = () => {
get: getSetting, get: getSetting,
get$: setSetting$, get$: setSetting$,
}, },
settings: {
client: {
...defaultCore.settings.client,
get: getSetting,
get$: setSetting$,
},
globalClient: defaultCore.settings.globalClient,
},
usageCollection: { usageCollection: {
reportUiCounter: () => {}, reportUiCounter: () => {},
}, },

View file

@ -13,6 +13,7 @@ import { TimelinesUIStart } from '@kbn/timelines-plugin/public';
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
import { RequestAdapter } from '@kbn/inspector-plugin/common'; import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { mockIndicatorsFiltersContext } from './mock_indicators_filters_context'; import { mockIndicatorsFiltersContext } from './mock_indicators_filters_context';
import { SecuritySolutionContext } from '../../containers/security_solution_context'; import { SecuritySolutionContext } from '../../containers/security_solution_context';
import { getSecuritySolutionContextMock } from './mock_security_context'; import { getSecuritySolutionContextMock } from './mock_security_context';
@ -34,6 +35,8 @@ export interface KibanaContextMock {
* For the core ui-settings package (see {@link IUiSettingsClient}) * For the core ui-settings package (see {@link IUiSettingsClient})
*/ */
uiSettings?: IUiSettingsClient; uiSettings?: IUiSettingsClient;
settings?: SettingsStart;
/** /**
* For the timelines plugin * For the timelines plugin
*/ */
@ -60,6 +63,7 @@ const securityLayout = {
const defaultServices = { const defaultServices = {
uiSettings: mockUiSettingsService(), uiSettings: mockUiSettingsService(),
settings: { client: mockUiSettingsService() },
timelines: mockKibanaTimelinesService, timelines: mockKibanaTimelinesService,
triggersActionsUi: mockTriggersActionsUiService, triggersActionsUi: mockTriggersActionsUiService,
storage: { storage: {

View file

@ -107,6 +107,7 @@ const core = coreMock.createStart();
const coreServiceMock = { const coreServiceMock = {
...core, ...core,
uiSettings: { get: jest.fn().mockImplementation(mockUiSetting) }, uiSettings: { get: jest.fn().mockImplementation(mockUiSetting) },
settings: { client: { get: jest.fn().mockImplementation(mockUiSetting) } },
}; };
const mockSecurityContext: SecuritySolutionPluginContext = getSecuritySolutionContextMock(); const mockSecurityContext: SecuritySolutionPluginContext = getSecuritySolutionContextMock();

View file

@ -125,7 +125,12 @@ const mockOnFieldChange = function (value: EuiComboBoxOptionOption<string>): voi
export const Default: Story<void> = () => { export const Default: Story<void> = () => {
return ( return (
<StoryProvidersComponent <StoryProvidersComponent
kibana={{ data: dataServiceMock, uiSettings: uiSettingsMock, timelines: timelinesMock }} kibana={{
data: dataServiceMock,
uiSettings: uiSettingsMock,
timelines: timelinesMock,
settings: { client: uiSettingsMock, globalClient: uiSettingsMock },
}}
> >
<IndicatorsBarChartWrapper <IndicatorsBarChartWrapper
dateRange={{ min: moment(), max: moment() }} dateRange={{ min: moment(), max: moment() }}
@ -144,7 +149,12 @@ Default.decorators = [(story) => <MemoryRouter>{story()}</MemoryRouter>];
export const InitialLoad: Story<void> = () => { export const InitialLoad: Story<void> = () => {
return ( return (
<StoryProvidersComponent <StoryProvidersComponent
kibana={{ data: dataServiceMock, uiSettings: uiSettingsMock, timelines: timelinesMock }} kibana={{
data: dataServiceMock,
uiSettings: uiSettingsMock,
timelines: timelinesMock,
settings: { client: uiSettingsMock, globalClient: uiSettingsMock },
}}
> >
<IndicatorsBarChartWrapper <IndicatorsBarChartWrapper
dateRange={{ min: moment(), max: moment() }} dateRange={{ min: moment(), max: moment() }}
@ -188,7 +198,12 @@ export const UpdatingData: Story<void> = () => {
return ( return (
<StoryProvidersComponent <StoryProvidersComponent
kibana={{ data: dataServiceMock, uiSettings: uiSettingsMock, timelines: timelinesMock }} kibana={{
data: dataServiceMock,
uiSettings: uiSettingsMock,
settings: { client: uiSettingsMock, globalClient: uiSettingsMock },
timelines: timelinesMock,
}}
> >
<IndicatorsBarChartWrapper <IndicatorsBarChartWrapper
dateRange={{ min: moment(), max: moment() }} dateRange={{ min: moment(), max: moment() }}

View file

@ -31,7 +31,8 @@
"@kbn/kibana-react-plugin", "@kbn/kibana-react-plugin",
"@kbn/utility-types", "@kbn/utility-types",
"@kbn/ui-theme", "@kbn/ui-theme",
"@kbn/securitysolution-io-ts-list-types" "@kbn/securitysolution-io-ts-list-types",
"@kbn/core-ui-settings-browser"
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -29,6 +29,7 @@ import type { AppDependencies } from '../app_dependencies';
import { MlSharedContext } from './shared_context'; import { MlSharedContext } from './shared_context';
import type { GetMlSharedImportsReturnType } from '../../shared_imports'; import type { GetMlSharedImportsReturnType } from '../../shared_imports';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
const coreSetup = coreMock.createSetup(); const coreSetup = coreMock.createSetup();
const coreStart = coreMock.createStart(); const coreStart = coreMock.createStart();
@ -91,6 +92,7 @@ const appDependencies: AppDependencies = {
triggersActionsUi: {} as jest.Mocked<TriggersAndActionsUIPublicPluginStart>, triggersActionsUi: {} as jest.Mocked<TriggersAndActionsUIPublicPluginStart>,
unifiedSearch: {} as jest.Mocked<UnifiedSearchPublicPluginStart>, unifiedSearch: {} as jest.Mocked<UnifiedSearchPublicPluginStart>,
savedObjectsManagement: {} as jest.Mocked<SavedObjectsManagementPluginStart>, savedObjectsManagement: {} as jest.Mocked<SavedObjectsManagementPluginStart>,
settings: settingsServiceMock.createStartContract(),
}; };
export const useAppDependencies = () => { export const useAppDependencies = () => {

View file

@ -33,6 +33,7 @@ import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
import { ChartsPluginStart } from '@kbn/charts-plugin/public'; import { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import type { GetMlSharedImportsReturnType } from '../shared_imports'; import type { GetMlSharedImportsReturnType } from '../shared_imports';
export interface AppDependencies { export interface AppDependencies {
@ -60,6 +61,7 @@ export interface AppDependencies {
unifiedSearch: UnifiedSearchPublicPluginStart; unifiedSearch: UnifiedSearchPublicPluginStart;
usageCollection?: UsageCollectionStart; usageCollection?: UsageCollectionStart;
savedObjectsManagement: SavedObjectsManagementPluginStart; savedObjectsManagement: SavedObjectsManagementPluginStart;
settings: SettingsStart;
} }
export const useAppDependencies = () => { export const useAppDependencies = () => {

View file

@ -37,6 +37,7 @@ export async function mountManagementSection(
theme, theme,
savedObjects, savedObjects,
uiSettings, uiSettings,
settings,
notifications, notifications,
} = core; } = core;
const { const {
@ -72,6 +73,7 @@ export async function mountManagementSection(
savedObjects, savedObjects,
storage: localStorage, storage: localStorage,
uiSettings, uiSettings,
settings,
history, history,
savedObjectsPlugin: plugins.savedObjects, savedObjectsPlugin: plugins.savedObjects,
share, share,

View file

@ -59,7 +59,9 @@
"@kbn/ml-route-utils", "@kbn/ml-route-utils",
"@kbn/core-lifecycle-server", "@kbn/core-lifecycle-server",
"@kbn/security-plugin", "@kbn/security-plugin",
"@kbn/ml-error-utils" "@kbn/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-browser",
"@kbn/ml-error-utils",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",

View file

@ -18,6 +18,7 @@ import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks'; import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { AppDeps } from '../../../public/application/app'; import { AppDeps } from '../../../public/application/app';
import { LicenseStatus } from '../../../common/types/license_status'; import { LicenseStatus } from '../../../common/types/license_status';
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
class MockTimeBuckets { class MockTimeBuckets {
setBounds(_domain: any) { setBounds(_domain: any) {
@ -41,6 +42,7 @@ export const mockContextValue: AppDeps = {
setBreadcrumbs: jest.fn(), setBreadcrumbs: jest.fn(),
createTimeBuckets: () => new MockTimeBuckets(), createTimeBuckets: () => new MockTimeBuckets(),
uiSettings: uiSettingsServiceMock.createSetupContract(), uiSettings: uiSettingsServiceMock.createSetupContract(),
settings: settingsServiceMock.createStartContract(),
toasts: notificationServiceMock.createSetupContract().toasts, toasts: notificationServiceMock.createSetupContract().toasts,
theme: { theme: {
useChartsTheme: jest.fn(), useChartsTheme: jest.fn(),

View file

@ -15,6 +15,7 @@ import {
ApplicationStart, ApplicationStart,
ExecutionContextStart, ExecutionContextStart,
} from '@kbn/core/public'; } from '@kbn/core/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { Router, Switch, Redirect, withRouter, RouteComponentProps } from 'react-router-dom'; import { Router, Switch, Redirect, withRouter, RouteComponentProps } from 'react-router-dom';
@ -48,6 +49,7 @@ export interface AppDeps {
getUrlForApp: ApplicationStart['getUrlForApp']; getUrlForApp: ApplicationStart['getUrlForApp'];
executionContext: ExecutionContextStart; executionContext: ExecutionContextStart;
licenseManagementLocator?: LicenseManagementLocator; licenseManagementLocator?: LicenseManagementLocator;
settings: SettingsStart;
} }
export const App = (deps: AppDeps) => { export const App = (deps: AppDeps) => {

View file

@ -28,7 +28,9 @@ export const renderApp = (bootDeps: BootDeps) => {
render( render(
<I18nContext> <I18nContext>
<KibanaContextProvider services={{ uiSettings: bootDeps.uiSettings }}> <KibanaContextProvider
services={{ uiSettings: bootDeps.uiSettings, settings: bootDeps.settings }}
>
<KibanaThemeProvider theme$={theme$}> <KibanaThemeProvider theme$={theme$}>
<App {...appDeps} /> <App {...appDeps} />
</KibanaThemeProvider> </KibanaThemeProvider>

View file

@ -50,6 +50,7 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
docLinks, docLinks,
application, application,
executionContext, executionContext,
settings,
} = coreStart; } = coreStart;
docTitle.change(pluginName); docTitle.change(pluginName);
@ -65,6 +66,7 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
toasts: notifications.toasts, toasts: notifications.toasts,
http, http,
uiSettings, uiSettings,
settings,
docLinks, docLinks,
setBreadcrumbs, setBreadcrumbs,
theme: charts.theme, theme: charts.theme,

View file

@ -34,6 +34,8 @@
"@kbn/shared-ux-router", "@kbn/shared-ux-router",
"@kbn/license-management-plugin", "@kbn/license-management-plugin",
"@kbn/share-plugin", "@kbn/share-plugin",
"@kbn/core-ui-settings-browser",
"@kbn/core-ui-settings-browser-mocks",
], ],
"exclude": [ "exclude": [
"target/**/*", "target/**/*",