Skip to content

Commit

Permalink
[Watcher] Remove deprecated savedObjectsClient (#154172)
Browse files Browse the repository at this point in the history
## Summary
Fixes #154035

This PR removes the saved objects client from the client-side code of
the Watcher plugin. It seems not to be used anywhere so the removal
should not cause any changes to the UI.
To test this PR, it should be enough to create/update/delete a couple of
simple and advanced watches.
  • Loading branch information
yuliacech authored Apr 11, 2023
1 parent 5feeb17 commit 7daa791
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import { HttpSetup } from '@kbn/core/public';
import { init as initHttpRequests } from './http_requests';
import { mockContextValue } from './app_context.mock';
import { AppContextProvider } from '../../../public/application/app_context';
import { setHttpClient, setSavedObjectsClient } from '../../../public/application/lib/api';

const mockSavedObjectsClient = () => {
return {
find: (_params?: any) => {},
};
};
import { setHttpClient } from '../../../public/application/lib/api';

export const WithAppDependencies =
(Component: any, httpSetup: HttpSetup) => (props: Record<string, unknown>) => {
Expand All @@ -31,7 +25,5 @@ export const WithAppDependencies =
};

export const setupEnvironment = () => {
setSavedObjectsClient(mockSavedObjectsClient() as any);

return initHttpRequests();
};
8 changes: 3 additions & 5 deletions x-pack/plugins/watcher/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Observable } from 'rxjs';
import { SavedObjectsClientContract, CoreTheme } from '@kbn/core/public';
import { CoreTheme } from '@kbn/core/public';

import { KibanaThemeProvider } from './shared_imports';
import { App, AppDeps } from './app';
import { setHttpClient, setSavedObjectsClient } from './lib/api';
import { setHttpClient } from './lib/api';

interface BootDeps extends AppDeps {
element: HTMLElement;
savedObjects: SavedObjectsClientContract;
I18nContext: any;
theme$: Observable<CoreTheme>;
}

export const renderApp = (bootDeps: BootDeps) => {
const { I18nContext, element, savedObjects, theme$, ...appDeps } = bootDeps;
const { I18nContext, element, theme$, ...appDeps } = bootDeps;

setHttpClient(appDeps.http);
setSavedObjectsClient(savedObjects);

render(
<I18nContext>
Expand Down
10 changes: 1 addition & 9 deletions x-pack/plugins/watcher/public/application/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { HttpSetup, SavedObjectsClientContract } from '@kbn/core/public';
import { HttpSetup } from '@kbn/core/public';

import { Settings } from '../models/settings';
import { Watch } from '../models/watch';
Expand All @@ -27,14 +27,6 @@ export const getHttpClient = () => {
return httpClient;
};

let savedObjectsClient: SavedObjectsClientContract;

export const setSavedObjectsClient = (aSavedObjectsClient: SavedObjectsClientContract) => {
savedObjectsClient = aSavedObjectsClient;
};

export const getSavedObjectsClient = () => savedObjectsClient;

const basePath = ROUTES.API_ROOT;

const loadWatchesDeserializer = ({ watches = [] }: { watches: any[] }) => {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/watcher/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
chrome: { docTitle },
i18n: i18nDep,
docLinks,
savedObjects,
application,
executionContext,
} = coreStart;
Expand All @@ -69,7 +68,6 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
docLinks,
setBreadcrumbs,
theme: charts.theme,
savedObjects: savedObjects.client,
I18nContext: i18nDep.Context,
createTimeBuckets: () => new TimeBuckets(uiSettings, data),
history,
Expand Down

0 comments on commit 7daa791

Please sign in to comment.