66
77import { CoreSetup , CoreStart , Plugin , PluginInitializerContext } from 'src/core/public' ;
88import { i18n } from '@kbn/i18n' ;
9+ import { SecurityPluginStart } from '../../security/public' ;
910import { getIsCloudEnabled } from '../common/is_cloud_enabled' ;
1011import { ELASTIC_SUPPORT_LINK } from '../common/constants' ;
1112import { HomePublicPluginSetup } from '../../../../src/plugins/home/public' ;
13+ import { createUserMenuLinks } from './user_menu_links' ;
1214
13- interface CloudConfigType {
15+ export interface CloudConfigType {
1416 id ?: string ;
1517 resetPasswordUrl ?: string ;
1618 deploymentUrl ?: string ;
@@ -22,6 +24,10 @@ interface CloudSetupDependencies {
2224 home ?: HomePublicPluginSetup ;
2325}
2426
27+ interface CloudStartDependencies {
28+ security ?: SecurityPluginStart ;
29+ }
30+
2531export interface CloudSetup {
2632 cloudId ?: string ;
2733 cloudDeploymentUrl ?: string ;
@@ -33,33 +39,32 @@ export interface CloudSetup {
3339
3440export class CloudPlugin implements Plugin < CloudSetup > {
3541 private config ! : CloudConfigType ;
42+ private isCloudEnabled : boolean ;
3643
3744 constructor ( private readonly initializerContext : PluginInitializerContext ) {
3845 this . config = this . initializerContext . config . get < CloudConfigType > ( ) ;
46+ this . isCloudEnabled = false ;
3947 }
4048
4149 public async setup ( core : CoreSetup , { home } : CloudSetupDependencies ) {
42- const { id, resetPasswordUrl, deploymentUrl, accountUrl , securityUrl } = this . config ;
43- const isCloudEnabled = getIsCloudEnabled ( id ) ;
50+ const { id, resetPasswordUrl, deploymentUrl } = this . config ;
51+ this . isCloudEnabled = getIsCloudEnabled ( id ) ;
4452
4553 if ( home ) {
46- home . environment . update ( { cloud : isCloudEnabled } ) ;
47- if ( isCloudEnabled ) {
54+ home . environment . update ( { cloud : this . isCloudEnabled } ) ;
55+ if ( this . isCloudEnabled ) {
4856 home . tutorials . setVariable ( 'cloud' , { id, resetPasswordUrl } ) ;
4957 }
5058 }
5159
5260 return {
5361 cloudId : id ,
5462 cloudDeploymentUrl : deploymentUrl ,
55- isCloudEnabled,
56- resetPasswordUrl,
57- accountUrl,
58- securityUrl,
63+ isCloudEnabled : this . isCloudEnabled ,
5964 } ;
6065 }
6166
62- public start ( coreStart : CoreStart ) {
67+ public start ( coreStart : CoreStart , { security } : CloudStartDependencies ) {
6368 const { deploymentUrl } = this . config ;
6469 coreStart . chrome . setHelpSupportUrl ( ELASTIC_SUPPORT_LINK ) ;
6570 if ( deploymentUrl ) {
@@ -71,5 +76,10 @@ export class CloudPlugin implements Plugin<CloudSetup> {
7176 href : deploymentUrl ,
7277 } ) ;
7378 }
79+
80+ if ( security && this . isCloudEnabled ) {
81+ const userMenuLinks = createUserMenuLinks ( this . config ) ;
82+ security . navControlService . setUserMenuLinks ( userMenuLinks ) ;
83+ }
7484 }
7585}
0 commit comments