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 (#70920)
  • Loading branch information
kertal committed Jul 13, 2020
1 parent b4737e8 commit 84edc36
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
export { SEARCH_EMBEDDABLE_TYPE } from './constants';
export * from './types';
export * from './search_embeddable_factory';
export * from './search_embeddable';
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import * as columnActions from '../angular/doc_table/actions/columns';
import searchTemplate from './search_template.html';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
import { SortOrder } from '../angular/doc_table/components/table_header/helpers';
import { getSortForSearchSource } from '../angular/doc_table/lib/get_sort_for_search_source';
import { getSortForSearchSource } from '../angular/doc_table';
import {
getRequestInspectorStats,
getResponseInspectorStats,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
} from '../../../../embeddable/public';

import { TimeRange } from '../../../../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 +92,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
11 changes: 10 additions & 1 deletion src/plugins/discover/public/application/embeddable/types.ts
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 {
Embeddable,
EmbeddableInput,
EmbeddableOutput,
IEmbeddable,
} from 'src/plugins/embeddable/public';
import { SortOrder } from '../angular/doc_table/components/table_header/helpers';
import { Filter, IIndexPattern, TimeRange, Query } from '../../../../data/public';
import { SavedSearch } from '../..';
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;
}
8 changes: 2 additions & 6 deletions src/plugins/discover/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {
DISCOVER_APP_URL_GENERATOR,
DiscoverUrlGenerator,
} from './url_generator';
import { SearchEmbeddableFactory } from './application/embeddable';

declare module '../../share/public' {
export interface UrlGeneratorStateMapping {
Expand Down Expand Up @@ -345,12 +346,7 @@ export class DiscoverPlugin
/**
* register embeddable with a slimmer embeddable version of inner angular
*/
private async registerEmbeddable(
core: CoreSetup<DiscoverStartPlugins>,
plugins: DiscoverSetupPlugins
) {
const { SearchEmbeddableFactory } = await import('./application/embeddable');

private registerEmbeddable(core: CoreSetup<DiscoverStartPlugins>, plugins: DiscoverSetupPlugins) {
if (!this.getEmbeddableInjector) {
throw Error('Discover plugin method getEmbeddableInjector is undefined');
}
Expand Down

0 comments on commit 84edc36

Please sign in to comment.