Skip to content

Commit

Permalink
[ML] close job selector flyout on navigating away from the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Oct 7, 2020
1 parent b6b4c10 commit adc711a
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import React from 'react';
import { CoreStart } from 'kibana/public';
import moment from 'moment';
import { takeUntil } from 'rxjs/operators';
import { from } from 'rxjs';
import { VIEW_BY_JOB_LABEL } from '../../application/explorer/explorer_constants';
import {
KibanaContextProvider,
Expand All @@ -19,13 +21,19 @@ import { getInitialGroupsMap } from '../../application/components/job_selector/j
import { getDefaultPanelTitle } from './anomaly_swimlane_embeddable';
import { getMlGlobalServices } from '../../application/app';
import { HttpService } from '../../application/services/http_service';
import { DashboardConstants } from '../../../../../../src/plugins/dashboard/public';
import { AnomalySwimlaneEmbeddableInput } from '..';

export async function resolveAnomalySwimlaneUserInput(
coreStart: CoreStart,
input?: AnomalySwimlaneEmbeddableInput
): Promise<Partial<AnomalySwimlaneEmbeddableInput>> {
const { http, uiSettings, overlays } = coreStart;
const {
http,
uiSettings,
overlays,
application: { currentAppId$ },
} = coreStart;

const anomalyDetectorService = new AnomalyDetectorService(new HttpService(http));

Expand Down Expand Up @@ -90,5 +98,12 @@ export async function resolveAnomalySwimlaneUserInput(
ownFocus: true,
}
);

// Close the flyout when user navigates out of the dashboard plugin
currentAppId$.pipe(takeUntil(from(flyoutSession.onClose))).subscribe((appId) => {
if (appId !== DashboardConstants.DASHBOARDS_ID) {
flyoutSession.close();
}
});
});
}

0 comments on commit adc711a

Please sign in to comment.