Skip to content

Commit

Permalink
[ML Plugin] Replace SavedObjectsFinder component (#152939)
Browse files Browse the repository at this point in the history
## Summary

This PR replaces the SavedObjectsFinder component from `saved_objects
plugin` with the one in `saved_objects_finder` plugin. This is a part of
making the component BWCA compliant
(#150604).


### 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
- [X] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [X] 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)~
- [X] 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))
- [X] 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 <[email protected]>
  • Loading branch information
Maja Grubic and kibanamachine authored Mar 10, 2023
1 parent 3d571bd commit 526edbd
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 19 deletions.
5 changes: 3 additions & 2 deletions x-pack/plugins/ml/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"taskManager",
"triggersActionsUi",
"uiActions",
"unifiedSearch"
"unifiedSearch",
"savedObjectsFinder",
"savedObjectsManagement"
],
"optionalPlugins": [
"alerting",
Expand All @@ -52,7 +54,6 @@
"kibanaUtils",
"lens",
"maps",
"savedObjects",
"savedSearch",
"usageCollection",
"unifiedFieldList",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const App: FC<AppProps> = ({ coreStart, deps, appMountParams }) => {
unifiedSearch: deps.unifiedSearch,
licensing: deps.licensing,
lens: deps.lens,
savedObjectsManagement: deps.savedObjectsManagement,
...coreStart,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { CasesUiStart } from '@kbn/cases-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { LensPublicStart } from '@kbn/lens-plugin/public';
import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import type { MlServicesContext } from '../../app';

interface StartPlugins {
Expand All @@ -47,6 +48,7 @@ interface StartPlugins {
core: CoreStart;
appName: string;
lens: LensPublicStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
}
export type StartServices = CoreStart &
StartPlugins & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { getDataViewAndSavedSearch, DataViewAndSavedSearch } from '../../../../.

import { SourceSelection } from './source_selection';

jest.mock('@kbn/saved-objects-plugin/public', () => {
const SavedObjectFinderUi = ({
jest.mock('@kbn/saved-objects-finder-plugin/public', () => {
const SavedObjectFinder = ({
onChoose,
}: {
onChoose: (id: string, type: string, fullName: string, savedObject: object) => void;
Expand Down Expand Up @@ -63,7 +63,7 @@ jest.mock('@kbn/saved-objects-plugin/public', () => {
};

return {
SavedObjectFinderUi,
SavedObjectFinder,
};
});

Expand All @@ -73,6 +73,7 @@ jest.mock('../../../../../contexts/kibana', () => ({
services: {
uiSettings: {},
http: {},
savedObjectsManagement: {},
},
}),
useNavigateToPath: () => mockNavigateToPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import { i18n } from '@kbn/i18n';
import { getNestedProperty } from '@kbn/ml-nested-property';
import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public';
import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public';

import { SavedObjectCommon } from '@kbn/saved-objects-plugin/common';
import { useMlKibana, useNavigateToPath } from '../../../../../contexts/kibana';
Expand All @@ -27,7 +27,7 @@ const fixedPageSize: number = 20;

export const SourceSelection: FC = () => {
const {
services: { http, uiSettings },
services: { http, uiSettings, savedObjectsManagement },
} = useMlKibana();
const navigateToPath = useNavigateToPath();

Expand Down Expand Up @@ -117,7 +117,7 @@ export const SourceSelection: FC = () => {
<EuiSpacer size="m" />
</>
)}
<SavedObjectFinderUi
<SavedObjectFinder
key="searchSavedObjectFinder"
onChoose={onSearchSelected}
showFilter
Expand Down Expand Up @@ -151,8 +151,11 @@ export const SourceSelection: FC = () => {
},
]}
fixedPageSize={fixedPageSize}
uiSettings={uiSettings}
http={http}
services={{
uiSettings,
http,
savedObjectsManagement,
}}
/>
</EuiPageContent>
</EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
EuiModalBody,
} from '@elastic/eui';

import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public';
import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public';
import { JobCreatorContext } from '../../../job_creator_context';
import { AdvancedJobCreator } from '../../../../../common/job_creator';
import { resetAdvancedJob } from '../../../../../common/job_creator/util/general';
Expand Down Expand Up @@ -57,6 +57,7 @@ export const ChangeDataViewModal: FC<Props> = ({ onClose }) => {
http,
uiSettings,
data: { dataViews },
savedObjectsManagement,
},
} = useMlKibana();
const navigateToPath = useNavigateToPath();
Expand Down Expand Up @@ -146,7 +147,7 @@ export const ChangeDataViewModal: FC<Props> = ({ onClose }) => {

<EuiSpacer size="s" />

<SavedObjectFinderUi
<SavedObjectFinder
key="searchSavedObjectFinder"
onChoose={onDataViewSelected}
showFilter
Expand All @@ -170,8 +171,11 @@ export const ChangeDataViewModal: FC<Props> = ({ onClose }) => {
},
]}
fixedPageSize={fixedPageSize}
uiSettings={uiSettings}
http={http}
services={{
uiSettings,
http,
savedObjectsManagement,
}}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { FC } from 'react';
import { EuiPageBody, EuiPageContent_Deprecated as EuiPageContent } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public';
import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public';
import { useMlKibana, useNavigateToPath } from '../../../../contexts/kibana';
import { MlPageHeader } from '../../../../components/page_header';

Expand All @@ -19,7 +19,7 @@ export interface PageProps {

export const Page: FC<PageProps> = ({ nextStepPath }) => {
const RESULTS_PER_PAGE = 20;
const { uiSettings, http } = useMlKibana().services;
const { uiSettings, http, savedObjectsManagement } = useMlKibana().services;
const navigateToPath = useNavigateToPath();

const onObjectSelection = (id: string, type: string) => {
Expand All @@ -40,7 +40,7 @@ export const Page: FC<PageProps> = ({ nextStepPath }) => {
/>
</MlPageHeader>
<EuiPageContent hasShadow={false} hasBorder={true}>
<SavedObjectFinderUi
<SavedObjectFinder
key="searchSavedObjectFinder"
onChoose={onObjectSelection}
showFilter
Expand Down Expand Up @@ -71,8 +71,11 @@ export const Page: FC<PageProps> = ({ nextStepPath }) => {
},
]}
fixedPageSize={RESULTS_PER_PAGE}
uiSettings={uiSettings}
http={http}
services={{
uiSettings,
http,
savedObjectsManagement,
}}
/>
</EuiPageContent>
</EuiPageBody>
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/publ
import type { LicenseManagementUIPluginSetup } from '@kbn/license-management-plugin/public';
import type { LicensingPluginSetup, LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { SecurityPluginStart } from '@kbn/security-plugin/public';
import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';

import type { MapsStartApi, MapsSetupApi } from '@kbn/maps-plugin/public';
import {
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface MlStartDependencies {
lens?: LensPublicStart;
cases?: CasesUiStart;
security: SecurityPluginStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
}

export interface MlSetupDependencies {
Expand Down Expand Up @@ -135,6 +137,7 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
fieldFormats: pluginsStart.fieldFormats,
lens: pluginsStart.lens,
cases: pluginsStart.cases,
savedObjectsManagement: pluginsStart.savedObjectsManagement,
},
params
);
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/ml/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
"@kbn/unified-field-list-plugin",
"@kbn/shared-ux-router",
"@kbn/saved-search-plugin",
"@kbn/saved-objects-management-plugin",
"@kbn/saved-objects-finder-plugin",
"@kbn/monaco",
],
}

0 comments on commit 526edbd

Please sign in to comment.