@@ -25,7 +25,7 @@ import { registerFeature } from './helpers/register_feature';
2525import './kibana_services' ;
2626import { IEmbeddableStart , IEmbeddableSetup } from '../../../../../plugins/embeddable/public' ;
2727import { getInnerAngularModule , getInnerAngularModuleEmbeddable } from './get_inner_angular' ;
28- import { setAngularModule , setServices } from './kibana_services' ;
28+ import { Chrome , setAngularModule , setServices } from './kibana_services' ;
2929import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public' ;
3030import { EuiUtilsStart } from '../../../../../plugins/eui_utils/public' ;
3131import { buildServices } from './helpers/build_services' ;
@@ -49,6 +49,9 @@ export interface DiscoverSetupPlugins {
4949 uiActions : IUiActionsStart ;
5050 embeddable : IEmbeddableSetup ;
5151 kibana_legacy : KibanaLegacySetup ;
52+ __LEGACY : {
53+ chrome : Chrome ;
54+ } ;
5255}
5356export interface DiscoverStartPlugins {
5457 uiActions : IUiActionsStart ;
@@ -70,16 +73,16 @@ const embeddableAngularName = 'app/discoverEmbeddable';
7073export class DiscoverPlugin implements Plugin < DiscoverSetup , DiscoverStart > {
7174 private servicesInitialized : boolean = false ;
7275 private innerAngularInitialized : boolean = false ;
73- private readonly docViewsRegistry : DocViewsRegistry ;
76+ private docViewsRegistry : DocViewsRegistry | null = null ;
7477 /**
7578 * why are those functions public? they are needed for some mocha tests
7679 * can be removed once all is Jest
7780 */
7881 public initializeInnerAngular ?: ( ) => void ;
7982 public initializeServices ?: ( ) => void ;
8083
81- constructor ( ) {
82- this . docViewsRegistry = new DocViewsRegistry ( ) ;
84+ setup ( core : CoreSetup , plugins : DiscoverSetupPlugins ) : DiscoverSetup {
85+ this . docViewsRegistry = new DocViewsRegistry ( plugins . __LEGACY . chrome ) ;
8386 this . docViewsRegistry . addDocView ( {
8487 title : i18n . translate ( 'kbn.discover.docViews.table.tableTitle' , {
8588 defaultMessage : 'Table' ,
@@ -94,9 +97,6 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
9497 order : 20 ,
9598 component : JsonCodeBlock ,
9699 } ) ;
97- }
98-
99- setup ( core : CoreSetup , plugins : DiscoverSetupPlugins ) : DiscoverSetup {
100100 plugins . kibana_legacy . registerLegacyApp ( {
101101 id : 'discover' ,
102102 title : 'Discover' ,
@@ -140,7 +140,7 @@ export class DiscoverPlugin implements Plugin<DiscoverSetup, DiscoverStart> {
140140 if ( this . servicesInitialized ) {
141141 return ;
142142 }
143- const services = await buildServices ( core , plugins , this . docViewsRegistry ) ;
143+ const services = await buildServices ( core , plugins , this . docViewsRegistry ! ) ;
144144 setServices ( services ) ;
145145 this . servicesInitialized = true ;
146146 } ;
0 commit comments