mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40:07 -04:00
[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:
parent
521811e0a1
commit
069550d72a
72 changed files with 268 additions and 64 deletions
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
|
@ -21,5 +21,6 @@
|
|||
"@kbn/developer-examples-plugin",
|
||||
"@kbn/i18n",
|
||||
"@kbn/i18n-react",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -72,11 +72,12 @@ export const getFieldEditorOpener =
|
|||
apiService,
|
||||
}: Dependencies) =>
|
||||
(options: OpenFieldEditorOptions): CloseEditor => {
|
||||
const { uiSettings, overlays, docLinks, notifications } = core;
|
||||
const { uiSettings, overlays, docLinks, notifications, settings } = core;
|
||||
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
|
||||
uiSettings,
|
||||
docLinks,
|
||||
http: core.http,
|
||||
settings,
|
||||
});
|
||||
|
||||
let overlayRef: OverlayRef | null = null;
|
||||
|
|
|
@ -40,7 +40,7 @@ export async function mountManagementSection(
|
|||
params: ManagementAppMountParams
|
||||
) {
|
||||
const [
|
||||
{ application, chrome, uiSettings, notifications, overlays, http, docLinks, theme },
|
||||
{ application, chrome, uiSettings, settings, notifications, overlays, http, docLinks, theme },
|
||||
{
|
||||
data,
|
||||
dataViewFieldEditor,
|
||||
|
@ -63,6 +63,7 @@ export async function mountManagementSection(
|
|||
application,
|
||||
chrome,
|
||||
uiSettings,
|
||||
settings,
|
||||
notifications,
|
||||
overlays,
|
||||
unifiedSearch,
|
||||
|
|
|
@ -57,7 +57,7 @@ const docLinks = {
|
|||
const createIndexPatternManagmentContext = (): {
|
||||
[key in keyof IndexPatternManagmentContext]: any;
|
||||
} => {
|
||||
const { application, chrome, uiSettings, notifications, overlays, theme } =
|
||||
const { application, chrome, uiSettings, notifications, overlays, theme, settings } =
|
||||
coreMock.createStart();
|
||||
const { http } = coreMock.createSetup();
|
||||
const data = dataPluginMock.createStartContract();
|
||||
|
@ -70,6 +70,7 @@ const createIndexPatternManagmentContext = (): {
|
|||
application,
|
||||
chrome,
|
||||
uiSettings,
|
||||
settings,
|
||||
notifications,
|
||||
overlays,
|
||||
http,
|
||||
|
|
|
@ -26,12 +26,14 @@ import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
|||
import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
|
||||
import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
|
||||
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import { IndexPatternManagementStart } from '.';
|
||||
|
||||
export interface IndexPatternManagmentContext {
|
||||
application: ApplicationStart;
|
||||
chrome: ChromeStart;
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
notifications: NotificationsStart;
|
||||
overlays: OverlayStart;
|
||||
http: HttpSetup;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
"@kbn/utility-types-jest",
|
||||
"@kbn/config-schema",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -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 { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-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 { DiscoverStartPlugins } from './plugin';
|
||||
import { DiscoverContextAppLocator } from './application/context/services/locator';
|
||||
|
@ -83,6 +84,7 @@ export interface DiscoverServices {
|
|||
toastNotifications: ToastsStart;
|
||||
notifications: NotificationsStart;
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
|
||||
dataViewFieldEditor: IndexPatternFieldEditorStart;
|
||||
dataViewEditor: DataViewEditorStart;
|
||||
|
@ -137,6 +139,7 @@ export const buildServices = memoize(function (
|
|||
toastNotifications: core.notifications.toasts,
|
||||
notifications: core.notifications,
|
||||
uiSettings: core.uiSettings,
|
||||
settings: core.settings,
|
||||
storage,
|
||||
trackUiMetric: usageCollection?.reportUiCounter.bind(usageCollection, 'discover'),
|
||||
dataViewFieldEditor: plugins.dataViewFieldEditor,
|
||||
|
|
|
@ -17,6 +17,11 @@ import { buildDataTableRecord } from '../../utils/build_data_record';
|
|||
import { EsHitRecord } from '../../types';
|
||||
|
||||
const mockServices = {
|
||||
settings: {
|
||||
client: {
|
||||
get: (key: string) => key === 'discover:maxDocFieldsDisplayed' && 200,
|
||||
},
|
||||
},
|
||||
uiSettings: {
|
||||
get: (key: string) => key === 'discover:maxDocFieldsDisplayed' && 200,
|
||||
},
|
||||
|
|
|
@ -105,6 +105,7 @@ export class InspectorPublicPlugin implements Plugin<Setup, Start> {
|
|||
http: core.http,
|
||||
uiSettings: core.uiSettings,
|
||||
share: startDeps.share,
|
||||
settings: core.settings,
|
||||
}}
|
||||
/>,
|
||||
{ theme$: core.theme.theme$ }
|
||||
|
|
|
@ -15,6 +15,8 @@ import type { ApplicationStart, HttpSetup, IUiSettingsClient } from '@kbn/core/p
|
|||
import { SharePluginStart } from '@kbn/share-plugin/public';
|
||||
import { sharePluginMock } from '@kbn/share-plugin/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', () => {
|
||||
let adapters: Adapters;
|
||||
|
@ -24,11 +26,13 @@ describe('InspectorPanel', () => {
|
|||
http: {},
|
||||
share: sharePluginMock.createStartContract(),
|
||||
uiSettings: {},
|
||||
settings: settingsServiceMock.createStartContract(),
|
||||
} as unknown as {
|
||||
application: ApplicationStart;
|
||||
http: HttpSetup;
|
||||
share: SharePluginStart;
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
import { ApplicationStart, HttpStart, IUiSettingsClient } from '@kbn/core/public';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { SharePluginStart } from '@kbn/share-plugin/public';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import { InspectorViewDescription } from '../types';
|
||||
import { Adapters } from '../../common';
|
||||
import { InspectorViewChooser } from './inspector_view_chooser';
|
||||
|
@ -46,6 +47,7 @@ interface InspectorPanelProps {
|
|||
http: HttpStart;
|
||||
uiSettings: IUiSettingsClient;
|
||||
share: SharePluginStart;
|
||||
settings: SettingsStart;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
"@kbn/test-jest-helpers",
|
||||
"@kbn/i18n-react",
|
||||
"@kbn/monaco",
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -22,8 +22,8 @@ useObservableSpy.mockImplementation((observable, def) => def);
|
|||
|
||||
const mock = (): [KibanaServices, Subject<any>] => {
|
||||
const core = coreMock.createStart();
|
||||
const get = core.uiSettings.get;
|
||||
const get$ = core.uiSettings.get$;
|
||||
const get = core.settings.client.get;
|
||||
const get$ = core.settings.client.get$;
|
||||
const subject = new Subject();
|
||||
|
||||
get.mockImplementation(() => 'bar');
|
||||
|
@ -73,8 +73,8 @@ describe('useUiSetting', () => {
|
|||
|
||||
const strong = container!.querySelector('strong');
|
||||
expect(strong!.textContent).toBe('bar');
|
||||
expect(core.uiSettings!.get).toHaveBeenCalledTimes(1);
|
||||
expect((core.uiSettings!.get as any).mock.calls[0][0]).toBe('foo');
|
||||
expect(core.settings!.client.get).toHaveBeenCalledTimes(1);
|
||||
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 () => {
|
||||
|
@ -88,9 +88,10 @@ describe('useUiSetting', () => {
|
|||
container
|
||||
);
|
||||
|
||||
expect(core.uiSettings!.get).toHaveBeenCalledTimes(1);
|
||||
expect((core.uiSettings!.get as any).mock.calls[0][0]).toBe('foo');
|
||||
expect((core.uiSettings!.get as any).mock.calls[0][1]).toBe('DEFAULT');
|
||||
expect(core.uiSettings!.get).toHaveBeenCalledTimes(0);
|
||||
expect(core.settings!.client.get).toHaveBeenCalledTimes(1);
|
||||
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');
|
||||
expect(strong!.textContent).toBe('bar');
|
||||
expect(core.uiSettings!.get).toHaveBeenCalledTimes(1);
|
||||
expect((core.uiSettings!.get as any).mock.calls[0][0]).toBe('foo');
|
||||
expect(core.settings!.client.get).toHaveBeenCalledTimes(1);
|
||||
expect((core.settings!.client.get as any).mock.calls[0][0]).toBe('foo');
|
||||
});
|
||||
|
||||
test('calls Core with correct arguments', async () => {
|
||||
|
@ -198,7 +199,7 @@ describe('useUiSetting$', () => {
|
|||
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 () => {
|
||||
|
@ -235,7 +236,7 @@ describe('useUiSetting$', () => {
|
|||
Simulate.click(container!.querySelector('button')!, {});
|
||||
});
|
||||
|
||||
expect(core.uiSettings!.set).toHaveBeenCalledTimes(1);
|
||||
expect(core.uiSettings!.set).toHaveBeenCalledWith('a', 'c');
|
||||
expect(core.settings!.client.set).toHaveBeenCalledTimes(1);
|
||||
expect(core.settings!.client.set).toHaveBeenCalledWith('a', 'c');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,13 +20,15 @@ import { useKibana } from '../context';
|
|||
* ```
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
|
||||
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 => {
|
||||
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.');
|
||||
}
|
||||
|
||||
return services.settings.globalClient.get(key, defaultValue);
|
||||
return settings.globalClient.get(key, defaultValue);
|
||||
};
|
||||
|
||||
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>] => {
|
||||
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.');
|
||||
}
|
||||
|
||||
const observable$ = useMemo(
|
||||
() => services.uiSettings!.get$(key, defaultValue),
|
||||
[key, defaultValue, services.uiSettings]
|
||||
() => settings!.client.get$(key, defaultValue),
|
||||
[key, defaultValue, settings]
|
||||
);
|
||||
const value = useObservable<T>(observable$, services.uiSettings!.get(key, defaultValue));
|
||||
const set = useCallback((newValue: T) => services.uiSettings!.set(key, newValue), [key]);
|
||||
const value = useObservable<T>(observable$, settings!.client.get(key, defaultValue));
|
||||
const set = useCallback((newValue: T) => settings!.client.set(key, newValue), [key]);
|
||||
|
||||
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>] => {
|
||||
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.');
|
||||
}
|
||||
|
||||
const observable$ = useMemo(
|
||||
() => services.settings!.globalClient.get$(key, defaultValue),
|
||||
[key, defaultValue, services.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]
|
||||
() => settings!.globalClient.get$(key, defaultValue),
|
||||
[key, defaultValue, settings!.globalClient]
|
||||
);
|
||||
const value = useObservable<T>(observable$, settings!.globalClient.get(key, defaultValue));
|
||||
const set = useCallback((newValue: T) => settings!.globalClient.set(key, newValue), [key]);
|
||||
|
||||
return [value, set];
|
||||
};
|
||||
|
|
|
@ -4,6 +4,34 @@ exports[`SavedObjectEdition should render normally 1`] = `
|
|||
<Provider
|
||||
services={
|
||||
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 {
|
||||
"get": [MockFunction],
|
||||
"get$": [MockFunction],
|
||||
|
|
|
@ -28,6 +28,7 @@ import {
|
|||
SavedObjectEditionProps,
|
||||
SavedObjectEditionState,
|
||||
} from './saved_object_view';
|
||||
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
|
||||
|
||||
const resolvePromises = () => new Promise((resolve) => process.nextTick(resolve));
|
||||
|
||||
|
@ -40,6 +41,7 @@ describe('SavedObjectEdition', () => {
|
|||
let history: ReturnType<typeof scopedHistoryMock.create>;
|
||||
let applications: ReturnType<typeof applicationServiceMock.createStartContract>;
|
||||
let docLinks: ReturnType<typeof docLinksServiceMock.createStartContract>;
|
||||
let settings: ReturnType<typeof settingsServiceMock.createStartContract>;
|
||||
|
||||
const shallowRender = (overrides: Partial<SavedObjectEditionProps> = {}) => {
|
||||
return shallowWithI18nProvider(
|
||||
|
@ -56,6 +58,7 @@ describe('SavedObjectEdition', () => {
|
|||
overlays = overlayServiceMock.createStartContract();
|
||||
notifications = notificationServiceMock.createStartContract();
|
||||
uiSettings = uiSettingsServiceMock.createStartContract();
|
||||
settings = settingsServiceMock.createStartContract();
|
||||
history = scopedHistoryMock.create();
|
||||
docLinks = docLinksServiceMock.createStartContract();
|
||||
applications = applicationServiceMock.createStartContract();
|
||||
|
@ -82,6 +85,7 @@ describe('SavedObjectEdition', () => {
|
|||
history,
|
||||
uiSettings,
|
||||
docLinks: docLinks.links,
|
||||
settings,
|
||||
};
|
||||
|
||||
bulkDeleteObjectsMock.mockResolvedValue([{}]);
|
||||
|
|
|
@ -20,10 +20,12 @@ import {
|
|||
IUiSettingsClient,
|
||||
DocLinksStart,
|
||||
} from '@kbn/core/public';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import { Header, Inspect, NotFoundErrors } from './components';
|
||||
import { bulkDeleteObjects, bulkGetObjects } from '../../lib';
|
||||
import { SavedObjectWithMetadata } from '../../types';
|
||||
import './saved_object_view.scss';
|
||||
|
||||
export interface SavedObjectEditionProps {
|
||||
id: string;
|
||||
savedObjectType: string;
|
||||
|
@ -35,6 +37,7 @@ export interface SavedObjectEditionProps {
|
|||
history: ScopedHistory;
|
||||
uiSettings: IUiSettingsClient;
|
||||
docLinks: DocLinksStart['links'];
|
||||
settings: SettingsStart;
|
||||
}
|
||||
export interface SavedObjectEditionState {
|
||||
type: string;
|
||||
|
@ -91,12 +94,12 @@ export class SavedObjectEdition extends Component<
|
|||
}
|
||||
|
||||
render() {
|
||||
const { capabilities, notFoundType, http, uiSettings, docLinks } = this.props;
|
||||
const { capabilities, notFoundType, http, uiSettings, docLinks, settings } = this.props;
|
||||
const { object } = this.state;
|
||||
const { delete: canDelete } = capabilities.savedObjectsManagement as Record<string, boolean>;
|
||||
const canView = this.canViewInApp(capabilities, object);
|
||||
return (
|
||||
<KibanaContextProvider services={{ uiSettings }}>
|
||||
<KibanaContextProvider services={{ uiSettings, settings }}>
|
||||
<EuiFlexGroup
|
||||
direction="column"
|
||||
data-test-subject="savedObjectsEdit"
|
||||
|
|
|
@ -64,6 +64,7 @@ const SavedObjectsEditionPage = ({
|
|||
uiSettings={coreStart.uiSettings}
|
||||
history={history}
|
||||
docLinks={docLinks}
|
||||
settings={coreStart.settings}
|
||||
/>
|
||||
</RedirectAppLinks>
|
||||
);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
"@kbn/core-custom-branding-browser-mocks",
|
||||
"@kbn/core-custom-branding-browser",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -22,6 +22,9 @@ describe('TextBasedLanguagesEditor', () => {
|
|||
|
||||
const services = {
|
||||
uiSettings,
|
||||
settings: {
|
||||
client: uiSettings,
|
||||
},
|
||||
};
|
||||
|
||||
function renderTextBasedLanguagesEditorComponent(testProps: TextBasedLanguagesEditorProps) {
|
||||
|
|
|
@ -89,6 +89,7 @@ function wrapSearchBarInContext(testProps: any) {
|
|||
|
||||
const services = {
|
||||
uiSettings: startMock.uiSettings,
|
||||
settings: startMock.settings,
|
||||
savedObjects: startMock.savedObjects,
|
||||
notifications: startMock.notifications,
|
||||
http: startMock.http,
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
import { IExternalUrl } from '@kbn/core/public';
|
||||
import { uiSettingsServiceMock } from '@kbn/core/public/mocks';
|
||||
import { UrlDrilldown, ActionContext, Config } from './url_drilldown';
|
||||
import {
|
||||
IEmbeddable,
|
||||
|
@ -18,6 +17,7 @@ import { DatatableColumnType } from '@kbn/expressions-plugin/common';
|
|||
import { of } from '@kbn/kibana-utils-plugin/common';
|
||||
import { createPoint, rowClickData, TestEmbeddable } from './test/data';
|
||||
import { ROW_CLICK_TRIGGER } from '@kbn/ui-actions-plugin/public';
|
||||
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
|
||||
|
||||
const mockDataPoints = [
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ const createDrilldown = (isExternalUrlValid: boolean = true) => {
|
|||
getSyntaxHelpDocsLink: () => 'http://localhost:5601/docs',
|
||||
getVariablesHelpDocsLink: () => 'http://localhost:5601/docs',
|
||||
navigateToUrl: mockNavigateToUrl,
|
||||
uiSettings: uiSettingsServiceMock.createSetupContract(),
|
||||
settings: settingsServiceMock.createSetupContract(),
|
||||
});
|
||||
return drilldown;
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { IExternalUrl, IUiSettingsClient } from '@kbn/core/public';
|
||||
import { IExternalUrl } from '@kbn/core/public';
|
||||
import {
|
||||
ChartActionContext,
|
||||
CONTEXT_MENU_TRIGGER,
|
||||
|
@ -30,6 +30,7 @@ import {
|
|||
UiActionsEnhancedBaseActionFactoryContext as BaseActionFactoryContext,
|
||||
} from '@kbn/ui-actions-enhanced-plugin/public';
|
||||
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 { getEventVariableList, getEventScopeValues } from './variables/event_variables';
|
||||
import { getContextVariableList, getContextScopeValues } from './variables/context_variables';
|
||||
|
@ -50,7 +51,7 @@ interface UrlDrilldownDeps {
|
|||
navigateToUrl: (url: string) => Promise<void>;
|
||||
getSyntaxHelpDocsLink: () => string;
|
||||
getVariablesHelpDocsLink: () => string;
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
}
|
||||
|
||||
export type ActionContext = ChartActionContext<EmbeddableWithQueryInput>;
|
||||
|
@ -122,7 +123,7 @@ export class UrlDrilldown implements Drilldown<Config, ActionContext, ActionFact
|
|||
return (
|
||||
<KibanaContextProvider
|
||||
services={{
|
||||
uiSettings: this.deps.uiSettings,
|
||||
settings: this.deps.settings,
|
||||
}}
|
||||
>
|
||||
<UrlDrilldownCollectConfig
|
||||
|
|
|
@ -48,7 +48,7 @@ export class UrlDrilldownPlugin
|
|||
startServices().core.docLinks.links.dashboard.urlDrilldownTemplateSyntax,
|
||||
getVariablesHelpDocsLink: () =>
|
||||
startServices().core.docLinks.links.dashboard.urlDrilldownVariables,
|
||||
uiSettings: core.uiSettings,
|
||||
settings: core.settings,
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
"@kbn/es-query",
|
||||
"@kbn/monaco",
|
||||
"@kbn/std",
|
||||
"@kbn/image-embeddable-plugin"
|
||||
"@kbn/image-embeddable-plugin",
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
"@kbn/core-ui-settings-browser"
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -84,6 +84,12 @@ function mountDatePicker(initialParams: {
|
|||
get: (key: string) => [],
|
||||
get$: (key: string) => of(true),
|
||||
},
|
||||
settings: {
|
||||
client: {
|
||||
get: (key: string) => [],
|
||||
get$: (key: string) => of(true),
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DatePickerContextProvider>
|
||||
|
|
|
@ -30,6 +30,7 @@ import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
|
|||
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
|
||||
import { casesPluginMock } from '@kbn/cases-plugin/public/mocks';
|
||||
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 { ExploratoryViewPublicPluginsStart } from '../../../plugin';
|
||||
import * as useAppDataViewHook from './hooks/use_app_data_view';
|
||||
|
@ -128,6 +129,14 @@ export const mockCore: () => Partial<CoreStart & ExploratoryViewPublicPluginsSta
|
|||
get: getSetting,
|
||||
get$: setSetting$,
|
||||
},
|
||||
settings: {
|
||||
...settingsServiceMock.createStartContract(),
|
||||
client: {
|
||||
...settingsServiceMock.createStartContract().client,
|
||||
get: getSetting,
|
||||
get$: setSetting$,
|
||||
},
|
||||
},
|
||||
lens: lensPluginMock.createStartContract(),
|
||||
data: dataPluginMock.createStartContract(),
|
||||
dataViews: dataViewPluginMocks.createStartContract(),
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-application-browser",
|
||||
"@kbn/observability-shared-plugin",
|
||||
"@kbn/core-ui-settings-browser-mocks"
|
||||
],
|
||||
"exclude": ["target/**/*"]
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ exports[`Should render error when upload fails from elasticsearch request failur
|
|||
<Provider
|
||||
services={
|
||||
Object {
|
||||
"settings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
"uiSettings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
|
@ -98,6 +101,9 @@ exports[`Should render error when upload fails from http request timeout 1`] = `
|
|||
<Provider
|
||||
services={
|
||||
Object {
|
||||
"settings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
"uiSettings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
|
@ -192,6 +198,9 @@ exports[`Should render success 1`] = `
|
|||
<Provider
|
||||
services={
|
||||
Object {
|
||||
"settings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
"uiSettings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
|
@ -349,6 +358,9 @@ exports[`Should render warning when some features failed import 1`] = `
|
|||
<Provider
|
||||
services={
|
||||
Object {
|
||||
"settings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
"uiSettings": Object {
|
||||
"get": [MockFunction],
|
||||
},
|
||||
|
|
|
@ -33,6 +33,11 @@ jest.mock('../kibana_services', () => ({
|
|||
get: jest.fn(),
|
||||
};
|
||||
},
|
||||
getSettings: () => {
|
||||
return {
|
||||
get: jest.fn(),
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
test('Should render success', () => {
|
||||
|
|
|
@ -20,12 +20,13 @@ import {
|
|||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
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 { getPartialImportMessage } from './utils';
|
||||
|
||||
const services = {
|
||||
uiSettings: getUiSettings(),
|
||||
settings: getSettings(),
|
||||
};
|
||||
|
||||
interface Props {
|
||||
|
|
|
@ -19,4 +19,5 @@ export const getDocLinks = () => coreStart.docLinks;
|
|||
export const getDataViewsService = () => pluginsStart.data.dataViews;
|
||||
export const getHttp = () => coreStart.http;
|
||||
export const getSavedObjectsClient = () => coreStart.savedObjects.client;
|
||||
export const getUiSettings = () => coreStart.uiSettings;
|
||||
export const getUiSettings = () => coreStart.settings.client;
|
||||
export const getSettings = () => coreStart.settings;
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
import { GlobalFlyout } from '@kbn/es-ui-shared-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 { AppContextProvider } from '../../../public/application/app_context';
|
||||
import { httpService } from '../../../public/application/services/http';
|
||||
|
@ -60,6 +61,7 @@ export const kibanaVersion = new SemVer(MAJOR_VERSION);
|
|||
|
||||
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
|
||||
uiSettings: uiSettingsServiceMock.createSetupContract(),
|
||||
settings: settingsServiceMock.createStartContract(),
|
||||
kibanaVersion: {
|
||||
get: () => kibanaVersion,
|
||||
},
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
} from '@kbn/core/public';
|
||||
import { SharePluginStart } from '@kbn/share-plugin/public';
|
||||
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import { ExtensionsService } from '../services';
|
||||
import { UiMetricService, NotificationService, HttpService } from './services';
|
||||
|
||||
|
@ -46,6 +47,7 @@ export interface AppDependencies {
|
|||
history: ScopedHistory;
|
||||
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
url: SharePluginStart['url'];
|
||||
docLinks: DocLinksStart;
|
||||
kibanaVersion: SemVer;
|
||||
|
|
|
@ -63,6 +63,7 @@ export async function mountManagementSection(
|
|||
chrome: { docTitle },
|
||||
uiSettings,
|
||||
executionContext,
|
||||
settings,
|
||||
} = core;
|
||||
|
||||
const { url } = startDependencies.share;
|
||||
|
@ -96,6 +97,7 @@ export async function mountManagementSection(
|
|||
history,
|
||||
setBreadcrumbs,
|
||||
uiSettings,
|
||||
settings,
|
||||
url,
|
||||
docLinks,
|
||||
kibanaVersion,
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
"@kbn/config-schema",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-http-router-server-mocks",
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -15,6 +15,8 @@ import { NotificationsSetup, IUiSettingsClient, CoreTheme } from '@kbn/core/publ
|
|||
import { ManagementAppMountParams } from '@kbn/management-plugin/public';
|
||||
import type { SharePluginStart } from '@kbn/share-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 { ILicense } from '../types';
|
||||
|
||||
|
@ -40,6 +42,7 @@ export interface AppServices {
|
|||
notifications: NotificationsSetup;
|
||||
history: ManagementAppMountParams['history'];
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
share: SharePluginStart;
|
||||
fileUpload: FileUploadPluginStart;
|
||||
application: ApplicationStart;
|
||||
|
|
|
@ -47,6 +47,7 @@ export async function mountManagementSection(
|
|||
notifications,
|
||||
history,
|
||||
uiSettings: coreStart.uiSettings,
|
||||
settings: coreStart.settings,
|
||||
share: depsStart.share,
|
||||
fileUpload: depsStart.fileUpload,
|
||||
application,
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
"@kbn/test-jest-helpers",
|
||||
"@kbn/config-schema",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -124,6 +124,7 @@ export async function getLensServices(
|
|||
chrome: coreStart.chrome,
|
||||
overlays: coreStart.overlays,
|
||||
uiSettings: coreStart.uiSettings,
|
||||
settings: coreStart.settings,
|
||||
application: coreStart.application,
|
||||
notifications: coreStart.notifications,
|
||||
savedObjectStore: new SavedObjectIndexStore(startDependencies.contentManagement.client),
|
||||
|
|
|
@ -45,6 +45,7 @@ import type { ChartsPluginSetup } from '@kbn/charts-plugin/public';
|
|||
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
||||
import type { DocLinksStart } from '@kbn/core-doc-links-browser';
|
||||
import type { SharePluginStart } from '@kbn/share-plugin/public';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import type {
|
||||
DatasourceMap,
|
||||
EditorFrameInstance,
|
||||
|
@ -149,6 +150,7 @@ export interface LensAppServices {
|
|||
data: DataPublicPluginStart;
|
||||
inspector: LensInspector;
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
uiActions: UiActionsStart;
|
||||
application: ApplicationStart;
|
||||
notifications: NotificationsStart;
|
||||
|
|
|
@ -168,7 +168,7 @@ export function getFormBasedDatasource({
|
|||
dataViewFieldEditor: IndexPatternFieldEditorStart;
|
||||
uiActions: UiActionsStart;
|
||||
}) {
|
||||
const uiSettings = core.uiSettings;
|
||||
const { uiSettings, settings } = core;
|
||||
|
||||
const DATASOURCE_ID = 'formBased';
|
||||
|
||||
|
@ -535,6 +535,7 @@ export function getFormBasedDatasource({
|
|||
appName: 'lens',
|
||||
storage,
|
||||
uiSettings,
|
||||
settings,
|
||||
data,
|
||||
fieldFormats,
|
||||
savedObjects: core.savedObjects,
|
||||
|
@ -564,6 +565,7 @@ export function getFormBasedDatasource({
|
|||
appName: 'lens',
|
||||
storage,
|
||||
uiSettings,
|
||||
settings,
|
||||
data,
|
||||
fieldFormats,
|
||||
savedObjects: core.savedObjects,
|
||||
|
|
|
@ -29,6 +29,7 @@ import type { EmbeddableStateTransfer } from '@kbn/embeddable-plugin/public';
|
|||
|
||||
import { presentationUtilPluginMock } from '@kbn/presentation-util-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 {
|
||||
LensByValueInput,
|
||||
|
@ -139,6 +140,7 @@ export function makeDefaultServices(
|
|||
chrome: core.chrome,
|
||||
overlays: core.overlays,
|
||||
uiSettings: core.uiSettings,
|
||||
settings: settingsServiceMock.createStartContract(),
|
||||
executionContext: core.executionContext,
|
||||
navigation: navigationStartMock,
|
||||
notifications: core.notifications,
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
"@kbn/safer-lodash-set",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/dom-drag-drop",
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
"@kbn/visualization-ui-components",
|
||||
"@kbn/content-management-plugin",
|
||||
"@kbn/core-saved-objects-api-server",
|
||||
|
|
|
@ -18,6 +18,7 @@ const kibanaServices = {
|
|||
application: { getUrlForApp: () => {}, navigateToApp: () => {} },
|
||||
chrome: { setBreadcrumbs, docTitle: { change: setTitle } },
|
||||
uiSettings: { get: () => true },
|
||||
settings: { client: { get: () => true } },
|
||||
} as unknown as Partial<CoreStart>;
|
||||
const KibanaContext = createKibanaReactContext(kibanaServices);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ interface AppDependencies {
|
|||
http: HttpSetup;
|
||||
I18nContext: CoreStart['i18n']['Context'];
|
||||
uiSettings: CoreSetup['uiSettings'];
|
||||
settings: CoreStart['settings'];
|
||||
links: Links;
|
||||
chrome: ChromeStart;
|
||||
theme$: Observable<CoreTheme>;
|
||||
|
@ -27,13 +28,14 @@ interface AppDependencies {
|
|||
|
||||
export function renderApp(
|
||||
element: HTMLElement | null,
|
||||
{ http, I18nContext, uiSettings, links, chrome, theme$ }: AppDependencies
|
||||
{ http, I18nContext, uiSettings, links, chrome, theme$, settings }: AppDependencies
|
||||
) {
|
||||
if (!element) {
|
||||
return () => undefined;
|
||||
}
|
||||
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
|
||||
uiSettings,
|
||||
settings,
|
||||
});
|
||||
render(
|
||||
<I18nContext>
|
||||
|
|
|
@ -56,6 +56,7 @@ export class PainlessLabUIPlugin implements Plugin<void, void, PluginDependencie
|
|||
notifications,
|
||||
docLinks,
|
||||
chrome,
|
||||
settings,
|
||||
} = core;
|
||||
|
||||
const license = await firstValueFrom(licensing.license$);
|
||||
|
@ -75,6 +76,7 @@ export class PainlessLabUIPlugin implements Plugin<void, void, PluginDependencie
|
|||
links: getLinks(docLinks),
|
||||
chrome,
|
||||
theme$,
|
||||
settings,
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
|
|
@ -22,8 +22,11 @@ export const getRuntimeFieldEditorLoader =
|
|||
(coreSetup: CoreSetup) => async (): Promise<LoadEditorResponse> => {
|
||||
const { RuntimeFieldEditorFlyoutContent } = await import('./components');
|
||||
const [core] = await coreSetup.getStartServices();
|
||||
const { uiSettings, theme, overlays, docLinks } = core;
|
||||
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ uiSettings });
|
||||
const { uiSettings, theme, overlays, docLinks, settings } = core;
|
||||
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
|
||||
uiSettings,
|
||||
settings,
|
||||
});
|
||||
|
||||
let overlayRef: OverlayRef | null = null;
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ export const createStartServicesMock = (
|
|||
core: ReturnType<typeof coreMock.createStart> = coreMock.createStart()
|
||||
): StartServices => {
|
||||
core.uiSettings.get.mockImplementation(createUseUiSettingMock());
|
||||
core.settings.client.get.mockImplementation(createUseUiSettingMock());
|
||||
const { storage } = createSecuritySolutionStorageMock();
|
||||
const apm = mockApm();
|
||||
const data = dataPluginMock.createStartContract();
|
||||
|
|
|
@ -131,7 +131,7 @@ export class Simulator {
|
|||
// Used for `KibanaContextProvider`
|
||||
const coreStart = coreMock.createStart();
|
||||
|
||||
coreStart.uiSettings.get.mockImplementation(uiSetting);
|
||||
coreStart.settings.client.get.mockImplementation(uiSetting);
|
||||
|
||||
this.sideEffectSimulator = sideEffectSimulatorFactory();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ describe(`useFormattedDate, when the "dateFormat" UI setting is "${uiSetting(
|
|||
return <span data-test-subj="useFormattedDateTest">{useFormattedDate(date)}</span>;
|
||||
}
|
||||
const mockCoreStart = coreMock.createStart();
|
||||
mockCoreStart.uiSettings.get.mockImplementation(uiSetting);
|
||||
mockCoreStart.settings.client.get.mockImplementation(uiSetting);
|
||||
|
||||
it.each([
|
||||
['randomString', 'an invalid string', 'Invalid Date'],
|
||||
|
|
|
@ -64,6 +64,7 @@ const appDependencies = {
|
|||
|
||||
const kibanaContextDependencies = {
|
||||
uiSettings: core.uiSettings,
|
||||
settings: core.settings,
|
||||
};
|
||||
|
||||
export const setupEnvironment = () => {
|
||||
|
|
|
@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
import { CoreStart, ScopedHistory, CoreTheme, IUiSettingsClient } from '@kbn/core/public';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import { ClientConfigType } from '../types';
|
||||
import { HttpService, UiMetricService } from './services';
|
||||
|
||||
|
@ -19,6 +20,7 @@ export interface AppDependencies {
|
|||
core: CoreStart;
|
||||
services: {
|
||||
uiSettings: IUiSettingsClient;
|
||||
settings: SettingsStart;
|
||||
httpService: HttpService;
|
||||
uiMetricService: UiMetricService;
|
||||
i18n: typeof i18n;
|
||||
|
|
|
@ -28,6 +28,7 @@ export async function mountManagementSection(
|
|||
const [core] = await coreSetup.getStartServices();
|
||||
const {
|
||||
chrome: { docTitle },
|
||||
settings,
|
||||
} = core;
|
||||
|
||||
docTitleService.setup(docTitle.change);
|
||||
|
@ -38,6 +39,7 @@ export async function mountManagementSection(
|
|||
config,
|
||||
services: {
|
||||
uiSettings: coreSetup.uiSettings,
|
||||
settings,
|
||||
httpService,
|
||||
uiMetricService: services.uiMetricService,
|
||||
i18n,
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
"@kbn/analytics",
|
||||
"@kbn/config-schema",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
"@kbn/core-http-router-server-mocks",
|
||||
],
|
||||
"exclude": [
|
||||
|
|
|
@ -129,6 +129,14 @@ export const mockCore: () => Partial<CoreStart> = () => {
|
|||
get: getSetting,
|
||||
get$: setSetting$,
|
||||
},
|
||||
settings: {
|
||||
client: {
|
||||
...defaultCore.settings.client,
|
||||
get: getSetting,
|
||||
get$: setSetting$,
|
||||
},
|
||||
globalClient: defaultCore.settings.globalClient,
|
||||
},
|
||||
usageCollection: {
|
||||
reportUiCounter: () => {},
|
||||
},
|
||||
|
|
|
@ -127,6 +127,14 @@ export const mockCore: () => Partial<CoreStart> = () => {
|
|||
get: getSetting,
|
||||
get$: setSetting$,
|
||||
},
|
||||
settings: {
|
||||
client: {
|
||||
...defaultCore.settings.client,
|
||||
get: getSetting,
|
||||
get$: setSetting$,
|
||||
},
|
||||
globalClient: defaultCore.settings.globalClient,
|
||||
},
|
||||
usageCollection: {
|
||||
reportUiCounter: () => {},
|
||||
},
|
||||
|
|
|
@ -13,6 +13,7 @@ import { TimelinesUIStart } from '@kbn/timelines-plugin/public';
|
|||
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
|
||||
import { RequestAdapter } from '@kbn/inspector-plugin/common';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
import { mockIndicatorsFiltersContext } from './mock_indicators_filters_context';
|
||||
import { SecuritySolutionContext } from '../../containers/security_solution_context';
|
||||
import { getSecuritySolutionContextMock } from './mock_security_context';
|
||||
|
@ -34,6 +35,8 @@ export interface KibanaContextMock {
|
|||
* For the core ui-settings package (see {@link IUiSettingsClient})
|
||||
*/
|
||||
uiSettings?: IUiSettingsClient;
|
||||
|
||||
settings?: SettingsStart;
|
||||
/**
|
||||
* For the timelines plugin
|
||||
*/
|
||||
|
@ -60,6 +63,7 @@ const securityLayout = {
|
|||
|
||||
const defaultServices = {
|
||||
uiSettings: mockUiSettingsService(),
|
||||
settings: { client: mockUiSettingsService() },
|
||||
timelines: mockKibanaTimelinesService,
|
||||
triggersActionsUi: mockTriggersActionsUiService,
|
||||
storage: {
|
||||
|
|
|
@ -107,6 +107,7 @@ const core = coreMock.createStart();
|
|||
const coreServiceMock = {
|
||||
...core,
|
||||
uiSettings: { get: jest.fn().mockImplementation(mockUiSetting) },
|
||||
settings: { client: { get: jest.fn().mockImplementation(mockUiSetting) } },
|
||||
};
|
||||
|
||||
const mockSecurityContext: SecuritySolutionPluginContext = getSecuritySolutionContextMock();
|
||||
|
|
|
@ -125,7 +125,12 @@ const mockOnFieldChange = function (value: EuiComboBoxOptionOption<string>): voi
|
|||
export const Default: Story<void> = () => {
|
||||
return (
|
||||
<StoryProvidersComponent
|
||||
kibana={{ data: dataServiceMock, uiSettings: uiSettingsMock, timelines: timelinesMock }}
|
||||
kibana={{
|
||||
data: dataServiceMock,
|
||||
uiSettings: uiSettingsMock,
|
||||
timelines: timelinesMock,
|
||||
settings: { client: uiSettingsMock, globalClient: uiSettingsMock },
|
||||
}}
|
||||
>
|
||||
<IndicatorsBarChartWrapper
|
||||
dateRange={{ min: moment(), max: moment() }}
|
||||
|
@ -144,7 +149,12 @@ Default.decorators = [(story) => <MemoryRouter>{story()}</MemoryRouter>];
|
|||
export const InitialLoad: Story<void> = () => {
|
||||
return (
|
||||
<StoryProvidersComponent
|
||||
kibana={{ data: dataServiceMock, uiSettings: uiSettingsMock, timelines: timelinesMock }}
|
||||
kibana={{
|
||||
data: dataServiceMock,
|
||||
uiSettings: uiSettingsMock,
|
||||
timelines: timelinesMock,
|
||||
settings: { client: uiSettingsMock, globalClient: uiSettingsMock },
|
||||
}}
|
||||
>
|
||||
<IndicatorsBarChartWrapper
|
||||
dateRange={{ min: moment(), max: moment() }}
|
||||
|
@ -188,7 +198,12 @@ export const UpdatingData: Story<void> = () => {
|
|||
|
||||
return (
|
||||
<StoryProvidersComponent
|
||||
kibana={{ data: dataServiceMock, uiSettings: uiSettingsMock, timelines: timelinesMock }}
|
||||
kibana={{
|
||||
data: dataServiceMock,
|
||||
uiSettings: uiSettingsMock,
|
||||
settings: { client: uiSettingsMock, globalClient: uiSettingsMock },
|
||||
timelines: timelinesMock,
|
||||
}}
|
||||
>
|
||||
<IndicatorsBarChartWrapper
|
||||
dateRange={{ min: moment(), max: moment() }}
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
"@kbn/kibana-react-plugin",
|
||||
"@kbn/utility-types",
|
||||
"@kbn/ui-theme",
|
||||
"@kbn/securitysolution-io-ts-list-types"
|
||||
"@kbn/securitysolution-io-ts-list-types",
|
||||
"@kbn/core-ui-settings-browser"
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -29,6 +29,7 @@ import type { AppDependencies } from '../app_dependencies';
|
|||
import { MlSharedContext } from './shared_context';
|
||||
import type { GetMlSharedImportsReturnType } from '../../shared_imports';
|
||||
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
|
||||
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
|
||||
|
||||
const coreSetup = coreMock.createSetup();
|
||||
const coreStart = coreMock.createStart();
|
||||
|
@ -91,6 +92,7 @@ const appDependencies: AppDependencies = {
|
|||
triggersActionsUi: {} as jest.Mocked<TriggersAndActionsUIPublicPluginStart>,
|
||||
unifiedSearch: {} as jest.Mocked<UnifiedSearchPublicPluginStart>,
|
||||
savedObjectsManagement: {} as jest.Mocked<SavedObjectsManagementPluginStart>,
|
||||
settings: settingsServiceMock.createStartContract(),
|
||||
};
|
||||
|
||||
export const useAppDependencies = () => {
|
||||
|
|
|
@ -33,6 +33,7 @@ import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
|
|||
import { ChartsPluginStart } from '@kbn/charts-plugin/public';
|
||||
import type { FieldFormatsStart } from '@kbn/field-formats-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';
|
||||
|
||||
export interface AppDependencies {
|
||||
|
@ -60,6 +61,7 @@ export interface AppDependencies {
|
|||
unifiedSearch: UnifiedSearchPublicPluginStart;
|
||||
usageCollection?: UsageCollectionStart;
|
||||
savedObjectsManagement: SavedObjectsManagementPluginStart;
|
||||
settings: SettingsStart;
|
||||
}
|
||||
|
||||
export const useAppDependencies = () => {
|
||||
|
|
|
@ -37,6 +37,7 @@ export async function mountManagementSection(
|
|||
theme,
|
||||
savedObjects,
|
||||
uiSettings,
|
||||
settings,
|
||||
notifications,
|
||||
} = core;
|
||||
const {
|
||||
|
@ -72,6 +73,7 @@ export async function mountManagementSection(
|
|||
savedObjects,
|
||||
storage: localStorage,
|
||||
uiSettings,
|
||||
settings,
|
||||
history,
|
||||
savedObjectsPlugin: plugins.savedObjects,
|
||||
share,
|
||||
|
|
|
@ -59,7 +59,9 @@
|
|||
"@kbn/ml-route-utils",
|
||||
"@kbn/core-lifecycle-server",
|
||||
"@kbn/security-plugin",
|
||||
"@kbn/ml-error-utils"
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
"@kbn/ml-error-utils",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -18,6 +18,7 @@ import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
|
|||
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
|
||||
import { AppDeps } from '../../../public/application/app';
|
||||
import { LicenseStatus } from '../../../common/types/license_status';
|
||||
import { settingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
|
||||
|
||||
class MockTimeBuckets {
|
||||
setBounds(_domain: any) {
|
||||
|
@ -41,6 +42,7 @@ export const mockContextValue: AppDeps = {
|
|||
setBreadcrumbs: jest.fn(),
|
||||
createTimeBuckets: () => new MockTimeBuckets(),
|
||||
uiSettings: uiSettingsServiceMock.createSetupContract(),
|
||||
settings: settingsServiceMock.createStartContract(),
|
||||
toasts: notificationServiceMock.createSetupContract().toasts,
|
||||
theme: {
|
||||
useChartsTheme: jest.fn(),
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
ApplicationStart,
|
||||
ExecutionContextStart,
|
||||
} from '@kbn/core/public';
|
||||
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
|
||||
|
||||
import { Router, Switch, Redirect, withRouter, RouteComponentProps } from 'react-router-dom';
|
||||
|
||||
|
@ -48,6 +49,7 @@ export interface AppDeps {
|
|||
getUrlForApp: ApplicationStart['getUrlForApp'];
|
||||
executionContext: ExecutionContextStart;
|
||||
licenseManagementLocator?: LicenseManagementLocator;
|
||||
settings: SettingsStart;
|
||||
}
|
||||
|
||||
export const App = (deps: AppDeps) => {
|
||||
|
|
|
@ -28,7 +28,9 @@ export const renderApp = (bootDeps: BootDeps) => {
|
|||
|
||||
render(
|
||||
<I18nContext>
|
||||
<KibanaContextProvider services={{ uiSettings: bootDeps.uiSettings }}>
|
||||
<KibanaContextProvider
|
||||
services={{ uiSettings: bootDeps.uiSettings, settings: bootDeps.settings }}
|
||||
>
|
||||
<KibanaThemeProvider theme$={theme$}>
|
||||
<App {...appDeps} />
|
||||
</KibanaThemeProvider>
|
||||
|
|
|
@ -50,6 +50,7 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
|
|||
docLinks,
|
||||
application,
|
||||
executionContext,
|
||||
settings,
|
||||
} = coreStart;
|
||||
|
||||
docTitle.change(pluginName);
|
||||
|
@ -65,6 +66,7 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
|
|||
toasts: notifications.toasts,
|
||||
http,
|
||||
uiSettings,
|
||||
settings,
|
||||
docLinks,
|
||||
setBreadcrumbs,
|
||||
theme: charts.theme,
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
"@kbn/shared-ux-router",
|
||||
"@kbn/license-management-plugin",
|
||||
"@kbn/share-plugin",
|
||||
"@kbn/core-ui-settings-browser",
|
||||
"@kbn/core-ui-settings-browser-mocks",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue