Skip to content

Commit

Permalink
start removing stateful saved object finder
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Dec 4, 2019
1 parent 7ce0a37 commit 6bbdddc
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 92 deletions.
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 @@ -728,7 +727,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';
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 { SavedObjectFinder } 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 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
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
overlays={this.props.kibana.services.overlays}
notifications={this.props.kibana.services.notifications}
inspector={this.props.kibana.services.inspector}
SavedObjectFinder={this.props.kibana.services.SavedObjectFinder}
uiSettings={this.props.kibana.services.}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ test('EmbeddableChildPanel renders an embeddable when it is done loading', async
getEmbeddableFactory={(() => undefined) as any}
notifications={{} as any}
overlays={{} as any}
uiSettings={{} as any}
savedObjects={{} as any}
inspector={inspector}
SavedObjectFinder={() => null}
/>
);

Expand Down Expand Up @@ -106,8 +107,9 @@ test(`EmbeddableChildPanel renders an error message if the factory doesn't exist
getEmbeddableFactory={(() => undefined) as any}
notifications={{} as any}
overlays={{} as any}
uiSettings={{} as any}
savedObjects={{} as any}
inspector={inspector}
SavedObjectFinder={() => null}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export interface EmbeddableChildPanelProps {
getAllEmbeddableFactories: GetEmbeddableFactories;
overlays: CoreStart['overlays'];
notifications: CoreStart['notifications'];
uiSettings: CoreStart['uiSettings'];
savedObjects: CoreStart['savedObjects'];
inspector: InspectorStartContract;
SavedObjectFinder: React.ComponentType<any>;
}

interface State {
Expand Down Expand Up @@ -102,8 +103,9 @@ export class EmbeddableChildPanel extends React.Component<EmbeddableChildPanelPr
getAllEmbeddableFactories={this.props.getAllEmbeddableFactories}
overlays={this.props.overlays}
notifications={this.props.notifications}
savedObjects={this.props.savedObjects}
uiSettings={this.props.uiSettings}
inspector={this.props.inspector}
SavedObjectFinder={this.props.SavedObjectFinder}
/>
)}
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ interface Props {
getAllEmbeddableFactories: GetEmbeddableFactories;
overlays: CoreStart['overlays'];
notifications: CoreStart['notifications'];
uiSettings: CoreStart['uiSettings'];
savedObjects: CoreStart['savedObjects'];
inspector: InspectorStartContract;
SavedObjectFinder: React.ComponentType<any>;
hideHeader?: boolean;
}

Expand Down Expand Up @@ -233,7 +234,8 @@ export class EmbeddablePanel extends React.Component<Props, State> {
this.props.getAllEmbeddableFactories,
this.props.overlays,
this.props.notifications,
this.props.SavedObjectFinder
this.props.uiSettings,
this.props.savedObjects
),
new InspectPanelAction(this.props.inspector),
new RemovePanelAction(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { i18n } from '@kbn/i18n';
import { IAction } from 'src/plugins/ui_actions/public';
import { NotificationsStart, OverlayStart } from 'src/core/public';
import { CoreStart, NotificationsStart, OverlayStart } from 'src/core/public';
import { ViewMode, GetEmbeddableFactory, GetEmbeddableFactories } from '../../../../types';
import { openAddPanelFlyout } from './open_add_panel_flyout';
import { IContainer } from '../../../../containers';
Expand All @@ -38,7 +38,8 @@ export class AddPanelAction implements IAction<ActionContext> {
private readonly getAllFactories: GetEmbeddableFactories,
private readonly overlays: OverlayStart,
private readonly notifications: NotificationsStart,
private readonly SavedObjectFinder: React.ComponentType<any>
private readonly uiSettings: CoreStart['uiSettings'],
private readonly savedObjects: CoreStart['savedObjects']
) {}

public getDisplayName() {
Expand Down Expand Up @@ -66,7 +67,8 @@ export class AddPanelAction implements IAction<ActionContext> {
getAllFactories: this.getAllFactories,
overlays: this.overlays,
notifications: this.notifications,
SavedObjectFinder: this.SavedObjectFinder,
savedObjects: this.savedObjects,
uiSettings: this.uiSettings,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { CoreSetup } from 'src/core/public';
import { CoreSetup, CoreStart } from 'src/core/public';

import {
EuiButton,
Expand All @@ -36,14 +36,16 @@ import {
import { IContainer } from '../../../../containers';
import { EmbeddableFactoryNotFoundError } from '../../../../errors';
import { GetEmbeddableFactories, GetEmbeddableFactory } from '../../../../types';
import { SavedObjectFinder } from '../../../../../../../kibana_react/public';

interface Props {
onClose: () => void;
container: IContainer;
getFactory: GetEmbeddableFactory;
getAllFactories: GetEmbeddableFactories;
notifications: CoreSetup['notifications'];
SavedObjectFinder: React.ComponentType<any>;
savedObjects: CoreStart['savedObjects'];
uiSettings: CoreSetup['uiSettings'];
}

interface State {
Expand Down Expand Up @@ -131,7 +133,6 @@ export class AddPanelFlyout extends React.Component<Props, State> {
}

public render() {
const SavedObjectFinder = this.props.SavedObjectFinder;
const savedObjectsFinder = (
<SavedObjectFinder
onChoose={this.onAddPanel}
Expand All @@ -145,6 +146,8 @@ export class AddPanelFlyout extends React.Component<Props, State> {
noItemsMessage={i18n.translate('embeddableApi.addPanel.noMatchingObjectsMessage', {
defaultMessage: 'No matching objects found.',
})}
savedObjects={this.props.savedObjects}
uiSettings={this.props.uiSettings}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { NotificationsStart, OverlayStart } from 'src/core/public';
import { CoreSetup, CoreStart, NotificationsStart, OverlayStart } from 'src/core/public';
import { toMountPoint } from '../../../../../../../kibana_react/public';
import { IContainer } from '../../../../containers';
import { AddPanelFlyout } from './add_panel_flyout';
Expand All @@ -29,15 +29,17 @@ export async function openAddPanelFlyout(options: {
getAllFactories: GetEmbeddableFactories;
overlays: OverlayStart;
notifications: NotificationsStart;
SavedObjectFinder: React.ComponentType<any>;
savedObjects: CoreStart['savedObjects'];
uiSettings: CoreSetup['uiSettings'];
}) {
const {
embeddable,
getFactory,
getAllFactories,
overlays,
notifications,
SavedObjectFinder,
savedObjects,
uiSettings,
} = options;
const flyoutSession = overlays.openFlyout(
toMountPoint(
Expand All @@ -51,7 +53,8 @@ export async function openAddPanelFlyout(options: {
getFactory={getFactory}
getAllFactories={getAllFactories}
notifications={notifications}
SavedObjectFinder={SavedObjectFinder}
savedObjects={savedObjects}
uiSettings={uiSettings}
/>
),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'uiExports/embeddableFactories';
import 'uiExports/embeddableActions';

import { npSetup, npStart } from 'ui/new_platform';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
import { ExitFullScreenButton } from 'ui/exit_full_screen';
import uiRoutes from 'ui/routes';
// @ts-ignore
Expand All @@ -39,7 +38,6 @@ export const setup = pluginInstance.setup(npSetup.core, {
embeddable: npSetup.plugins.embeddable,
inspector: npSetup.plugins.inspector,
__LEGACY: {
SavedObjectFinder,
ExitFullScreenButton,
},
});
Expand All @@ -64,7 +62,6 @@ export const start = pluginInstance.start(npStart.core, {
inspector: npStart.plugins.inspector,
uiActions: npStart.plugins.uiActions,
__LEGACY: {
SavedObjectFinder,
ExitFullScreenButton,
onRenderComplete: (renderCompleteListener: () => void) => {
if (rendered) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
ContactCardEmbeddableFactory,
} from './embeddable_api';
import { App } from './app';
import { SavedObjectFinder as SavedObjectFinderNP } from '../../../../../../../src/plugins/kibana_react/public';
import {
IEmbeddableStart,
IEmbeddableSetup,
Expand All @@ -47,7 +48,6 @@ export interface SetupDependencies {
embeddable: IEmbeddableSetup;
inspector: InspectorSetupContract;
__LEGACY: {
SavedObjectFinder: React.ComponentType<any>;
ExitFullScreenButton: React.ComponentType<any>;
};
}
Expand All @@ -57,7 +57,6 @@ interface StartDependencies {
uiActions: IUiActionsStart;
inspector: InspectorStartContract;
__LEGACY: {
SavedObjectFinder: React.ComponentType<any>;
ExitFullScreenButton: React.ComponentType<any>;
onRenderComplete: (onRenderComplete: () => void) => void;
};
Expand Down Expand Up @@ -97,6 +96,14 @@ export class EmbeddableExplorerPublicPlugin
contactCardEmbeddableFactory
);

const SavedObjectFinder = (props: any) => (
<SavedObjectFinderNP
savedObjects={core.savedObjects}
uiSettings={core.uiSettings}
{...props}
/>
);

plugins.__LEGACY.onRenderComplete(() => {
const root = document.getElementById(REACT_ROOT_ID);
ReactDOM.render(
Expand All @@ -107,8 +114,8 @@ export class EmbeddableExplorerPublicPlugin
notifications={core.notifications}
overlays={core.overlays}
inspector={plugins.inspector}
SavedObjectFinder={plugins.__LEGACY.SavedObjectFinder}
I18nContext={core.i18n.Context}
SavedObjectFinder={SavedObjectFinder}
/>,
root
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { start } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy';
import { EmbeddableExpression } from '../expression_types/embeddable';
import { SavedObjectFinder } from '../../../../../../src/legacy/ui/public/saved_objects/components/saved_object_finder';
import { RendererStrings } from '../../i18n';

const { embeddable: strings } = RendererStrings;
Expand Down Expand Up @@ -48,7 +47,8 @@ const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) =
notifications={npStart.core.notifications}
overlays={npStart.core.overlays}
inspector={npStart.plugins.inspector}
SavedObjectFinder={SavedObjectFinder}
uiSettings={npStart.core.uiSettings}
savedObjects={npStart.core.savedObjects}
/>
</I18nContext>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
import { npStart } from 'ui/new_platform';
import { SavedObjectFinder } from '../../../../../../../../../../src/plugins/kibana_react/public';

export interface PageProps {
nextStepPath: string;
Expand Down Expand Up @@ -76,6 +77,8 @@ export const Page: FC<PageProps> = ({ nextStepPath }) => {
},
]}
fixedPageSize={RESULTS_PER_PAGE}
uiSettings={npStart.core.uiSettings}
savedObjects={npStart.core.savedObjects}
/>
</EuiPageContent>
</EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import React, { useEffect, useState } from 'react';
import { createPortalNode, InPortal } from 'react-reverse-portal';
import styled, { css } from 'styled-components';
import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';

import { EmbeddablePanel } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy';
Expand Down Expand Up @@ -213,9 +212,10 @@ export const EmbeddedMapComponent = ({
getEmbeddableFactory={start.getEmbeddableFactory}
getAllEmbeddableFactories={start.getEmbeddableFactories}
notifications={core.notifications}
uiSettings={core.uiSettings}
savedObjects={core.savedObjects}
overlays={core.overlays}
inspector={plugins.inspector}
SavedObjectFinder={SavedObjectFinder}
/>
) : !isLoading && isIndexError ? (
<IndexPatternsMissingPrompt data-test-subj="missing-prompt" />
Expand Down
Loading

0 comments on commit 6bbdddc

Please sign in to comment.