-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Decouple open-in-anomaly-explorer action #178729
Changes from 8 commits
00fb5db
5f0c122
f2886b1
0673c47
d291b52
4211c14
fd352ad
b2130b3
d4debca
48d9c50
22df822
dfaef99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,26 @@ | |
* 2.0. | ||
*/ | ||
|
||
import React, { Suspense } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import type { CoreStart } from '@kbn/core/public'; | ||
import type { IContainer } from '@kbn/embeddable-plugin/public'; | ||
import { embeddableInputToSubject, embeddableOutputToSubject } from '@kbn/embeddable-plugin/public'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { Subject } from 'rxjs'; | ||
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; | ||
import type { IContainer } from '@kbn/embeddable-plugin/public'; | ||
import { EmbeddableSwimLaneContainer } from './embeddable_swim_lane_container_lazy'; | ||
import type { JobId } from '../../../common/types/anomaly_detection_jobs'; | ||
import type { MlDependencies } from '../../application/app'; | ||
import { SWIM_LANE_SELECTION_TRIGGER } from '../../ui_actions'; | ||
import React, { Suspense } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { BehaviorSubject, Subject, Subscription } from 'rxjs'; | ||
import type { | ||
AnomalySwimlaneEmbeddableInput, | ||
AnomalySwimlaneEmbeddableOutput, | ||
AnomalySwimlaneServices, | ||
} from '..'; | ||
import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '..'; | ||
import { EmbeddableLoading } from '../common/components/embeddable_loading_fallback'; | ||
import type { JobId } from '../../../common/types/anomaly_detection_jobs'; | ||
import type { MlDependencies } from '../../application/app'; | ||
import { SWIM_LANE_SELECTION_TRIGGER } from '../../ui_actions'; | ||
import { AnomalyDetectionEmbeddable } from '../common/anomaly_detection_embeddable'; | ||
import { EmbeddableLoading } from '../common/components/embeddable_loading_fallback'; | ||
import { EmbeddableSwimLaneContainer } from './embeddable_swim_lane_container_lazy'; | ||
|
||
export const getDefaultSwimlanePanelTitle = (jobIds: JobId[]) => | ||
i18n.translate('xpack.ml.swimlaneEmbeddable.title', { | ||
|
@@ -41,12 +42,37 @@ export class AnomalySwimlaneEmbeddable extends AnomalyDetectionEmbeddable< | |
private reload$ = new Subject<void>(); | ||
public readonly type: string = ANOMALY_SWIMLANE_EMBEDDABLE_TYPE; | ||
|
||
// API | ||
public viewBy = new BehaviorSubject<string | undefined>(this.getInput().viewBy); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit. If you're initializing these in the constructor via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good spot, leftovers from the original implementation, updated in 48d9c50 |
||
public perPage = new BehaviorSubject<number | undefined>(this.getOutput().perPage); | ||
public fromPage = new BehaviorSubject<number | undefined>(this.getOutput().fromPage); | ||
|
||
private apiSubscriptions = new Subscription(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I pass it to |
||
|
||
constructor( | ||
initialInput: AnomalySwimlaneEmbeddableInput, | ||
public services: [CoreStart, MlDependencies, AnomalySwimlaneServices], | ||
parent?: IContainer | ||
) { | ||
super(initialInput, services[2].anomalyDetectorService, services[1].data.dataViews, parent); | ||
|
||
this.viewBy = embeddableInputToSubject<string, AnomalySwimlaneEmbeddableInput>( | ||
this.apiSubscriptions, | ||
this, | ||
'viewBy' | ||
); | ||
|
||
this.perPage = embeddableOutputToSubject<number, AnomalySwimlaneEmbeddableOutput>( | ||
this.apiSubscriptions, | ||
this, | ||
'perPage' | ||
); | ||
|
||
this.fromPage = embeddableOutputToSubject<number, AnomalySwimlaneEmbeddableOutput>( | ||
this.apiSubscriptions, | ||
this, | ||
'fromPage' | ||
); | ||
} | ||
|
||
public reportsEmbeddableLoad() { | ||
|
@@ -104,6 +130,7 @@ export class AnomalySwimlaneEmbeddable extends AnomalyDetectionEmbeddable< | |
} | ||
|
||
public destroy() { | ||
this.apiSubscriptions.unsubscribe(); | ||
super.destroy(); | ||
if (this.node) { | ||
ReactDOM.unmountComponentAtNode(this.node); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use
embeddableOutputToSubject
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it for one embeddable and forgot the other 🤦🏻 Updated in d4debca