Skip to content

Commit adc711a

Browse files
committed
[ML] close job selector flyout on navigating away from the dashboard
1 parent b6b4c10 commit adc711a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_setup_flyout.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import React from 'react';
88
import { CoreStart } from 'kibana/public';
99
import moment from 'moment';
10+
import { takeUntil } from 'rxjs/operators';
11+
import { from } from 'rxjs';
1012
import { VIEW_BY_JOB_LABEL } from '../../application/explorer/explorer_constants';
1113
import {
1214
KibanaContextProvider,
@@ -19,13 +21,19 @@ import { getInitialGroupsMap } from '../../application/components/job_selector/j
1921
import { getDefaultPanelTitle } from './anomaly_swimlane_embeddable';
2022
import { getMlGlobalServices } from '../../application/app';
2123
import { HttpService } from '../../application/services/http_service';
24+
import { DashboardConstants } from '../../../../../../src/plugins/dashboard/public';
2225
import { AnomalySwimlaneEmbeddableInput } from '..';
2326

2427
export 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

Comments
 (0)