import { Observable } from 'rxjs' ; import { takeUntil , startWith , map } from 'rxjs/operators' ; import { ServiceStatus , ServiceStatusLevels } from '../../../../src/core/server' ; import { ILicense } from '../common/types' ; export const getPluginStatus$ = ( license$ , stop$ ) : Observable < ServiceStatus > => { return license$ . pipe ( startWith ( undefined ) , takeUntil ( stop$ ) , map ( ( license ) => { if ( license ) { if ( license . error ) { return { level : ServiceStatusLevels . unavailable , summary : 'Error fetching license' , } ; } return { level : ServiceStatusLevels . available , summary : 'License fetched' , } ; } return { level : ServiceStatusLevels . degraded , summary : 'License not fetched yet' , } ; } ) ) ; } ;