Skip to content

Commit

Permalink
[Discover] Migrate async import of embeddable factory to actual embed…
Browse files Browse the repository at this point in the history
…dable (elastic#70920)

# Conflicts:
#	src/plugins/discover/public/application/embeddable/index.ts
#	src/plugins/discover/public/application/embeddable/search_embeddable.ts
#	src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts
#	src/plugins/discover/public/application/embeddable/types.ts
#	src/plugins/discover/public/plugin.ts
  • Loading branch information
kertal committed Jul 13, 2020
1 parent 98a855c commit 49bf43a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@

export * from './types';
export * from './search_embeddable_factory';
export * from './search_embeddable';
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import {
} from '../../../../../../../plugins/embeddable/public';

import { TimeRange } from '../../../../../../../plugins/data/public';
import { SearchEmbeddable } from './search_embeddable';
import { SearchInput, SearchOutput } from './types';
import { SearchInput, SearchOutput, SearchEmbeddable } from './types';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';

interface StartServices {
Expand Down Expand Up @@ -92,7 +91,8 @@ export class SearchEmbeddableFactory
const savedObject = await getServices().getSavedSearchById(savedObjectId);
const indexPattern = savedObject.searchSource.getField('index');
const { executeTriggerActions } = await this.getStartServices();
return new SearchEmbeddable(
const { SearchEmbeddable: SearchEmbeddableClass } = await import('./search_embeddable');
return new SearchEmbeddableClass(
{
savedSearch: savedObject,
$rootScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* under the License.
*/

import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from 'src/plugins/embeddable/public';
import {
EmbeddableInput,
EmbeddableOutput,
IEmbeddable,
Embeddable,
} from 'src/plugins/embeddable/public';
import { SortOrder } from '../angular/doc_table/components/table_header/helpers';
import { Filter, IIndexPattern, TimeRange, Query } from '../../../../../../../plugins/data/public';
import { SavedSearch } from '../../../../../../../plugins/discover/public';
Expand All @@ -40,3 +45,7 @@ export interface SearchOutput extends EmbeddableOutput {
export interface ISearchEmbeddable extends IEmbeddable<SearchInput, SearchOutput> {
getSavedSearch(): SavedSearch;
}

export interface SearchEmbeddable extends Embeddable<SearchInput, SearchOutput> {
type: string;
}
3 changes: 1 addition & 2 deletions src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
VisualizationsSetup,
} from '../../../../../plugins/visualizations/public';
import { createKbnUrlTracker } from '../../../../../plugins/kibana_utils/public';
import { SearchEmbeddableFactory } from './np_ready/embeddable';

export interface DiscoverSetupPlugins {
uiActions: UiActionsSetup;
Expand Down Expand Up @@ -202,8 +203,6 @@ export class DiscoverPlugin implements Plugin<void, void> {
core: CoreSetup<DiscoverStartPlugins>,
plugins: DiscoverSetupPlugins
) {
const { SearchEmbeddableFactory } = await import('./np_ready/embeddable');

if (!this.getEmbeddableInjector) {
throw Error('Discover plugin method getEmbeddableInjector is undefined');
}
Expand Down

0 comments on commit 49bf43a

Please sign in to comment.