Skip to content

Commit 9999f59

Browse files
committed
[ML] embeddable exports
1 parent 2d914a4 commit 9999f59

18 files changed

Lines changed: 105 additions & 116 deletions

x-pack/plugins/ml/public/application/explorer/add_to_dashboard_control.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { getDefaultPanelTitle } from '../../embeddables/anomaly_swimlane/anomaly
2929
import { useDashboardService } from '../services/dashboard_service';
3030
import { SWIMLANE_TYPE, SwimlaneType } from './explorer_constants';
3131
import { JobId } from '../../../common/types/anomaly_detection_jobs';
32-
import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../..';
32+
import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../../embeddables';
3333

3434
export interface DashboardItem {
3535
id: string;

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

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,81 +9,24 @@ import ReactDOM from 'react-dom';
99
import { CoreStart } from 'kibana/public';
1010
import { i18n } from '@kbn/i18n';
1111
import { Subject } from 'rxjs';
12-
import {
13-
Embeddable,
14-
EmbeddableInput,
15-
EmbeddableOutput,
16-
IContainer,
17-
IEmbeddable,
18-
} from '../../../../../../src/plugins/embeddable/public';
12+
import { Embeddable, IContainer } from '../../../../../../src/plugins/embeddable/public';
1913
import { EmbeddableSwimLaneContainer } from './embeddable_swim_lane_container';
20-
import { AnomalyDetectorService } from '../../application/services/anomaly_detector_service';
2114
import { JobId } from '../../../common/types/anomaly_detection_jobs';
22-
import { AnomalyTimelineService } from '../../application/services/anomaly_timeline_service';
23-
import {
24-
Filter,
25-
Query,
26-
RefreshInterval,
27-
TimeRange,
28-
} from '../../../../../../src/plugins/data/common';
29-
import { SwimlaneType } from '../../application/explorer/explorer_constants';
3015
import { MlDependencies } from '../../application/app';
31-
import { AppStateSelectedCells } from '../../application/explorer/explorer_utils';
32-
import { SWIM_LANE_SELECTION_TRIGGER } from '../../ui_actions/triggers';
33-
import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../..';
16+
import { SWIM_LANE_SELECTION_TRIGGER } from '../../ui_actions';
17+
import {
18+
ANOMALY_SWIMLANE_EMBEDDABLE_TYPE,
19+
AnomalySwimlaneEmbeddableInput,
20+
AnomalySwimlaneEmbeddableOutput,
21+
AnomalySwimlaneServices,
22+
} from '..';
3423

3524
export const getDefaultPanelTitle = (jobIds: JobId[]) =>
3625
i18n.translate('xpack.ml.swimlaneEmbeddable.title', {
3726
defaultMessage: 'ML anomaly swim lane for {jobIds}',
3827
values: { jobIds: jobIds.join(', ') },
3928
});
4029

41-
export interface AnomalySwimlaneEmbeddableCustomInput {
42-
jobIds: JobId[];
43-
swimlaneType: SwimlaneType;
44-
viewBy?: string;
45-
perPage?: number;
46-
47-
// Embeddable inputs which are not included in the default interface
48-
filters: Filter[];
49-
query: Query;
50-
refreshConfig: RefreshInterval;
51-
timeRange: TimeRange;
52-
}
53-
54-
export interface EditSwimlanePanelContext {
55-
embeddable: IEmbeddable<AnomalySwimlaneEmbeddableInput, AnomalySwimlaneEmbeddableOutput>;
56-
}
57-
58-
export interface SwimLaneDrilldownContext extends EditSwimlanePanelContext {
59-
/**
60-
* Optional data provided by swim lane selection
61-
*/
62-
data?: AppStateSelectedCells;
63-
}
64-
65-
export type AnomalySwimlaneEmbeddableInput = EmbeddableInput & AnomalySwimlaneEmbeddableCustomInput;
66-
67-
export type AnomalySwimlaneEmbeddableOutput = EmbeddableOutput &
68-
AnomalySwimlaneEmbeddableCustomOutput;
69-
70-
export interface AnomalySwimlaneEmbeddableCustomOutput {
71-
perPage?: number;
72-
fromPage?: number;
73-
interval?: number;
74-
}
75-
76-
export interface AnomalySwimlaneServices {
77-
anomalyDetectorService: AnomalyDetectorService;
78-
anomalyTimelineService: AnomalyTimelineService;
79-
}
80-
81-
export type AnomalySwimlaneEmbeddableServices = [
82-
CoreStart,
83-
MlDependencies,
84-
AnomalySwimlaneServices
85-
];
86-
8730
export type IAnomalySwimlaneEmbeddable = typeof AnomalySwimlaneEmbeddable;
8831

8932
export class AnomalySwimlaneEmbeddable extends Embeddable<

x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
import { AnomalySwimlaneEmbeddableFactory } from './anomaly_swimlane_embeddable_factory';
88
import { coreMock } from '../../../../../../src/core/public/mocks';
99
import { dataPluginMock } from '../../../../../../src/plugins/data/public/mocks';
10-
import {
11-
AnomalySwimlaneEmbeddable,
12-
AnomalySwimlaneEmbeddableInput,
13-
} from './anomaly_swimlane_embeddable';
10+
import { AnomalySwimlaneEmbeddable } from './anomaly_swimlane_embeddable';
11+
import { AnomalySwimlaneEmbeddableInput } from '..';
1412

1513
jest.mock('./anomaly_swimlane_embeddable', () => ({
1614
AnomalySwimlaneEmbeddable: jest.fn(),

x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import {
1212
EmbeddableFactoryDefinition,
1313
IContainer,
1414
} from '../../../../../../src/plugins/embeddable/public';
15-
import {
16-
AnomalySwimlaneEmbeddableInput,
17-
AnomalySwimlaneEmbeddableServices,
18-
} from './anomaly_swimlane_embeddable';
1915
import { HttpService } from '../../application/services/http_service';
2016
import { MlPluginStart, MlStartDependencies } from '../../plugin';
2117
import { MlDependencies } from '../../application/app';
22-
import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../..';
18+
import {
19+
ANOMALY_SWIMLANE_EMBEDDABLE_TYPE,
20+
AnomalySwimlaneEmbeddableInput,
21+
AnomalySwimlaneEmbeddableServices,
22+
} from '..';
2323

2424
export class AnomalySwimlaneEmbeddableFactory
2525
implements EmbeddableFactoryDefinition<AnomalySwimlaneEmbeddableInput> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { FormattedMessage } from '@kbn/i18n/react';
2323
import { i18n } from '@kbn/i18n';
2424
import { SWIMLANE_TYPE, SwimlaneType } from '../../application/explorer/explorer_constants';
25-
import { AnomalySwimlaneEmbeddableInput } from './anomaly_swimlane_embeddable';
25+
import { AnomalySwimlaneEmbeddableInput } from '..';
2626

2727
export interface AnomalySwimlaneInitializerProps {
2828
defaultTitle: string;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ import { AnomalySwimlaneInitializer } from './anomaly_swimlane_initializer';
1616
import { JobSelectorFlyout } from '../../application/components/job_selector/job_selector_flyout';
1717
import { AnomalyDetectorService } from '../../application/services/anomaly_detector_service';
1818
import { getInitialGroupsMap } from '../../application/components/job_selector/job_selector';
19-
import {
20-
AnomalySwimlaneEmbeddableInput,
21-
getDefaultPanelTitle,
22-
} from './anomaly_swimlane_embeddable';
19+
import { getDefaultPanelTitle } from './anomaly_swimlane_embeddable';
2320
import { getMlGlobalServices } from '../../application/app';
2421
import { HttpService } from '../../application/services/http_service';
22+
import { AnomalySwimlaneEmbeddableInput } from '..';
2523

2624
export async function resolveAnomalySwimlaneUserInput(
2725
coreStart: CoreStart,

x-pack/plugins/ml/public/embeddables/anomaly_swimlane/embeddable_swim_lane_container.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import {
1212
} from './embeddable_swim_lane_container';
1313
import { BehaviorSubject, Observable } from 'rxjs';
1414
import { I18nProvider } from '@kbn/i18n/react';
15-
import {
16-
AnomalySwimlaneEmbeddable,
17-
AnomalySwimlaneEmbeddableInput,
18-
AnomalySwimlaneServices,
19-
} from './anomaly_swimlane_embeddable';
15+
import { AnomalySwimlaneEmbeddable } from './anomaly_swimlane_embeddable';
2016
import { CoreStart } from 'kibana/public';
2117
import { useSwimlaneInputResolver } from './swimlane_input_resolver';
2218
import { SWIMLANE_TYPE } from '../../application/explorer/explorer_constants';
@@ -25,6 +21,7 @@ import { MlDependencies } from '../../application/app';
2521
import { uiActionsPluginMock } from 'src/plugins/ui_actions/public/mocks';
2622
import { TriggerContract } from 'src/plugins/ui_actions/public/triggers';
2723
import { TriggerId } from 'src/plugins/ui_actions/public';
24+
import { AnomalySwimlaneEmbeddableInput, AnomalySwimlaneServices } from '..';
2825

2926
jest.mock('./swimlane_input_resolver', () => ({
3027
useSwimlaneInputResolver: jest.fn(() => {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import { Observable } from 'rxjs';
1010

1111
import { CoreStart } from 'kibana/public';
1212
import { FormattedMessage } from '@kbn/i18n/react';
13-
import {
14-
IAnomalySwimlaneEmbeddable,
15-
AnomalySwimlaneEmbeddableInput,
16-
AnomalySwimlaneEmbeddableOutput,
17-
AnomalySwimlaneServices,
18-
} from './anomaly_swimlane_embeddable';
13+
import { IAnomalySwimlaneEmbeddable } from './anomaly_swimlane_embeddable';
1914
import { useSwimlaneInputResolver } from './swimlane_input_resolver';
2015
import { SwimlaneType } from '../../application/explorer/explorer_constants';
2116
import {
@@ -24,7 +19,12 @@ import {
2419
} from '../../application/explorer/swimlane_container';
2520
import { AppStateSelectedCells } from '../../application/explorer/explorer_utils';
2621
import { MlDependencies } from '../../application/app';
27-
import { SWIM_LANE_SELECTION_TRIGGER } from '../../ui_actions/triggers';
22+
import { SWIM_LANE_SELECTION_TRIGGER } from '../../ui_actions';
23+
import {
24+
AnomalySwimlaneEmbeddableInput,
25+
AnomalySwimlaneEmbeddableOutput,
26+
AnomalySwimlaneServices,
27+
} from '..';
2828

2929
export interface ExplorerSwimlaneContainerProps {
3030
id: string;

x-pack/plugins/ml/public/embeddables/anomaly_swimlane/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
*/
66

77
export { AnomalySwimlaneEmbeddableFactory } from './anomaly_swimlane_embeddable_factory';
8-
export { SwimLaneDrilldownContext, EditSwimlanePanelContext } from './anomaly_swimlane_embeddable';

x-pack/plugins/ml/public/embeddables/anomaly_swimlane/swimlane_input_resolver.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import { renderHook, act } from '@testing-library/react-hooks';
88
import { processFilters, useSwimlaneInputResolver } from './swimlane_input_resolver';
99
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
1010
import { SWIMLANE_TYPE } from '../../application/explorer/explorer_constants';
11-
import {
12-
AnomalySwimlaneEmbeddableInput,
13-
AnomalySwimlaneServices,
14-
} from './anomaly_swimlane_embeddable';
1511
import { CoreStart, IUiSettingsClient } from 'kibana/public';
1612
import { MlStartDependencies } from '../../plugin';
13+
import { AnomalySwimlaneEmbeddableInput, AnomalySwimlaneServices } from '..';
1714

1815
describe('useSwimlaneInputResolver', () => {
1916
let embeddableInput: BehaviorSubject<Partial<AnomalySwimlaneEmbeddableInput>>;

0 commit comments

Comments
 (0)