[Graph] Replace SavedObjectsFinder component (#152432)

## Summary

This PR replaces the `SavedObjectsFinder` component from `saved_objects`
plugin with the one in `saved_objects_finder` plugin.


### Checklist

Delete any items that are not applicable to this PR.

- [X] 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))~
- [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 <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Maja Grubic 2023-03-02 16:12:32 +01:00 committed by GitHub
parent 446f04d7b2
commit 0c5fb37670
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 44 additions and 13 deletions

View file

@ -17,7 +17,8 @@
"dataViews",
"data",
"uiActions",
"screenshotMode"
"screenshotMode",
"savedObjectsManagement"
],
"optionalPlugins": [
"usageCollection"

View file

@ -16,6 +16,7 @@ import { UsageCollectionSetup, UsageCollectionStart } from '@kbn/usage-collectio
import { Query, AggregateQuery } from '@kbn/es-query';
import { CoreStart, DocLinksStart } from '@kbn/core/public';
import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { AutocompleteSetup, AutocompleteStart } from './autocomplete';
import type { IndexPatternSelectProps, StatefulSearchBarProps } from '.';
import type { FiltersBuilderProps } from './filters_builder/filters_builder';
@ -92,4 +93,5 @@ export interface IUnifiedSearchPluginServices extends Partial<CoreStart> {
dataViews: DataViewsPublicPluginStart;
dataViewEditor: DataViewEditorStart;
usageCollection?: UsageCollectionStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
}

View file

@ -38,6 +38,7 @@
"@kbn/utility-types-jest",
"@kbn/react-field",
"@kbn/ui-theme",
"@kbn/saved-objects-management-plugin",
],
"exclude": [
"target/**/*",

View file

@ -16,7 +16,9 @@
"navigation",
"savedObjects",
"unifiedSearch",
"inspector"
"inspector",
"savedObjectsManagement",
"savedObjectsFinder",
],
"optionalPlugins": [
"home",

View file

@ -35,6 +35,7 @@ import('./font_awesome');
import { SavedObjectsStart } from '@kbn/saved-objects-plugin/public';
import { SpacesApi } from '@kbn/spaces-plugin/public';
import { KibanaThemeProvider, toMountPoint } from '@kbn/kibana-react-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { GraphSavePolicy } from './types';
import { graphRouter } from './router';
import { checkLicense } from '../common/check_license';
@ -72,6 +73,7 @@ export interface GraphDependencies {
history: ScopedHistory<unknown>;
spaces?: SpacesApi;
inspect: InspectorPublicPluginStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
}
export type GraphServices = Omit<GraphDependencies, 'element' | 'history'>;

View file

@ -43,6 +43,7 @@ export const WorkspaceRoute = ({
spaces,
indexPatterns: getIndexPatternProvider,
inspect,
savedObjectsManagement,
},
}: WorkspaceRouteProps) => {
/**
@ -70,9 +71,10 @@ export const WorkspaceRoute = ({
storage,
data,
unifiedSearch,
savedObjectsManagement,
...coreStart,
}),
[coreStart, data, storage, unifiedSearch]
[coreStart, data, storage, unifiedSearch, savedObjectsManagement]
);
const { loading, requestAdapter, callNodeProxy, callSearchNodeProxy, handleSearchQueryError } =

View file

@ -77,7 +77,7 @@ function GuidancePanelComponent(props: GuidancePanelProps) {
const kibana = useKibana<IUnifiedSearchPluginServices>();
const { services, overlays } = kibana;
const { http, uiSettings, application, data } = services;
const { http, uiSettings, application, data, savedObjectsManagement } = services;
const [hasDataViews, setHasDataViews] = useState<boolean>(true);
useEffect(() => {
@ -90,7 +90,7 @@ function GuidancePanelComponent(props: GuidancePanelProps) {
if (!overlays || !application) return null;
const onOpenDatasourcePicker = () => {
openSourceModal({ overlays, http, uiSettings }, onIndexPatternSelected);
openSourceModal({ overlays, http, uiSettings, savedObjectsManagement }, onIndexPatternSelected);
};
let content = (

View file

@ -29,6 +29,7 @@ import { GraphStore, setDatasource, submitSearchSaga } from '../state_management
import { ReactWrapper } from 'enzyme';
import { createMockGraphStore } from '../state_management/mocks';
import { Provider } from 'react-redux';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
jest.mock('../services/source_modal', () => ({ openSourceModal: jest.fn() }));
@ -42,6 +43,7 @@ function getServiceMocks() {
},
} as IUiSettingsClient,
savedObjects: {} as SavedObjectsStart,
savedObjectsManagement: {} as SavedObjectsManagementPluginStart,
notifications: {} as NotificationsStart,
docLinks: {
links: {

View file

@ -107,9 +107,9 @@ export function SearchBarComponent(props: SearchBarStateProps & SearchBarProps)
notifications,
http,
docLinks,
savedObjectsManagement,
} = services;
if (!overlays) return null;
return (
<form
onSubmit={(e) => {
@ -131,7 +131,11 @@ export function SearchBarComponent(props: SearchBarStateProps & SearchBarProps)
data-test-subj="graphDatasourceButton"
onClick={() => {
confirmWipeWorkspace(
() => openSourceModal({ overlays, http, uiSettings }, onIndexPatternSelected),
() =>
openSourceModal(
{ overlays, http, uiSettings, savedObjectsManagement },
onIndexPatternSelected
),
i18n.translate('xpack.graph.clearWorkspace.confirmText', {
defaultMessage:
'If you change data sources, your current fields and vertices will be reset.',

View file

@ -9,22 +9,28 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import { CoreStart } from '@kbn/core/public';
import { SavedObjectFinderUi } from '@kbn/saved-objects-plugin/public';
import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { IndexPatternSavedObject } from '../types';
export interface SourcePickerProps {
onIndexPatternSelected: (indexPattern: IndexPatternSavedObject) => void;
http: CoreStart['http'];
uiSettings: CoreStart['uiSettings'];
savedObjectsManagement: SavedObjectsManagementPluginStart;
}
const fixedPageSize = 8;
export function SourcePicker({ http, uiSettings, onIndexPatternSelected }: SourcePickerProps) {
export function SourcePicker({
http,
uiSettings,
savedObjectsManagement,
onIndexPatternSelected,
}: SourcePickerProps) {
return (
<SavedObjectFinderUi
http={http}
uiSettings={uiSettings}
<SavedObjectFinder
services={{ http, uiSettings, savedObjectsManagement }}
onChoose={(_id, _type, _name, indexPattern) => {
onIndexPatternSelected(indexPattern as IndexPatternSavedObject);
}}

View file

@ -28,6 +28,7 @@ import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { HomePublicPluginSetup, HomePublicPluginStart } from '@kbn/home-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { SavedObjectsStart } from '@kbn/saved-objects-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { checkLicense } from '../common/check_license';
import { ConfigSchema } from '../config';
@ -44,6 +45,7 @@ export interface GraphPluginStartDependencies {
inspector: InspectorPublicPluginStart;
home?: HomePublicPluginStart;
spaces?: SpacesApi;
savedObjectsManagement: SavedObjectsManagementPluginStart;
}
export class GraphPlugin
@ -113,6 +115,7 @@ export class GraphPlugin
uiSettings: core.uiSettings,
spaces: pluginsStart.spaces,
inspect: pluginsStart.inspector,
savedObjectsManagement: pluginsStart.savedObjectsManagement,
});
},
});

View file

@ -8,6 +8,7 @@
import { CoreStart } from '@kbn/core/public';
import React from 'react';
import { KibanaReactOverlays } from '@kbn/kibana-react-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { SourceModal } from '../components/source_modal';
import { IndexPatternSavedObject } from '../types';
@ -16,17 +17,20 @@ export function openSourceModal(
overlays,
http,
uiSettings,
savedObjectsManagement,
}: {
overlays: KibanaReactOverlays;
http: CoreStart['http'];
uiSettings: CoreStart['uiSettings'];
savedObjectsManagement: SavedObjectsManagementPluginStart;
},
onSelected: (indexPattern: IndexPatternSavedObject) => void
) {
const modalRef = overlays.openModal(
<SourceModal
uiSettings={uiSettings}
http={http}
uiSettings={uiSettings}
savedObjectsManagement={savedObjectsManagement}
onIndexPatternSelected={(indexPattern) => {
onSelected(indexPattern);
modalRef.close();

View file

@ -38,6 +38,8 @@
"@kbn/utility-types",
"@kbn/react-field",
"@kbn/shared-ux-router",
"@kbn/saved-objects-management-plugin",
"@kbn/saved-objects-finder-plugin",
],
"exclude": [
"target/**/*",