import { first } from 'rxjs/operators' ; import { i18n } from '@kbn/i18n' ; import { CoreSetup , PluginInitializerContext , Plugin } from 'src/core/public' ; import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public' ; import { PLUGIN } from '../common/constants' ; import { init as initHttp } from './application/services/http' ; import { init as initUiMetric } from './application/services/ui_metric' ; import { init as initNotification } from './application/services/notification' ; import { BreadcrumbService } from './application/services/breadcrumbs' ; import { addAllExtensions } from './extend_index_management' ; import { ClientConfigType , SetupDependencies , StartDependencies } from './types' ; import { IlmLocatorDefinition } from './locator' ; export class IndexLifecycleManagementPlugin implements Plugin < void , void , SetupDependencies , StartDependencies > { constructor ( private readonly initializerContext ) { } private breadcrumbService = new BreadcrumbService ( ) ; public setup ( coreSetup , plugins ) { const { ui : { enabled : isIndexLifecycleManagementUiEnabled } , } = this . initializerContext . config . get < ClientConfigType > ( ) ; if ( isIndexLifecycleManagementUiEnabled ) { const { http , notifications : { toasts } , fatalErrors , getStartServices , } = coreSetup ; const { usageCollection , management , indexManagement , home , cloud } = plugins ; initHttp ( http ) ; initUiMetric ( usageCollection ) ; initNotification ( toasts , fatalErrors ) ; management . sections . section . data . registerApp ( { id : PLUGIN . ID , title : PLUGIN . TITLE , order : 2 , mount : async ( { element , history , setBreadcrumbs , theme$ } ) => { const [ coreStart , { licensing } ] = await getStartServices ( ) ; const { chrome : { docTitle } , i18n : { Context : I18nContext } , application , docLinks , } = coreStart ; const license = await licensing . license$ . pipe ( first ( ) ) . toPromise ( ) ; docTitle . change ( PLUGIN . TITLE ) ; this . breadcrumbService . setup ( setBreadcrumbs ) ; const { renderApp } = await import ( './application' ) ; const unmountAppCallback = renderApp ( element , I18nContext , history , application , this . breadcrumbService , license , theme$ , docLinks , cloud ) ; return ( ) => { docTitle . reset ( ) ; unmountAppCallback ( ) ; } ; } , } ) ; if ( home ) { home . featureCatalogue . register ( { id : PLUGIN . ID , title : i18n . translate ( 'xpack.indexLifecycleMgmt.featureCatalogueTitle' , { defaultMessage : 'Manage index lifecycles' , } ) , description : i18n . translate ( 'xpack.indexLifecycleMgmt.featureCatalogueDescription' , { defaultMessage : 'Define lifecycle policies to automatically perform operations as an index ages.' , } ) , icon : 'indexRollupApp' , path : '/app/management/data/index_lifecycle_management' , showOnHomePage : true , category : FeatureCatalogueCategory . ADMIN , order : 640 , } ) ; } if ( indexManagement ) { addAllExtensions ( indexManagement . extensionsService ) ; } plugins . share . url . locators . create ( new IlmLocatorDefinition ( { managementAppLocator : plugins . management . locator , } ) ) ; } } public start ( ) { } public stop ( ) { } }