import { Subject } from 'rxjs' ; import { ConfigSchema } from '.' ; import { AppNavLinkStatus , AppUpdater , ApplicationStart , AppDeepLink , } from '../../../../src/core/public' ; import { CasesDeepLinkId } from '../../cases/public' ; import { casesFeatureId } from '../common' ; export function updateGlobalNavigation ( { capabilities , config , deepLinks , updater$ , } ) { const { apm , logs , metrics , uptime } = capabilities . navLinks ; const someVisible = Object . values ( { apm , logs , metrics , uptime } ) . some ( ( visible ) => visible ) ; const updatedDeepLinks = deepLinks . map ( ( link ) => { switch ( link . id ) { case CasesDeepLinkId . cases : return { ... link , navLinkStatus : config . unsafe . cases . enabled && capabilities [ casesFeatureId ] . read_cases && someVisible ? AppNavLinkStatus . visible : AppNavLinkStatus . hidden , } ; case 'alerts' : return { ... link , navLinkStatus : config . unsafe . alertingExperience . enabled && someVisible ? AppNavLinkStatus . visible : AppNavLinkStatus . hidden , } ; default : return link ; } } ) ; updater$ . next ( ( ) => ( { deepLinks : updatedDeepLinks , navLinkStatus : someVisible ? AppNavLinkStatus . visible : AppNavLinkStatus . hidden , } ) ) ; }