Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing stateful saved object finder #52166

Merged
merged 14 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
AppStateClass as TAppStateClass,
KbnUrl,
SaveOptions,
SavedObjectFinder,
unhashUrl,
} from './legacy_imports';
import { FilterStateManager, IndexPattern } from '../../../data/public';
Expand Down Expand Up @@ -115,7 +114,7 @@ export class DashboardAppController {
timefilter: { timefilter },
},
},
core: { notifications, overlays, chrome, injectedMetadata },
core: { notifications, overlays, chrome, injectedMetadata, uiSettings, savedObjects },
}: DashboardAppControllerDependencies) {
new FilterStateManager(globalState, getAppState, filterManager);
const queryFilter = filterManager;
Expand Down Expand Up @@ -724,7 +723,8 @@ export class DashboardAppController {
getFactory: embeddables.getEmbeddableFactory,
notifications,
overlays,
SavedObjectFinder,
uiSettings,
savedObjects,
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ export { stateMonitorFactory, StateMonitor } from 'ui/state_management/state_mon
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { unhashUrl } from 'ui/state_management/state_hashing';
export { IInjector } from 'ui/chrome';
export { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ import {
EuiFlyoutBody,
EuiTitle,
} from '@elastic/eui';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
import { SavedObjectFinderUi } from '../../../../../../../plugins/kibana_react/public';
import { getServices } from '../../kibana_services';

const SEARCH_OBJECT_TYPE = 'search';

export function OpenSearchPanel(props) {
const {
core: { uiSettings, savedObjects },
} = getServices();

return (
<EuiFlyout ownFocus onClose={props.onClose} data-test-subj="loadSearchForm">
<EuiFlyoutHeader hasBorder>
Expand All @@ -50,7 +55,7 @@ export function OpenSearchPanel(props) {
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<SavedObjectFinder
<SavedObjectFinderUi
noItemsMessage={
<FormattedMessage
id="kbn.discover.topNav.openSearchPanel.noSearchesFoundDescription"
Expand All @@ -70,6 +75,8 @@ export function OpenSearchPanel(props) {
window.location.assign(props.makeUrl(id));
props.onClose();
}}
uiSettings={uiSettings}
savedObjects={savedObjects}
/>
</EuiFlyoutBody>
<EuiFlyoutFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { shallow } from 'enzyme';
jest.mock('../../kibana_services', () => {
return {
getServices: () => ({
SavedObjectFinder: jest.fn()
core: { uiSettings: {}, savedObjects: {} },
}),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';

import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';

import { VisType } from '../../kibana_services';
import { VisType, getServices } from '../../kibana_services';
import { SavedObjectFinderUi } from '../../../../../../../plugins/kibana_react/public';

interface SearchSelectionProps {
onSearchSelected: (searchId: string, searchType: string) => void;
Expand All @@ -35,6 +34,9 @@ export class SearchSelection extends React.Component<SearchSelectionProps> {
private fixedPageSize: number = 8;

public render() {
const {
core: { uiSettings, savedObjects },
} = getServices();
return (
<React.Fragment>
<EuiModalHeader>
Expand All @@ -52,7 +54,7 @@ export class SearchSelection extends React.Component<SearchSelectionProps> {
</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>
<SavedObjectFinder
<SavedObjectFinderUi
key="searchSavedObjectFinder"
onChoose={this.props.onSearchSelected}
showFilter
Expand Down Expand Up @@ -85,6 +87,8 @@ export class SearchSelection extends React.Component<SearchSelectionProps> {
},
]}
fixedPageSize={this.fixedPageSize}
uiSettings={uiSettings}
savedObjects={savedObjects}
/>
</EuiModalBody>
</React.Fragment>
Expand Down
108 changes: 0 additions & 108 deletions src/legacy/ui/public/saved_objects/components/saved_object_finder.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ let embeddable: ContactCardEmbeddable;
beforeEach(async () => {
const options: DashboardOptions = {
ExitFullScreenButton: () => null,
SavedObjectFinder: () => null,
application: {} as any,
embeddable: {
getEmbeddableFactory: (id: string) => embeddableFactories.get(id)!,
Expand All @@ -52,6 +51,8 @@ beforeEach(async () => {
overlays: {} as any,
savedObjectMetaData: {} as any,
uiActions: {} as any,
uiSettings: {} as any,
savedObjects: {} as any,
};
const input = getSampleDashboardInput({
panels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,10 @@ import {
export async function openReplacePanelFlyout(options: {
embeddable: IContainer;
core: CoreStart;
savedObjectFinder: React.ComponentType<any>;
notifications: CoreStart['notifications'];
panelToRemove: IEmbeddable<EmbeddableInput, EmbeddableOutput>;
getEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories'];
}) {
const {
embeddable,
core,
panelToRemove,
savedObjectFinder,
notifications,
getEmbeddableFactories,
} = options;
const { embeddable, core, panelToRemove, getEmbeddableFactories } = options;
const flyoutSession = core.overlays.openFlyout(
toMountPoint(
<ReplacePanelFlyout
Expand All @@ -54,8 +45,9 @@ export async function openReplacePanelFlyout(options: {
}
}}
panelToRemove={panelToRemove}
savedObjectsFinder={savedObjectFinder}
notifications={notifications}
notifications={core.notifications}
uiSettings={core.uiSettings}
savedObjects={core.savedObjects}
getEmbeddableFactories={getEmbeddableFactories}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ beforeEach(async () => {
coreStart = coreMock.createStart();
const options: DashboardOptions = {
ExitFullScreenButton: () => null,
SavedObjectFinder: () => null,
application: {} as any,
embeddable: {
getEmbeddableFactory: (id: string) => embeddableFactories.get(id)!,
} as any,
inspector: {} as any,
notifications: {} as any,
uiSettings: coreStart.uiSettings,
savedObjects: coreStart.savedObjects,
overlays: coreStart.overlays,
savedObjectMetaData: {} as any,
uiActions: {} as any,
Expand Down Expand Up @@ -82,26 +83,12 @@ beforeEach(async () => {
});

test('Executes the replace panel action', async () => {
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
coreStart,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(coreStart, getEmbeddableFactories);
action.execute({ embeddable });
});

test('Is not compatible when embeddable is not in a dashboard container', async () => {
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
coreStart,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(coreStart, getEmbeddableFactories);
expect(
await action.isCompatible({
embeddable: new ContactCardEmbeddable(
Expand All @@ -113,40 +100,19 @@ test('Is not compatible when embeddable is not in a dashboard container', async
});

test('Execute throws an error when called with an embeddable not in a parent', async () => {
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
coreStart,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(coreStart, getEmbeddableFactories);
async function check() {
await action.execute({ embeddable: container });
}
await expect(check()).rejects.toThrow(Error);
});

test('Returns title', async () => {
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
coreStart,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(coreStart, getEmbeddableFactories);
expect(action.getDisplayName({ embeddable })).toBeDefined();
});

test('Returns an icon', async () => {
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
coreStart,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(coreStart, getEmbeddableFactories);
expect(action.getIconType({ embeddable })).toBeDefined();
});
Loading