import { first } from 'rxjs/operators' ; import { CoreSetup , Plugin , PluginInitializerContext } from 'src/core/public' ; import { TelemetryPluginStart } from '../../../../src/plugins/telemetry/public' ; import { ManagementSetup } from '../../../../src/plugins/management/public' ; import { LicensingPluginSetup } from '../../../plugins/licensing/public' ; import { PLUGIN } from '../common/constants' ; import { ClientConfigType } from './types' ; import { AppDependencies } from './application' ; import { BreadcrumbService } from './application/breadcrumbs' ; interface PluginsDependenciesSetup { management : ManagementSetup ; licensing : LicensingPluginSetup ; } interface PluginsDependenciesStart { telemetry ? : TelemetryPluginStart ; } export interface LicenseManagementUIPluginSetup { enabled : boolean ; } export type LicenseManagementUIPluginStart = void ; export class LicenseManagementUIPlugin implements Plugin < LicenseManagementUIPluginSetup , LicenseManagementUIPluginStart , any , any > { private breadcrumbService = new BreadcrumbService ( ) ; constructor ( private readonly initializerContext ) { } setup ( coreSetup , plugins ) { const config = this . initializerContext . config . get < ClientConfigType > ( ) ; if ( ! config . ui . enabled ) { return { enabled : false , } ; } const { getStartServices } = coreSetup ; const { management , licensing } = plugins ; management . sections . section . stack . registerApp ( { id : PLUGIN . id , title : PLUGIN . title , order : 0 , mount : async ( { element , setBreadcrumbs , history , theme$ } ) => { const [ coreStart , { telemetry } ] = await getStartServices ( ) ; const initialLicense = await plugins . licensing . license$ . pipe ( first ( ) ) . toPromise ( ) ; const { docLinks , chrome : { docTitle } , } = coreStart ; const appDocLinks = { security : docLinks . links . security . elasticsearchSettings , } ; docTitle . change ( PLUGIN . title ) ; this . breadcrumbService . setup ( setBreadcrumbs ) ; const appDependencies = { core : coreStart , config , plugins : { licensing , telemetry , } , services : { breadcrumbService : this . breadcrumbService , history , } , store : { initialLicense , } , docLinks : appDocLinks , theme$ , } ; const { renderApp } = await import ( './application' ) ; const unmountAppCallback = renderApp ( element , appDependencies ) ; return ( ) => { docTitle . reset ( ) ; unmountAppCallback ( ) ; } ; } , } ) ; return { enabled : true , } ; } start ( ) { } stop ( ) { } }