[Discover] Migrate async import of embeddable factory to actual embeddable (#70920) (#71447)

This commit is contained in:
Matthias Wilhelm 2020-07-13 18:55:23 +02:00 committed by GitHub
parent 9c402bac08
commit e2d7e2cbdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 12 deletions

View file

@ -20,4 +20,3 @@
export { SEARCH_EMBEDDABLE_TYPE } from './constants';
export * from './types';
export * from './search_embeddable_factory';
export * from './search_embeddable';

View file

@ -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,

View file

@ -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 {
@ -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,

View file

@ -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 '../..';
@ -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;
}

View file

@ -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 {
@ -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');
}