Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions x-pack/legacy/plugins/ml/common/types/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Moment } from 'moment';

// TS TODO: This is not yet a fully fledged representation of the job data structure,
// but it fulfills some basic TypeScript related needs.
export interface MlJob {
Expand Down Expand Up @@ -63,6 +65,20 @@ export interface MlSummaryJob {

export type MlSummaryJobs = MlSummaryJob[];

export interface MlJobWithTimeRange extends MlJob {
groups: string[];
timeRange: {
from: number;
to: number;
fromPx: number;
toPx: number;
fromMoment: Moment;
toMoment: Moment;
widthPx: number;
label: string;
};
}

export function isMlJob(arg: any): arg is MlJob {
return typeof arg.job_id === 'string';
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { injectObservablesAsProps } from '../../../util/observable_utils';
import useObservable from 'react-use/lib/useObservable';

import mockAnnotations from '../annotations_table/__mocks__/mock_annotations.json';

import React, { ComponentType } from 'react';
import React from 'react';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';

import { Annotation } from '../../../../../common/types/annotations';
Expand All @@ -25,11 +26,14 @@ describe('AnnotationFlyout', () => {
const annotation = mockAnnotations[1] as Annotation;
annotation$.next(annotation);

// injectObservablesAsProps wraps the observable in a new component
const ObservableComponent = injectObservablesAsProps(
{ annotation: annotation$ },
(AnnotationFlyout as any) as ComponentType
);
// useObservable wraps the observable in a new component
const ObservableComponent = (props: any) => {
const annotationProp = useObservable(annotation$);
if (annotationProp === undefined) {
return null;
}
return <AnnotationFlyout annotation={annotationProp} {...props} />;
};

const wrapper = mountWithIntl(<ObservableComponent />);
const updateBtn = wrapper.find('EuiButton').first();
Expand All @@ -40,11 +44,14 @@ describe('AnnotationFlyout', () => {
const annotation = mockAnnotations[2] as Annotation;
annotation$.next(annotation);

// injectObservablesAsProps wraps the observable in a new component
const ObservableComponent = injectObservablesAsProps(
{ annotation: annotation$ },
(AnnotationFlyout as any) as ComponentType
);
// useObservable wraps the observable in a new component
const ObservableComponent = (props: any) => {
const annotationProp = useObservable(annotation$);
if (annotationProp === undefined) {
return null;
}
return <AnnotationFlyout annotation={annotationProp} {...props} />;
};

const wrapper = mountWithIntl(<ObservableComponent />);
const updateBtn = wrapper.find('EuiButton').first();
Expand Down
Loading