77import React from 'react' ;
88import { CoreStart } from 'kibana/public' ;
99import moment from 'moment' ;
10+ import { takeUntil } from 'rxjs/operators' ;
11+ import { from } from 'rxjs' ;
1012import { VIEW_BY_JOB_LABEL } from '../../application/explorer/explorer_constants' ;
1113import {
1214 KibanaContextProvider ,
@@ -19,13 +21,19 @@ import { getInitialGroupsMap } from '../../application/components/job_selector/j
1921import { getDefaultPanelTitle } from './anomaly_swimlane_embeddable' ;
2022import { getMlGlobalServices } from '../../application/app' ;
2123import { HttpService } from '../../application/services/http_service' ;
24+ import { DashboardConstants } from '../../../../../../src/plugins/dashboard/public' ;
2225import { AnomalySwimlaneEmbeddableInput } from '..' ;
2326
2427export async function resolveAnomalySwimlaneUserInput (
2528 coreStart : CoreStart ,
2629 input ?: AnomalySwimlaneEmbeddableInput
2730) : Promise < Partial < AnomalySwimlaneEmbeddableInput > > {
28- const { http, uiSettings, overlays } = coreStart ;
31+ const {
32+ http,
33+ uiSettings,
34+ overlays,
35+ application : { currentAppId$ } ,
36+ } = coreStart ;
2937
3038 const anomalyDetectorService = new AnomalyDetectorService ( new HttpService ( http ) ) ;
3139
@@ -90,5 +98,12 @@ export async function resolveAnomalySwimlaneUserInput(
9098 ownFocus : true ,
9199 }
92100 ) ;
101+
102+ // Close the flyout when user navigates out of the dashboard plugin
103+ currentAppId$ . pipe ( takeUntil ( from ( flyoutSession . onClose ) ) ) . subscribe ( ( appId ) => {
104+ if ( appId !== DashboardConstants . DASHBOARDS_ID ) {
105+ flyoutSession . close ( ) ;
106+ }
107+ } ) ;
93108 } ) ;
94109}
0 commit comments