Skip to content

Commit

Permalink
remove legacy saved object finder
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Dec 4, 2019
1 parent 6bbdddc commit a2fbc47
Show file tree
Hide file tree
Showing 36 changed files with 158 additions and 261 deletions.
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 { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';

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

interface SearchSelectionProps {
onSearchSelected: (searchId: string, searchType: string) => void;
Expand Down Expand Up @@ -54,7 +54,7 @@ export class SearchSelection extends React.Component<SearchSelectionProps> {
</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>
<SavedObjectFinder
<SavedObjectFinderUi
key="searchSavedObjectFinder"
onChoose={this.props.onSearchSelected}
showFilter
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 @@ -43,14 +43,15 @@ let embeddable: ContactCardEmbeddable;
beforeEach(async () => {
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,
overlays: {} as any,
uiSettings: {} as any,
savedObjects: {} as any,
savedObjectMetaData: {} as any,
uiActions: {} as any,
};
Expand Down Expand Up @@ -81,27 +82,13 @@ beforeEach(async () => {

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

test('Is not compatible when embeddable is not in a dashboard container', async () => {
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(core, getEmbeddableFactories);
expect(
await action.isCompatible({
embeddable: new ContactCardEmbeddable(
Expand All @@ -114,14 +101,7 @@ 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 core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(core, getEmbeddableFactories);
async function check() {
await action.execute({ embeddable: container });
}
Expand All @@ -130,26 +110,12 @@ test('Execute throws an error when called with an embeddable not in a parent', a

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

test('Returns an icon', async () => {
let core: any;
let SavedObjectFinder: any;
let notifications: any;
const action = new ReplacePanelAction(
core,
SavedObjectFinder,
notifications,
getEmbeddableFactories
);
const action = new ReplacePanelAction(core, getEmbeddableFactories);
expect(action.getIconType({ embeddable })).toBeDefined();
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export class ReplacePanelAction implements IAction<ActionContext> {

constructor(
private core: CoreStart,
private savedobjectfinder: React.ComponentType<any>,
private notifications: CoreStart['notifications'],
private getEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories']
) {}

Expand Down Expand Up @@ -82,8 +80,6 @@ export class ReplacePanelAction implements IAction<ActionContext> {
openReplacePanelFlyout({
embeddable: dash,
core: this.core,
savedObjectFinder: this.savedobjectfinder,
notifications: this.notifications,
panelToRemove: view,
getEmbeddableFactories: this.getEmbeddableFactories,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ import React from 'react';
import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, EuiTitle } from '@elastic/eui';
import { GetEmbeddableFactories } from 'src/plugins/embeddable/public';
import { DashboardPanelState } from '../embeddable';
import { NotificationsStart, Toast } from '../../../../core/public';
import { CoreStart, NotificationsStart, Toast } from '../../../../core/public';
import { IContainer, IEmbeddable, EmbeddableInput, EmbeddableOutput } from '../embeddable_plugin';
import { SavedObjectFinderUi } from '../../../kibana_react/public';

interface Props {
container: IContainer;
savedObjectsFinder: React.ComponentType<any>;
onClose: () => void;
notifications: NotificationsStart;
uiSettings: CoreStart['uiSettings'];
savedObjects: CoreStart['savedObjects'];
panelToRemove: IEmbeddable<EmbeddableInput, EmbeddableOutput>;
getEmbeddableFactories: GetEmbeddableFactories;
}
Expand Down Expand Up @@ -94,9 +96,8 @@ export class ReplacePanelFlyout extends React.Component<Props> {
};

public render() {
const SavedObjectFinder = this.props.savedObjectsFinder;
const savedObjectsFinder = (
<SavedObjectFinder
<SavedObjectFinderUi
noItemsMessage={i18n.translate(
'dashboardEmbeddableContainer.addPanel.noMatchingObjectsMessage',
{
Expand All @@ -111,6 +112,8 @@ export class ReplacePanelFlyout extends React.Component<Props> {
.map(({ savedObjectMetaData }) => savedObjectMetaData as any)}
showFilter={true}
onChoose={this.onReplacePanel}
uiSettings={this.props.uiSettings}
savedObjects={this.props.savedObjects}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ const options: DashboardContainerOptions = {
notifications: {} as any,
overlays: {} as any,
inspector: {} as any,
SavedObjectFinder: () => null,
ExitFullScreenButton: () => null,
uiActions: {} as any,
uiSettings: {} as any,
savedObjects: {} as any,
};

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ export interface DashboardContainerOptions {
application: CoreStart['application'];
overlays: CoreStart['overlays'];
notifications: CoreStart['notifications'];
savedObjects: CoreStart['savedObjects'];
uiSettings: CoreStart['uiSettings'];
embeddable: IEmbeddableStart;
inspector: InspectorStartContract;
SavedObjectFinder: React.ComponentType<any>;
ExitFullScreenButton: React.ComponentType<any>;
uiActions: IUiActionsStart;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ function prepare(props?: Partial<DashboardGridProps>) {
notifications: {} as any,
overlays: {} as any,
inspector: {} as any,
SavedObjectFinder: () => null,
ExitFullScreenButton: () => null,
uiActions: {} as any,
uiSettings: {} as any,
savedObjects: {} as any,
};
dashboardContainer = new DashboardContainer(initialInput, options);
const defaultTestProps: DashboardGridProps = {
Expand Down
Loading

0 comments on commit a2fbc47

Please sign in to comment.