From d5c3014a09c5460a6e0dc566b7789a9a76ef7915 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 23 Sep 2024 15:46:50 +0200 Subject: [PATCH 1/4] @kbn/ml-embeddables --- package.json | 1 + tsconfig.base.json | 2 ++ x-pack/packages/ml/embeddables/README.md | 3 +++ .../ml}/embeddables/constants.ts | 0 x-pack/packages/ml/embeddables/index.ts | 12 ++++++++++++ x-pack/packages/ml/embeddables/jest.config.js | 12 ++++++++++++ x-pack/packages/ml/embeddables/kibana.jsonc | 5 +++++ x-pack/packages/ml/embeddables/package.json | 6 ++++++ x-pack/packages/ml/embeddables/tsconfig.json | 17 +++++++++++++++++ .../applications/shared/kibana/kibana_logic.ts | 2 +- .../plugins/enterprise_search/public/plugin.ts | 2 +- .../fields/create_field/create_field.tsx | 2 +- .../semantic_text/use_semantic_text.ts | 2 +- .../application/hooks/use_index_errors.ts | 2 +- x-pack/plugins/index_management/public/types.ts | 2 +- .../application/explorer/anomaly_timeline.tsx | 5 ++++- .../timeseriesexplorer_controls.tsx | 2 +- ...anomaly_swimlane_embeddable_factory.test.tsx | 2 +- .../anomaly_swimlane_embeddable_factory.tsx | 2 +- .../embeddables/anomaly_swimlane/types.ts | 2 +- x-pack/plugins/ml/public/embeddables/index.ts | 6 +++--- x-pack/plugins/ml/public/index.ts | 1 - .../shared_components/anomaly_swim_lane.tsx | 2 +- .../ml/public/ui_actions/create_swim_lane.tsx | 2 +- .../anomalies_swimlane_visualisation.tsx | 2 +- yarn.lock | 4 ++++ 26 files changed, 82 insertions(+), 18 deletions(-) create mode 100644 x-pack/packages/ml/embeddables/README.md rename x-pack/{plugins/ml/public => packages/ml}/embeddables/constants.ts (100%) create mode 100644 x-pack/packages/ml/embeddables/index.ts create mode 100644 x-pack/packages/ml/embeddables/jest.config.js create mode 100644 x-pack/packages/ml/embeddables/kibana.jsonc create mode 100644 x-pack/packages/ml/embeddables/package.json create mode 100644 x-pack/packages/ml/embeddables/tsconfig.json diff --git a/package.json b/package.json index ccf36e1a7d53b..9d15c9a94896a 100644 --- a/package.json +++ b/package.json @@ -644,6 +644,7 @@ "@kbn/ml-data-view-utils": "link:x-pack/packages/ml/data_view_utils", "@kbn/ml-date-picker": "link:x-pack/packages/ml/date_picker", "@kbn/ml-date-utils": "link:x-pack/packages/ml/date_utils", + "@kbn/ml-embeddables": "link:x-pack/packages/ml/embeddables", "@kbn/ml-error-utils": "link:x-pack/packages/ml/error_utils", "@kbn/ml-field-stats-flyout": "link:x-pack/packages/ml/field_stats_flyout", "@kbn/ml-in-memory-table": "link:x-pack/packages/ml/in_memory_table", diff --git a/tsconfig.base.json b/tsconfig.base.json index 7a66911a4bee5..2ce958153c244 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1212,6 +1212,8 @@ "@kbn/ml-date-picker/*": ["x-pack/packages/ml/date_picker/*"], "@kbn/ml-date-utils": ["x-pack/packages/ml/date_utils"], "@kbn/ml-date-utils/*": ["x-pack/packages/ml/date_utils/*"], + "@kbn/ml-embeddables": ["x-pack/packages/ml/embeddables"], + "@kbn/ml-embeddables/*": ["x-pack/packages/ml/embeddables/*"], "@kbn/ml-error-utils": ["x-pack/packages/ml/error_utils"], "@kbn/ml-error-utils/*": ["x-pack/packages/ml/error_utils/*"], "@kbn/ml-field-stats-flyout": ["x-pack/packages/ml/field_stats_flyout"], diff --git a/x-pack/packages/ml/embeddables/README.md b/x-pack/packages/ml/embeddables/README.md new file mode 100644 index 0000000000000..6e3f090398a91 --- /dev/null +++ b/x-pack/packages/ml/embeddables/README.md @@ -0,0 +1,3 @@ +# @kbn/ml-embeddables + +Empty package generated by @kbn/generate diff --git a/x-pack/plugins/ml/public/embeddables/constants.ts b/x-pack/packages/ml/embeddables/constants.ts similarity index 100% rename from x-pack/plugins/ml/public/embeddables/constants.ts rename to x-pack/packages/ml/embeddables/constants.ts diff --git a/x-pack/packages/ml/embeddables/index.ts b/x-pack/packages/ml/embeddables/index.ts new file mode 100644 index 0000000000000..deb276ee09af3 --- /dev/null +++ b/x-pack/packages/ml/embeddables/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { + ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE, + ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, + ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE, +} from './constants'; diff --git a/x-pack/packages/ml/embeddables/jest.config.js b/x-pack/packages/ml/embeddables/jest.config.js new file mode 100644 index 0000000000000..3dd0870b44809 --- /dev/null +++ b/x-pack/packages/ml/embeddables/jest.config.js @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../../../..', + roots: ['/x-pack/packages/ml/embeddables'], +}; diff --git a/x-pack/packages/ml/embeddables/kibana.jsonc b/x-pack/packages/ml/embeddables/kibana.jsonc new file mode 100644 index 0000000000000..2aa9f0f436d80 --- /dev/null +++ b/x-pack/packages/ml/embeddables/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/ml-embeddables", + "owner": "@elastic/ml-ui" +} diff --git a/x-pack/packages/ml/embeddables/package.json b/x-pack/packages/ml/embeddables/package.json new file mode 100644 index 0000000000000..b4a2d17c63595 --- /dev/null +++ b/x-pack/packages/ml/embeddables/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/ml-embeddables", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" +} \ No newline at end of file diff --git a/x-pack/packages/ml/embeddables/tsconfig.json b/x-pack/packages/ml/embeddables/tsconfig.json new file mode 100644 index 0000000000000..0d78dace105e1 --- /dev/null +++ b/x-pack/packages/ml/embeddables/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node" + ] + }, + "include": [ + "**/*.ts", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [] +} diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts b/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts index 939d92745006c..d555ee766c790 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts @@ -26,7 +26,7 @@ import { DataPublicPluginStart } from '@kbn/data-plugin/public'; import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; import { IndexMappingProps } from '@kbn/index-management-shared-types'; import { LensPublicStart } from '@kbn/lens-plugin/public'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import { ELASTICSEARCH_URL_PLACEHOLDER } from '@kbn/search-api-panels/constants'; import { ConnectorDefinition } from '@kbn/search-connectors-plugin/public'; import type { SearchHomepagePluginStart } from '@kbn/search-homepage/public'; diff --git a/x-pack/plugins/enterprise_search/public/plugin.ts b/x-pack/plugins/enterprise_search/public/plugin.ts index 73dbe6885fdcc..02105b4d465da 100644 --- a/x-pack/plugins/enterprise_search/public/plugin.ts +++ b/x-pack/plugins/enterprise_search/public/plugin.ts @@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n'; import type { IndexManagementPluginStart } from '@kbn/index-management-shared-types'; import { LensPublicStart } from '@kbn/lens-plugin/public'; import { LicensingPluginStart } from '@kbn/licensing-plugin/public'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public'; import { ELASTICSEARCH_URL_PLACEHOLDER } from '@kbn/search-api-panels/constants'; import { SearchConnectorsPluginStart } from '@kbn/search-connectors-plugin/public'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx index 1daa437356546..9e73942ee79ef 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx @@ -15,7 +15,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { TrainedModelStat } from '@kbn/ml-plugin/common/types/trained_models'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import classNames from 'classnames'; import React, { useEffect } from 'react'; import { EUI_SIZE, TYPE_DEFINITION } from '../../../../constants'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/semantic_text/use_semantic_text.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/semantic_text/use_semantic_text.ts index 42d220ba4724b..c987f1fd5eae8 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/semantic_text/use_semantic_text.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/semantic_text/use_semantic_text.ts @@ -6,7 +6,7 @@ */ import { useCallback } from 'react'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import React, { useEffect } from 'react'; import { InferenceTaskType } from '@elastic/elasticsearch/lib/api/types'; import { ElserModels } from '@kbn/ml-trained-models-utils'; diff --git a/x-pack/plugins/index_management/public/application/hooks/use_index_errors.ts b/x-pack/plugins/index_management/public/application/hooks/use_index_errors.ts index 82f1545e3a98a..df566c6e8df4d 100644 --- a/x-pack/plugins/index_management/public/application/hooks/use_index_errors.ts +++ b/x-pack/plugins/index_management/public/application/hooks/use_index_errors.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import { Index } from '@kbn/index-management-shared-types'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import { useState, useEffect } from 'react'; import { normalize } from '../components/mappings_editor/lib'; import { isLocalModel } from '../components/mappings_editor/lib/utils'; diff --git a/x-pack/plugins/index_management/public/types.ts b/x-pack/plugins/index_management/public/types.ts index 35e6fc6b9dfd5..d40b65d6fe328 100644 --- a/x-pack/plugins/index_management/public/types.ts +++ b/x-pack/plugins/index_management/public/types.ts @@ -14,7 +14,7 @@ import { import { CloudSetup } from '@kbn/cloud-plugin/public'; import { ConsolePluginStart } from '@kbn/console-plugin/public'; import { ManagementSetup } from '@kbn/management-plugin/public'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; import { LicensingPluginStart } from '@kbn/licensing-plugin/public'; diff --git a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx index ae12b8b1fa4ac..8109589054d5d 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx +++ b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline.tsx @@ -8,6 +8,7 @@ import type { FC } from 'react'; import React, { useCallback, useMemo, useState } from 'react'; import { isEqual } from 'lodash'; + import type { EuiContextMenuPanelDescriptor, EuiContextMenuPanelItemDescriptor, @@ -26,6 +27,7 @@ import { EuiTitle, htmlIdGenerator, } from '@elastic/eui'; + import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import useDebounce from 'react-use/lib/useDebounce'; @@ -41,11 +43,12 @@ import { withSuspense, } from '@kbn/presentation-util-plugin/public'; import { useTimeBuckets } from '@kbn/ml-time-buckets'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; + import type { JobId } from '../../../common/types/anomaly_detection_jobs'; import { getDefaultSwimlanePanelTitle } from '../../embeddables/anomaly_swimlane/anomaly_swimlane_embeddable'; import { useCasesModal } from '../contexts/kibana/use_cases_modal'; import type { AnomalySwimLaneEmbeddableState } from '../..'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../..'; import type { SwimlaneType } from './explorer_constants'; import { OVERALL_LABEL, SWIMLANE_TYPE, VIEW_BY_JOB_LABEL } from './explorer_constants'; import { useMlKibana } from '../contexts/kibana'; diff --git a/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx b/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx index 898ef65812d29..a960dae56d52e 100644 --- a/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx +++ b/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx @@ -25,12 +25,12 @@ import { withSuspense, } from '@kbn/presentation-util-plugin/public'; import { useTimeRangeUpdates } from '@kbn/ml-date-picker'; +import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { JobId } from '../../../../../common/types/anomaly_detection_jobs/job'; import { useMlKibana } from '../../../contexts/kibana'; import { useCasesModal } from '../../../contexts/kibana/use_cases_modal'; import { getDefaultSingleMetricViewerPanelTitle } from '../../../../embeddables/single_metric_viewer/get_default_panel_title'; import type { MlEntity } from '../../../../embeddables'; -import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '../../../../embeddables/constants'; import type { SingleMetricViewerEmbeddableState } from '../../../../embeddables/types'; interface Props { diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.test.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.test.tsx index 61a2fadeb6df8..8981285249f20 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.test.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.test.tsx @@ -13,7 +13,7 @@ import { setStubKibanaServices } from '@kbn/presentation-panel-plugin/public/moc import { render, waitFor, screen } from '@testing-library/react'; import React from 'react'; import { of } from 'rxjs'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../constants'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { getAnomalySwimLaneEmbeddableFactory } from './anomaly_swimlane_embeddable_factory'; import type { AnomalySwimLaneEmbeddableApi, AnomalySwimLaneEmbeddableState } from './types'; import { embeddablePluginMock } from '@kbn/embeddable-plugin/public/mocks'; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.tsx index 34390075f927b..ff2ecbd41e593 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable_factory.tsx @@ -27,8 +27,8 @@ import React, { useCallback, useState } from 'react'; import useUnmount from 'react-use/lib/useUnmount'; import type { Observable } from 'rxjs'; import { BehaviorSubject, combineLatest, map, of, Subscription } from 'rxjs'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { AnomalySwimlaneEmbeddableServices } from '..'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '..'; import type { MlDependencies } from '../../application/app'; import { Y_AXIS_LABEL_WIDTH } from '../../application/explorer/constants'; import type { AppStateSelectedCells } from '../../application/explorer/explorer_utils'; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/types.ts b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/types.ts index cde7ff1350687..3910e92a6ac51 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/types.ts +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/types.ts @@ -15,11 +15,11 @@ import type { SerializedTitles, } from '@kbn/presentation-publishing'; import { apiIsOfType } from '@kbn/presentation-publishing'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { SwimlaneType } from '../../application/explorer/explorer_constants'; import type { JobId } from '../../../common/types/anomaly_detection_jobs'; import type { AppStateSelectedCells } from '../../application/explorer/explorer_utils'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../constants'; import type { AnomalySwimlaneEmbeddableCustomInput, AnomalySwimlaneEmbeddableUserInput, diff --git a/x-pack/plugins/ml/public/embeddables/index.ts b/x-pack/plugins/ml/public/embeddables/index.ts index 9145bbddf5818..5ec002571a92d 100644 --- a/x-pack/plugins/ml/public/embeddables/index.ts +++ b/x-pack/plugins/ml/public/embeddables/index.ts @@ -6,14 +6,14 @@ */ import type { EmbeddableSetup } from '@kbn/embeddable-plugin/public'; -import type { MlCoreSetup } from '../plugin'; import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE, ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE, -} from './constants'; +} from '@kbn/ml-embeddables'; + +import type { MlCoreSetup } from '../plugin'; -export * from './constants'; export * from './types'; export function registerEmbeddables(embeddable: EmbeddableSetup, core: MlCoreSetup) { diff --git a/x-pack/plugins/ml/public/index.ts b/x-pack/plugins/ml/public/index.ts index d18b4f60a085f..97d97fa54917d 100755 --- a/x-pack/plugins/ml/public/index.ts +++ b/x-pack/plugins/ml/public/index.ts @@ -35,7 +35,6 @@ export type { DataRecognizerConfigResponse } from '../common/types/modules'; export type { AnomalySwimLaneEmbeddableApi, AnomalySwimLaneEmbeddableState } from './embeddables'; -export { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from './embeddables/constants'; export { CONTROLLED_BY_SWIM_LANE_FILTER } from './ui_actions/constants'; export type { MlLocator } from './locator'; diff --git a/x-pack/plugins/ml/public/shared_components/anomaly_swim_lane.tsx b/x-pack/plugins/ml/public/shared_components/anomaly_swim_lane.tsx index 5c995d0ddcb65..9cf2bc895a6c8 100644 --- a/x-pack/plugins/ml/public/shared_components/anomaly_swim_lane.tsx +++ b/x-pack/plugins/ml/public/shared_components/anomaly_swim_lane.tsx @@ -12,12 +12,12 @@ import type { PublishesWritableUnifiedSearch } from '@kbn/presentation-publishin import type { HasSerializedChildState } from '@kbn/presentation-containers'; import React, { useEffect, useMemo, useRef, type FC } from 'react'; import { BehaviorSubject } from 'rxjs'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { AnomalySwimLaneEmbeddableApi, AnomalySwimlaneEmbeddableCustomInput, AnomalySwimLaneEmbeddableState, } from '../embeddables'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../embeddables'; export interface AnomalySwimLaneProps extends AnomalySwimlaneEmbeddableCustomInput { id?: string; diff --git a/x-pack/plugins/ml/public/ui_actions/create_swim_lane.tsx b/x-pack/plugins/ml/public/ui_actions/create_swim_lane.tsx index 110873bb48401..c95418568c5e7 100644 --- a/x-pack/plugins/ml/public/ui_actions/create_swim_lane.tsx +++ b/x-pack/plugins/ml/public/ui_actions/create_swim_lane.tsx @@ -10,8 +10,8 @@ import type { PresentationContainer } from '@kbn/presentation-containers'; import type { EmbeddableApiContext } from '@kbn/presentation-publishing'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { ML_APP_NAME, PLUGIN_ICON, PLUGIN_ID } from '../../common/constants/app'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '../embeddables'; import type { AnomalySwimLaneEmbeddableApi } from '../embeddables/anomaly_swimlane/types'; import type { MlCoreSetup } from '../plugin'; diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/anomalies_swimlane_visualisation.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/anomalies_swimlane_visualisation.tsx index 92499cf3af44e..9af55ee3633bf 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/anomalies_swimlane_visualisation.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/anomalies_swimlane_visualisation.tsx @@ -7,7 +7,7 @@ import moment from 'moment'; import React, { useMemo } from 'react'; -import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-plugin/public'; +import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { MissingEmbeddableFactoryCallout } from '../../../../../components/missing_embeddable_factory_callout'; import { partitionField } from '../../../../../../common/infra_ml'; import { TimeRange } from '../../../../../../common/time/time_range'; diff --git a/yarn.lock b/yarn.lock index 5498cb13a015d..5bc37ad95eb38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5695,6 +5695,10 @@ version "0.0.0" uid "" +"@kbn/ml-embeddables@link:x-pack/packages/ml/embeddables": + version "0.0.0" + uid "" + "@kbn/ml-error-utils@link:x-pack/packages/ml/error_utils": version "0.0.0" uid "" From 4f93f54e325023e97e92f140bf2589bbf5820ec4 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 23 Sep 2024 15:58:23 +0200 Subject: [PATCH 2/4] move some consts to @kbn/ml-ui-actions --- x-pack/packages/ml/ui_actions/index.ts | 2 ++ x-pack/packages/ml/ui_actions/src/ml/ui_actions.ts | 3 +++ .../public/application/explorer/anomaly_context_menu.tsx | 2 +- .../anomaly_charts/anomaly_charts_embeddable_factory.tsx | 2 +- .../initialize_swim_lane_data_fetcher.ts | 2 +- .../ml/public/embeddables/common/process_filters.test.ts | 2 +- x-pack/plugins/ml/public/index.ts | 2 -- .../ml/public/ui_actions/apply_entity_filters_action.tsx | 4 ++-- .../ui_actions/apply_influencer_filters_action.tsx | 2 +- x-pack/plugins/ml/public/ui_actions/constants.ts | 9 --------- .../ml/public/ui_actions/create_anomaly_chart.tsx | 2 +- .../ui_actions/open_in_anomaly_explorer_action.tsx | 2 +- .../pages/logs/log_entry_rate/use_dataset_filtering.ts | 2 +- 13 files changed, 15 insertions(+), 21 deletions(-) delete mode 100644 x-pack/plugins/ml/public/ui_actions/constants.ts diff --git a/x-pack/packages/ml/ui_actions/index.ts b/x-pack/packages/ml/ui_actions/index.ts index 7a82ca6d68d9c..784203c52c6eb 100644 --- a/x-pack/packages/ml/ui_actions/index.ts +++ b/x-pack/packages/ml/ui_actions/index.ts @@ -6,6 +6,8 @@ */ export { + CONTROLLED_BY_SWIM_LANE_FILTER, + CONTROLLED_BY_ANOMALY_CHARTS_FILTER, CREATE_PATTERN_ANALYSIS_TO_ML_AD_JOB_ACTION, CREATE_PATTERN_ANALYSIS_TO_ML_AD_JOB_TRIGGER, type CreateCategorizationADJobContext, diff --git a/x-pack/packages/ml/ui_actions/src/ml/ui_actions.ts b/x-pack/packages/ml/ui_actions/src/ml/ui_actions.ts index cf36e3ff01ce6..adfa387ef1322 100644 --- a/x-pack/packages/ml/ui_actions/src/ml/ui_actions.ts +++ b/x-pack/packages/ml/ui_actions/src/ml/ui_actions.ts @@ -20,3 +20,6 @@ export const CREATE_PATTERN_ANALYSIS_TO_ML_AD_JOB_ACTION = 'createMLADCategoriza export const CREATE_PATTERN_ANALYSIS_TO_ML_AD_JOB_TRIGGER = 'CREATE_PATTERN_ANALYSIS_TO_ML_AD_JOB_TRIGGER'; + +export const CONTROLLED_BY_SWIM_LANE_FILTER = 'anomaly-swim-lane'; +export const CONTROLLED_BY_ANOMALY_CHARTS_FILTER = 'anomaly-charts'; diff --git a/x-pack/plugins/ml/public/application/explorer/anomaly_context_menu.tsx b/x-pack/plugins/ml/public/application/explorer/anomaly_context_menu.tsx index b27f8efe4fcc6..23126e28ea590 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomaly_context_menu.tsx +++ b/x-pack/plugins/ml/public/application/explorer/anomaly_context_menu.tsx @@ -39,6 +39,7 @@ import { withSuspense, } from '@kbn/presentation-util-plugin/public'; import type { TimeRangeBounds } from '@kbn/ml-time-buckets'; +import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { useTableSeverity } from '../components/controls/select_severity'; import type { JobId } from '../../../common/types/anomaly_detection_jobs'; import { MAX_ANOMALY_CHARTS_ALLOWED } from '../../embeddables/anomaly_charts/anomaly_charts_initializer'; @@ -47,7 +48,6 @@ import { escapeKueryForEmbeddableFieldValuePair } from '../util/string_utils'; import { useCasesModal } from '../contexts/kibana/use_cases_modal'; import { DEFAULT_MAX_SERIES_TO_PLOT } from '../services/anomaly_explorer_charts_service'; import type { AnomalyChartsEmbeddableState } from '../../embeddables'; -import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '../../embeddables'; import { useMlKibana } from '../contexts/kibana'; import type { AppStateSelectedCells, ExplorerJob } from './explorer_utils'; import { getSelectionInfluencers, getSelectionTimeRange } from './explorer_utils'; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_embeddable_factory.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_embeddable_factory.tsx index 3f5afc4065e1f..65099d81b9498 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_embeddable_factory.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_embeddable_factory.tsx @@ -25,9 +25,9 @@ import type { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import type { TimeRange } from '@kbn/es-query'; import { css } from '@emotion/react'; import { useEuiTheme } from '@elastic/eui'; +import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { MlPluginStart, MlStartDependencies } from '../../plugin'; import type { AnomalyChartsEmbeddableApi, AnomalyChartsEmbeddableState } from '..'; -import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '..'; import { useReactEmbeddableExecutionContext } from '../common/use_embeddable_execution_context'; import { initializeAnomalyChartsControls } from './initialize_anomaly_charts_controls'; import { LazyAnomalyChartsContainer } from './lazy_anomaly_charts_container'; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/initialize_swim_lane_data_fetcher.ts b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/initialize_swim_lane_data_fetcher.ts index 268a17fca4a81..004ca29205285 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/initialize_swim_lane_data_fetcher.ts +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/initialize_swim_lane_data_fetcher.ts @@ -24,13 +24,13 @@ import { switchMap, tap, } from 'rxjs'; +import { CONTROLLED_BY_SWIM_LANE_FILTER } from '@kbn/ml-ui-actions'; import { ANOMALY_SWIM_LANE_HARD_LIMIT, SWIMLANE_TYPE, } from '../../application/explorer/explorer_constants'; import type { OverallSwimlaneData } from '../../application/explorer/explorer_utils'; import { isViewBySwimLaneData } from '../../application/explorer/swimlane_container'; -import { CONTROLLED_BY_SWIM_LANE_FILTER } from '../../ui_actions/constants'; import { getJobsObservable } from '../common/get_jobs_observable'; import { processFilters } from '../common/process_filters'; import type { AnomalySwimlaneServices } from '../types'; diff --git a/x-pack/plugins/ml/public/embeddables/common/process_filters.test.ts b/x-pack/plugins/ml/public/embeddables/common/process_filters.test.ts index 262b744786d97..1f5589a9ae66b 100644 --- a/x-pack/plugins/ml/public/embeddables/common/process_filters.test.ts +++ b/x-pack/plugins/ml/public/embeddables/common/process_filters.test.ts @@ -6,7 +6,7 @@ */ import { processFilters } from './process_filters'; -import { CONTROLLED_BY_SWIM_LANE_FILTER } from '../..'; +import { CONTROLLED_BY_SWIM_LANE_FILTER } from '@kbn/ml-ui-actions'; describe('processFilters', () => { test('should format kql embeddable input to es query', () => { diff --git a/x-pack/plugins/ml/public/index.ts b/x-pack/plugins/ml/public/index.ts index 97d97fa54917d..92d0bb1ca2107 100755 --- a/x-pack/plugins/ml/public/index.ts +++ b/x-pack/plugins/ml/public/index.ts @@ -35,8 +35,6 @@ export type { DataRecognizerConfigResponse } from '../common/types/modules'; export type { AnomalySwimLaneEmbeddableApi, AnomalySwimLaneEmbeddableState } from './embeddables'; -export { CONTROLLED_BY_SWIM_LANE_FILTER } from './ui_actions/constants'; - export type { MlLocator } from './locator'; export { useMlHref, ML_PAGES, MlLocatorDefinition } from './locator'; diff --git a/x-pack/plugins/ml/public/ui_actions/apply_entity_filters_action.tsx b/x-pack/plugins/ml/public/ui_actions/apply_entity_filters_action.tsx index 8bd4c093cd4b9..2ae752541d2dc 100644 --- a/x-pack/plugins/ml/public/ui_actions/apply_entity_filters_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/apply_entity_filters_action.tsx @@ -10,10 +10,10 @@ import { FilterStateStore } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import { ML_ENTITY_FIELD_OPERATIONS } from '@kbn/ml-anomaly-utils'; +import { CONTROLLED_BY_ANOMALY_CHARTS_FILTER } from '@kbn/ml-ui-actions'; +import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { MlCoreSetup } from '../plugin'; import type { AnomalyChartsFieldSelectionContext } from '../embeddables'; -import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '../embeddables'; -import { CONTROLLED_BY_ANOMALY_CHARTS_FILTER } from './constants'; export const APPLY_ENTITY_FIELD_FILTERS_ACTION = 'applyEntityFieldFiltersAction'; diff --git a/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx b/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx index b2d785bf6dab3..d07310be4a53b 100644 --- a/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx @@ -12,11 +12,11 @@ import { i18n } from '@kbn/i18n'; import type { EmbeddableApiContext } from '@kbn/presentation-publishing'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import { firstValueFrom } from 'rxjs'; +import { CONTROLLED_BY_SWIM_LANE_FILTER } from '@kbn/ml-ui-actions'; import { isAnomalySwimlaneSelectionTriggerContext } from './triggers'; import { SWIMLANE_TYPE, VIEW_BY_JOB_LABEL } from '../application/explorer/explorer_constants'; import type { SwimLaneDrilldownContext } from '../embeddables'; import type { MlCoreSetup } from '../plugin'; -import { CONTROLLED_BY_SWIM_LANE_FILTER } from './constants'; export const APPLY_INFLUENCER_FILTERS_ACTION = 'applyInfluencerFiltersAction'; diff --git a/x-pack/plugins/ml/public/ui_actions/constants.ts b/x-pack/plugins/ml/public/ui_actions/constants.ts deleted file mode 100644 index 459f342dc4527..0000000000000 --- a/x-pack/plugins/ml/public/ui_actions/constants.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export const CONTROLLED_BY_SWIM_LANE_FILTER = 'anomaly-swim-lane'; -export const CONTROLLED_BY_ANOMALY_CHARTS_FILTER = 'anomaly-charts'; diff --git a/x-pack/plugins/ml/public/ui_actions/create_anomaly_chart.tsx b/x-pack/plugins/ml/public/ui_actions/create_anomaly_chart.tsx index a4d9f7e45b779..f8b5058aa55ec 100644 --- a/x-pack/plugins/ml/public/ui_actions/create_anomaly_chart.tsx +++ b/x-pack/plugins/ml/public/ui_actions/create_anomaly_chart.tsx @@ -10,9 +10,9 @@ import type { PresentationContainer } from '@kbn/presentation-containers'; import type { EmbeddableApiContext } from '@kbn/presentation-publishing'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; +import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { ML_APP_NAME, PLUGIN_ICON, PLUGIN_ID } from '../../common/constants/app'; import type { AnomalyChartsEmbeddableApi } from '../embeddables'; -import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '../embeddables'; import type { MlCoreSetup } from '../plugin'; export const EDIT_ANOMALY_CHARTS_PANEL_ACTION = 'editAnomalyChartsPanelAction'; diff --git a/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx b/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx index 98a44c042db58..195309b4e0c5f 100644 --- a/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx @@ -13,11 +13,11 @@ import type { EmbeddableApiContext } from '@kbn/presentation-publishing'; import { apiIsOfType } from '@kbn/presentation-publishing'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import type { SerializableRecord } from '@kbn/utility-types'; +import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { ML_APP_LOCATOR } from '../../common/constants/locator'; import type { ExplorerAppState } from '../../common/types/locator'; import type { AppStateSelectedCells } from '../application/explorer/explorer_utils'; import type { AnomalyChartsApi, AnomalyChartsEmbeddableApi } from '../embeddables'; -import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '../embeddables'; import type { AnomalySwimLaneEmbeddableApi } from '../embeddables/anomaly_swimlane/types'; import { isSwimLaneEmbeddableContext } from '../embeddables/anomaly_swimlane/types'; import type { MlCoreSetup } from '../plugin'; diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/use_dataset_filtering.ts b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/use_dataset_filtering.ts index 6f19fb1c0549c..8b52281240b7c 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/use_dataset_filtering.ts +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/use_dataset_filtering.ts @@ -7,7 +7,7 @@ import { Filter } from '@kbn/es-query'; import { useEffect, useReducer, useCallback } from 'react'; -import { CONTROLLED_BY_SWIM_LANE_FILTER } from '@kbn/ml-plugin/public'; +import { CONTROLLED_BY_SWIM_LANE_FILTER } from '@kbn/ml-ui-actions'; import { useKibanaContextForPlugin } from '../../../hooks/use_kibana'; interface ReducerState { From 4f8243a671a2de4f750a187dffac5826dc44fa43 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 23 Sep 2024 19:21:10 +0200 Subject: [PATCH 3/4] package @kbn/ml-locator --- .github/CODEOWNERS | 2 ++ package.json | 1 + tsconfig.base.json | 2 ++ x-pack/packages/ml/embeddables/index.ts | 3 ++ x-pack/packages/ml/embeddables/package.json | 2 +- x-pack/packages/ml/locator/README.md | 3 ++ .../ml/locator/constants.ts} | 0 .../ml}/locator/formatters/aiops.ts | 4 +-- .../locator/formatters/anomaly_detection.ts | 8 ++--- .../ml}/locator/formatters/common.ts | 2 +- .../formatters/data_frame_analytics.ts | 8 ++--- .../packages/ml/locator/formatters/index.ts | 24 +++++++++++++++ .../ml}/locator/formatters/notifications.ts | 4 +-- .../ml}/locator/formatters/settings.tsx | 4 +-- .../locator/formatters/string_utils.test.ts | 23 ++++++++++++++ .../ml/locator/formatters/string_utils.ts | 14 +++++++++ .../ml}/locator/formatters/trained_models.ts | 5 ++-- x-pack/packages/ml/locator/index.ts | 20 +++++++++++++ .../ml/locator/jest.config.js} | 9 +++--- x-pack/packages/ml/locator/kibana.jsonc | 5 ++++ .../ml}/locator/ml_locator.test.ts | 2 +- .../ml}/locator/ml_locator.ts | 4 +-- x-pack/packages/ml/locator/package.json | 6 ++++ x-pack/packages/ml/locator/tsconfig.json | 30 +++++++++++++++++++ .../ml/locator/types.ts} | 9 ++++-- .../ml}/locator/use_ml_href.ts | 12 ++++---- x-pack/plugins/ml/common/types/common.ts | 6 ---- .../ml/common/util/string_utils.test.ts | 17 +---------- x-pack/plugins/ml/common/util/string_utils.ts | 8 ----- .../ml_anomaly_alert_trigger.tsx | 4 ++- .../ml/public/alerting/register_ml_alerts.ts | 2 +- .../annotations_table/annotations_table.js | 4 +-- .../components/anomalies_table/links_menu.tsx | 5 ++-- .../anomaly_results_view_selector.tsx | 2 +- .../feedback_button/feedback_button.tsx | 4 +-- .../components/job_selector/job_selector.tsx | 2 +- .../job_selector_table/job_selector_table.js | 2 +- .../components/ml_page/side_nav.tsx | 4 +-- .../components/rule_editor/scope_section.js | 2 +- .../contexts/kibana/use_cases_modal.ts | 3 +- .../contexts/kibana/use_create_url.ts | 4 +-- .../back_to_list_panel/back_to_list_panel.tsx | 2 +- .../view_results_panel/view_results_panel.tsx | 2 +- .../expandable_section/expandable_section.tsx | 2 +- .../hooks/use_exploration_url_state.ts | 4 +-- .../components/action_map/use_map_action.tsx | 2 +- .../action_view/use_view_action.tsx | 2 +- .../analytics_list/analytics_list.tsx | 2 +- .../components/analytics_list/use_columns.tsx | 2 +- .../components/empty_prompt/empty_prompt.tsx | 2 +- .../pages/analytics_management/page.tsx | 2 +- .../pages/job_map/components/controls.tsx | 2 +- .../pages/job_map/job_map.tsx | 2 +- .../data_drift_index_patterns_editor.tsx | 2 +- .../data_drift/index_patterns_picker.tsx | 2 +- .../datavisualizer_selector.tsx | 2 +- .../file_based/file_datavisualizer.tsx | 4 +-- .../index_based/index_data_visualizer.tsx | 2 +- .../explorer/anomaly_explorer_common_state.ts | 2 +- .../anomaly_timeline_state_service.ts | 2 +- .../explorer_anomalies_container.tsx | 3 +- .../explorer/hooks/use_explorer_url_state.ts | 4 +-- .../jobs_action_menu/jobs_action_menu.tsx | 2 +- .../anomaly_detection_empty_state.tsx | 2 +- .../forecasts_table/forecasts_table.js | 2 +- .../components/jobs_list/job_id_link.tsx | 4 +-- .../new_job_button/new_job_button.js | 2 +- .../jobs/jobs_list/components/utils.js | 2 +- .../application/jobs/jobs_list/jobs.tsx | 2 +- .../common/job_creator/util/general.ts | 2 +- .../jobs/new_job/job_from_lens/utils.ts | 2 +- .../jobs/new_job/job_from_map/utils.ts | 2 +- .../job_from_pattern_analysis/utils.ts | 4 +-- .../calendars/calendars_selection.tsx | 2 +- .../jobs/new_job/pages/job_type/page.tsx | 3 +- .../jobs/new_job/recognize/page.tsx | 2 +- .../nodes_overview/nodes_list.tsx | 2 +- .../model_management/model_actions.tsx | 2 +- .../model_management/model_link.tsx | 2 +- .../model_management/models_list.tsx | 2 +- .../components/notifications_list.tsx | 2 +- .../components/analytics_panel/actions.tsx | 2 +- .../analytics_panel/analytics_panel.tsx | 2 +- .../anomaly_detection_panel/actions.tsx | 2 +- .../anomaly_detection_panel.tsx | 2 +- .../application/overview/overview_page.tsx | 2 +- .../ml/public/application/routing/router.tsx | 4 +-- .../routes/aiops/change_point_detection.tsx | 2 +- .../routes/aiops/log_categorization.tsx | 2 +- .../routes/aiops/log_rate_analysis.tsx | 2 +- .../analytics_job_creation.tsx | 2 +- .../analytics_job_exploration.tsx | 2 +- .../analytics_jobs_list.tsx | 2 +- .../data_frame_analytics/analytics_map.tsx | 2 +- .../analytics_source_selection.tsx | 2 +- .../routes/datavisualizer/data_comparison.tsx | 2 +- .../routes/datavisualizer/data_drift.tsx | 2 +- .../routes/datavisualizer/datavisualizer.tsx | 2 +- .../routes/datavisualizer/file_based.tsx | 2 +- .../routes/datavisualizer/index_based.tsx | 2 +- .../routing/routes/explorer/explorer.tsx | 2 +- .../application/routing/routes/jobs_list.tsx | 2 +- .../routing/routes/memory_usage.tsx | 3 +- .../routing/routes/new_job/from_lens.tsx | 2 +- .../routing/routes/new_job/from_map.tsx | 2 +- .../routes/new_job/from_pattern_analysis.tsx | 2 +- .../routes/new_job/index_or_search.tsx | 2 +- .../routing/routes/new_job/job_type.tsx | 2 +- .../routing/routes/new_job/new_job.tsx | 3 +- .../routing/routes/new_job/recognize.tsx | 2 +- .../routing/routes/new_job/wizard.tsx | 2 +- .../routing/routes/notifications.tsx | 2 +- .../application/routing/routes/overview.tsx | 2 +- .../routing/routes/settings/calendar_list.tsx | 2 +- .../routes/settings/calendar_new_edit.tsx | 2 +- .../routing/routes/settings/filter_list.tsx | 2 +- .../routes/settings/filter_list_new_edit.tsx | 2 +- .../routing/routes/settings/settings.tsx | 2 +- .../supplied_configurations_view.tsx | 3 +- .../timeseriesexplorer/state_manager.tsx | 2 +- .../timeseriesexplorer/timeseriesexplorer.tsx | 2 +- .../routes/trained_models/models_list.tsx | 2 +- .../application/routing/use_resolver.tsx | 2 +- .../settings/anomaly_detection_settings.tsx | 2 +- .../edit/calendar_form/calendar_form.js | 2 +- .../settings/calendars/edit/new_calendar.js | 2 +- .../settings/calendars/list/table/table.js | 2 +- .../filter_lists/edit/edit_filter_list.js | 2 +- .../settings/filter_lists/list/table.js | 2 +- .../supplied_configurations.tsx | 2 +- .../data_views_table.tsx | 2 +- .../timeseriesexplorer_no_jobs_found.tsx | 2 +- .../hooks/use_timeseriesexplorer_url_state.ts | 4 +-- .../ml/public/application/util/chart_utils.js | 2 +- .../anomaly_charts_initializer.tsx | 2 +- .../anomaly_charts_react_container.tsx | 5 ++-- .../anomaly_swimlane_initializer.tsx | 2 +- .../job_creation/common/job_details.tsx | 2 +- ...ingle_metric_viewer_embeddable_factory.tsx | 2 +- .../single_metric_viewer_initializer.tsx | 2 +- x-pack/plugins/ml/public/embeddables/types.ts | 10 +++---- x-pack/plugins/ml/public/index.ts | 3 -- x-pack/plugins/ml/public/locator/index.ts | 10 ------- .../maps/anomaly_layer_wizard_factory.tsx | 2 +- .../plugins/ml/public/maps/anomaly_source.tsx | 2 +- .../ml/public/maps/anomaly_source_factory.ts | 2 +- x-pack/plugins/ml/public/plugin.ts | 3 +- .../search_deep_links.ts | 4 +-- .../create_single_metric_viewer.tsx | 2 +- .../open_in_anomaly_explorer_action.tsx | 3 +- .../open_in_single_metric_viewer_action.tsx | 4 +-- x-pack/plugins/ml/tsconfig.json | 4 ++- .../mlexplorer_link.tsx | 4 +-- .../mlsingle_metric_link.tsx | 4 +-- .../apm_plugin/mock_apm_plugin_context.tsx | 2 +- .../apm_plugin/mock_apm_plugin_storybook.tsx | 2 +- .../public/hooks/use_ml_manage_jobs_href.ts | 4 +-- .../observability_solution/apm/tsconfig.json | 1 + .../page_results_content.tsx | 5 ++-- .../analyze_dataset_in_ml_action.tsx | 4 +-- .../sections/anomalies/log_entry_example.tsx | 4 +-- .../infra/tsconfig.json | 5 +++- .../public/hooks/use_trained_model_stats.ts | 2 +- .../public/types.ts | 2 +- .../ml/links/create_explorer_link.test.tsx | 2 +- .../ml/tables/anomalies_host_table.test.tsx | 2 +- .../tables/anomalies_network_table.test.tsx | 2 +- .../ml/tables/anomalies_user_table.test.tsx | 2 +- .../ml_popover/jobs_table/jobs_table.tsx | 6 ++-- .../common/lib/kibana/kibana_react.mock.ts | 2 +- .../components/ml_job_link/ml_job_link.tsx | 4 +-- .../entity_analytics_anomalies/index.test.tsx | 4 +-- .../entity_analytics_anomalies/index.tsx | 5 ++-- .../plugins/security_solution/tsconfig.json | 1 + yarn.lock | 4 +++ 175 files changed, 367 insertions(+), 250 deletions(-) create mode 100644 x-pack/packages/ml/locator/README.md rename x-pack/{plugins/ml/common/constants/locator.ts => packages/ml/locator/constants.ts} (100%) rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/aiops.ts (89%) rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/anomaly_detection.ts (95%) rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/common.ts (96%) rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/data_frame_analytics.ts (94%) create mode 100644 x-pack/packages/ml/locator/formatters/index.ts rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/notifications.ts (89%) rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/settings.tsx (93%) create mode 100644 x-pack/packages/ml/locator/formatters/string_utils.test.ts create mode 100644 x-pack/packages/ml/locator/formatters/string_utils.ts rename x-pack/{plugins/ml/public => packages/ml}/locator/formatters/trained_models.ts (89%) create mode 100644 x-pack/packages/ml/locator/index.ts rename x-pack/{plugins/ml/public/locator/formatters/index.ts => packages/ml/locator/jest.config.js} (65%) create mode 100644 x-pack/packages/ml/locator/kibana.jsonc rename x-pack/{plugins/ml/public => packages/ml}/locator/ml_locator.test.ts (99%) rename x-pack/{plugins/ml/public => packages/ml}/locator/ml_locator.ts (97%) create mode 100644 x-pack/packages/ml/locator/package.json create mode 100644 x-pack/packages/ml/locator/tsconfig.json rename x-pack/{plugins/ml/common/types/locator.ts => packages/ml/locator/types.ts} (98%) rename x-pack/{plugins/ml/public => packages/ml}/locator/use_ml_href.ts (70%) delete mode 100644 x-pack/plugins/ml/public/locator/index.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ac6d8a03d2d2b..ac8ff8cbfff99 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -609,6 +609,7 @@ x-pack/packages/ml/data_grid @elastic/ml-ui x-pack/packages/ml/data_view_utils @elastic/ml-ui x-pack/packages/ml/date_picker @elastic/ml-ui x-pack/packages/ml/date_utils @elastic/ml-ui +x-pack/packages/ml/embeddables @elastic/ml-ui x-pack/packages/ml/error_utils @elastic/ml-ui x-pack/packages/ml/field_stats_flyout @elastic/ml-ui x-pack/packages/ml/in_memory_table @elastic/ml-ui @@ -616,6 +617,7 @@ x-pack/packages/ml/is_defined @elastic/ml-ui x-pack/packages/ml/is_populated_object @elastic/ml-ui x-pack/packages/ml/kibana_theme @elastic/ml-ui x-pack/packages/ml/local_storage @elastic/ml-ui +x-pack/packages/ml/locator @elastic/ml-ui x-pack/packages/ml/nested_property @elastic/ml-ui x-pack/packages/ml/number_utils @elastic/ml-ui x-pack/packages/ml/parse_interval @elastic/ml-ui diff --git a/package.json b/package.json index 9d15c9a94896a..c4c88ecbe8fa1 100644 --- a/package.json +++ b/package.json @@ -652,6 +652,7 @@ "@kbn/ml-is-populated-object": "link:x-pack/packages/ml/is_populated_object", "@kbn/ml-kibana-theme": "link:x-pack/packages/ml/kibana_theme", "@kbn/ml-local-storage": "link:x-pack/packages/ml/local_storage", + "@kbn/ml-locator": "link:x-pack/packages/ml/locator", "@kbn/ml-nested-property": "link:x-pack/packages/ml/nested_property", "@kbn/ml-number-utils": "link:x-pack/packages/ml/number_utils", "@kbn/ml-parse-interval": "link:x-pack/packages/ml/parse_interval", diff --git a/tsconfig.base.json b/tsconfig.base.json index 2ce958153c244..590f93ab7d5c1 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1228,6 +1228,8 @@ "@kbn/ml-kibana-theme/*": ["x-pack/packages/ml/kibana_theme/*"], "@kbn/ml-local-storage": ["x-pack/packages/ml/local_storage"], "@kbn/ml-local-storage/*": ["x-pack/packages/ml/local_storage/*"], + "@kbn/ml-locator": ["x-pack/packages/ml/locator"], + "@kbn/ml-locator/*": ["x-pack/packages/ml/locator/*"], "@kbn/ml-nested-property": ["x-pack/packages/ml/nested_property"], "@kbn/ml-nested-property/*": ["x-pack/packages/ml/nested_property/*"], "@kbn/ml-number-utils": ["x-pack/packages/ml/number_utils"], diff --git a/x-pack/packages/ml/embeddables/index.ts b/x-pack/packages/ml/embeddables/index.ts index deb276ee09af3..86f12d5a5651d 100644 --- a/x-pack/packages/ml/embeddables/index.ts +++ b/x-pack/packages/ml/embeddables/index.ts @@ -9,4 +9,7 @@ export { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE, ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE, + type AnomalyExplorerChartsEmbeddableType, + type AnomalySwimLaneEmbeddableType, + type MlEmbeddableTypes, } from './constants'; diff --git a/x-pack/packages/ml/embeddables/package.json b/x-pack/packages/ml/embeddables/package.json index b4a2d17c63595..490b5cf5de337 100644 --- a/x-pack/packages/ml/embeddables/package.json +++ b/x-pack/packages/ml/embeddables/package.json @@ -2,5 +2,5 @@ "name": "@kbn/ml-embeddables", "private": true, "version": "1.0.0", - "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" + "license": "Elastic License 2.0" } \ No newline at end of file diff --git a/x-pack/packages/ml/locator/README.md b/x-pack/packages/ml/locator/README.md new file mode 100644 index 0000000000000..34230fc294b9e --- /dev/null +++ b/x-pack/packages/ml/locator/README.md @@ -0,0 +1,3 @@ +# @kbn/ml-locator + +Empty package generated by @kbn/generate diff --git a/x-pack/plugins/ml/common/constants/locator.ts b/x-pack/packages/ml/locator/constants.ts similarity index 100% rename from x-pack/plugins/ml/common/constants/locator.ts rename to x-pack/packages/ml/locator/constants.ts diff --git a/x-pack/plugins/ml/public/locator/formatters/aiops.ts b/x-pack/packages/ml/locator/formatters/aiops.ts similarity index 89% rename from x-pack/plugins/ml/public/locator/formatters/aiops.ts rename to x-pack/packages/ml/locator/formatters/aiops.ts index 941eecfd711bd..dfb97c1f7c7d0 100644 --- a/x-pack/plugins/ml/public/locator/formatters/aiops.ts +++ b/x-pack/packages/ml/locator/formatters/aiops.ts @@ -6,8 +6,8 @@ */ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; -import { ML_PAGES } from '../../../common/constants/locator'; -import type { ChangePointDetectionUrlState } from '../../../common/types/locator'; +import { ML_PAGES } from '../constants'; +import type { ChangePointDetectionUrlState } from '../types'; /** * Creates URL to the Change Point Detection page diff --git a/x-pack/plugins/ml/public/locator/formatters/anomaly_detection.ts b/x-pack/packages/ml/locator/formatters/anomaly_detection.ts similarity index 95% rename from x-pack/plugins/ml/public/locator/formatters/anomaly_detection.ts rename to x-pack/packages/ml/locator/formatters/anomaly_detection.ts index 939dc470f1d18..acde86556fadc 100644 --- a/x-pack/plugins/ml/public/locator/formatters/anomaly_detection.ts +++ b/x-pack/packages/ml/locator/formatters/anomaly_detection.ts @@ -9,6 +9,7 @@ import { isEmpty } from 'lodash'; import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; import type { + AppPageState, AnomalyDetectionUrlState, ExplorerAppState, ExplorerGlobalState, @@ -18,11 +19,10 @@ import type { TimeSeriesExplorerAppState, TimeSeriesExplorerGlobalState, TimeSeriesExplorerUrlState, -} from '../../../common/types/locator'; -import { ML_PAGES } from '../../../common/constants/locator'; +} from '../types'; +import { ML_PAGES } from '../constants'; import { formatGenericMlUrl } from './common'; -import { getGroupQueryText, getJobQueryText } from '../../../common/util/string_utils'; -import type { AppPageState } from '../../../common/types/common'; +import { getGroupQueryText, getJobQueryText } from './string_utils'; /** * Creates URL to the Anomaly Detection Job management page diff --git a/x-pack/plugins/ml/public/locator/formatters/common.ts b/x-pack/packages/ml/locator/formatters/common.ts similarity index 96% rename from x-pack/plugins/ml/public/locator/formatters/common.ts rename to x-pack/packages/ml/locator/formatters/common.ts index 949d4063562f0..d2df3acaf1ff7 100644 --- a/x-pack/plugins/ml/public/locator/formatters/common.ts +++ b/x-pack/packages/ml/locator/formatters/common.ts @@ -7,7 +7,7 @@ import { isEmpty } from 'lodash'; import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; -import type { MlGenericUrlState } from '../../../common/types/locator'; +import type { MlGenericUrlState } from '../types'; export function extractParams(urlState: UrlState) { // page should be guaranteed to exist here but is unknown diff --git a/x-pack/plugins/ml/public/locator/formatters/data_frame_analytics.ts b/x-pack/packages/ml/locator/formatters/data_frame_analytics.ts similarity index 94% rename from x-pack/plugins/ml/public/locator/formatters/data_frame_analytics.ts rename to x-pack/packages/ml/locator/formatters/data_frame_analytics.ts index e1d3317364edf..41e5b3f75416b 100644 --- a/x-pack/plugins/ml/public/locator/formatters/data_frame_analytics.ts +++ b/x-pack/packages/ml/locator/formatters/data_frame_analytics.ts @@ -13,16 +13,16 @@ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; import { formatGenericMlUrl } from './common'; import type { + AppPageState, DataFrameAnalyticsExplorationQueryState, DataFrameAnalyticsExplorationUrlState, DataFrameAnalyticsUrlState, ExplorationPageUrlState, MlGenericUrlState, MlCommonGlobalState, -} from '../../../common/types/locator'; -import { ML_PAGES } from '../../../common/constants/locator'; -import { getGroupQueryText, getJobQueryText } from '../../../common/util/string_utils'; -import type { AppPageState } from '../../../common/types/common'; +} from '../types'; +import { ML_PAGES } from '../constants'; +import { getGroupQueryText, getJobQueryText } from './string_utils'; export function formatDataFrameAnalyticsJobManagementUrl( appBasePath: string, diff --git a/x-pack/packages/ml/locator/formatters/index.ts b/x-pack/packages/ml/locator/formatters/index.ts new file mode 100644 index 0000000000000..1490fb852ee43 --- /dev/null +++ b/x-pack/packages/ml/locator/formatters/index.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { extractParams, formatGenericMlUrl } from './common'; +export { + formatAnomalyDetectionJobManagementUrl, + formatAnomalyDetectionCreateJobSelectType, + formatAnomalyDetectionCreateJobSelectIndex, + formatSuppliedConfigurationsManagementUrl, + formatExplorerUrl, + formatSingleMetricViewerUrl, +} from './anomaly_detection'; +export { + formatDataFrameAnalyticsJobManagementUrl, + formatDataFrameAnalyticsExplorationUrl, + formatDataFrameAnalyticsCreateJobUrl, + formatDataFrameAnalyticsMapUrl, +} from './data_frame_analytics'; +export { formatNotificationsUrl } from './notifications'; +export { formatEditCalendarUrl, formatEditFilterUrl } from './settings'; diff --git a/x-pack/plugins/ml/public/locator/formatters/notifications.ts b/x-pack/packages/ml/locator/formatters/notifications.ts similarity index 89% rename from x-pack/plugins/ml/public/locator/formatters/notifications.ts rename to x-pack/packages/ml/locator/formatters/notifications.ts index a86f0e91ed2be..433e8c66f715d 100644 --- a/x-pack/plugins/ml/public/locator/formatters/notifications.ts +++ b/x-pack/packages/ml/locator/formatters/notifications.ts @@ -6,8 +6,8 @@ */ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; -import { ML_PAGES } from '../../../common/constants/locator'; -import type { NotificationsUrlState } from '../../../common/types/locator'; +import { ML_PAGES } from '../constants'; +import type { NotificationsUrlState } from '../types'; export interface NotificationsAppState { level?: string; diff --git a/x-pack/plugins/ml/public/locator/formatters/settings.tsx b/x-pack/packages/ml/locator/formatters/settings.tsx similarity index 93% rename from x-pack/plugins/ml/public/locator/formatters/settings.tsx rename to x-pack/packages/ml/locator/formatters/settings.tsx index fd9b9dd3dba4c..ed981151e86eb 100644 --- a/x-pack/plugins/ml/public/locator/formatters/settings.tsx +++ b/x-pack/packages/ml/locator/formatters/settings.tsx @@ -6,8 +6,8 @@ */ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; -import type { CalendarEditUrlState, FilterEditUrlState } from '../../../common/types/locator'; -import { ML_PAGES } from '../../../common/constants/locator'; +import type { CalendarEditUrlState, FilterEditUrlState } from '../types'; +import { ML_PAGES } from '../constants'; export function formatEditCalendarUrl( appBasePath: string, diff --git a/x-pack/packages/ml/locator/formatters/string_utils.test.ts b/x-pack/packages/ml/locator/formatters/string_utils.test.ts new file mode 100644 index 0000000000000..9d568da845d74 --- /dev/null +++ b/x-pack/packages/ml/locator/formatters/string_utils.test.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { getGroupQueryText } from './string_utils'; + +describe('getGroupQueryText', () => { + const groupIdOne = 'test_group_id_1'; + const groupIdTwo = 'test_group_id_2'; + + it('should get query string for selected group ids', () => { + const actual = getGroupQueryText([groupIdOne, groupIdTwo]); + expect(actual).toBe(`groups:(${groupIdOne} or ${groupIdTwo})`); + }); + + it('should get query string for selected group id', () => { + const actual = getGroupQueryText([groupIdOne]); + expect(actual).toBe(`groups:(${groupIdOne})`); + }); +}); diff --git a/x-pack/packages/ml/locator/formatters/string_utils.ts b/x-pack/packages/ml/locator/formatters/string_utils.ts new file mode 100644 index 0000000000000..01e235818110a --- /dev/null +++ b/x-pack/packages/ml/locator/formatters/string_utils.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export function getGroupQueryText(groupIds: string[]): string { + return `groups:(${groupIds.join(' or ')})`; +} + +export function getJobQueryText(jobIds: string | string[]): string { + return Array.isArray(jobIds) ? `id:(${jobIds.join(' OR ')})` : `id:${jobIds}`; +} diff --git a/x-pack/plugins/ml/public/locator/formatters/trained_models.ts b/x-pack/packages/ml/locator/formatters/trained_models.ts similarity index 89% rename from x-pack/plugins/ml/public/locator/formatters/trained_models.ts rename to x-pack/packages/ml/locator/formatters/trained_models.ts index d3048405be91d..623900ec693f0 100644 --- a/x-pack/plugins/ml/public/locator/formatters/trained_models.ts +++ b/x-pack/packages/ml/locator/formatters/trained_models.ts @@ -7,9 +7,8 @@ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; -import type { MemoryUsageUrlState, TrainedModelsUrlState } from '../../../common/types/locator'; -import { ML_PAGES } from '../../../common/constants/locator'; -import type { AppPageState } from '../../../common/types/common'; +import type { AppPageState, MemoryUsageUrlState, TrainedModelsUrlState } from '../types'; +import { ML_PAGES } from '../constants'; export function formatTrainedModelsManagementUrl( appBasePath: string, diff --git a/x-pack/packages/ml/locator/index.ts b/x-pack/packages/ml/locator/index.ts new file mode 100644 index 0000000000000..4b2fc54ff8613 --- /dev/null +++ b/x-pack/packages/ml/locator/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { formatExplorerUrl } from './formatters'; +export { ML_APP_LOCATOR, ML_PAGES, type MlPages } from './constants'; +export { MlLocatorDefinition, type MlLocatorParams, type MlLocator } from './ml_locator'; +export { useMlHref } from './use_ml_href'; +export type { + AnomalyExplorerFilterUrlState, + AnomalyExplorerSwimLaneUrlState, + AnomalyDetectionQueryState, + ExpandablePanels, + ExplorationPageUrlState, + ExplorerAppState, + TimeSeriesExplorerAppState, +} from './types'; diff --git a/x-pack/plugins/ml/public/locator/formatters/index.ts b/x-pack/packages/ml/locator/jest.config.js similarity index 65% rename from x-pack/plugins/ml/public/locator/formatters/index.ts rename to x-pack/packages/ml/locator/jest.config.js index 4b8dc38d51968..85248d09369c4 100644 --- a/x-pack/plugins/ml/public/locator/formatters/index.ts +++ b/x-pack/packages/ml/locator/jest.config.js @@ -5,7 +5,8 @@ * 2.0. */ -export * from './common'; -export * from './anomaly_detection'; -export * from './data_frame_analytics'; -export * from './settings'; +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../../../..', + roots: ['/x-pack/packages/ml/locator'], +}; diff --git a/x-pack/packages/ml/locator/kibana.jsonc b/x-pack/packages/ml/locator/kibana.jsonc new file mode 100644 index 0000000000000..b9874a1416b31 --- /dev/null +++ b/x-pack/packages/ml/locator/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-browser", + "id": "@kbn/ml-locator", + "owner": "@elastic/ml-ui" +} diff --git a/x-pack/plugins/ml/public/locator/ml_locator.test.ts b/x-pack/packages/ml/locator/ml_locator.test.ts similarity index 99% rename from x-pack/plugins/ml/public/locator/ml_locator.test.ts rename to x-pack/packages/ml/locator/ml_locator.test.ts index 4682ce68088af..fdc742a33d410 100644 --- a/x-pack/plugins/ml/public/locator/ml_locator.test.ts +++ b/x-pack/packages/ml/locator/ml_locator.test.ts @@ -6,7 +6,7 @@ */ import { MlLocatorDefinition } from './ml_locator'; -import { ML_PAGES } from '../../common/constants/locator'; +import { ML_PAGES } from './constants'; import { ANALYSIS_CONFIG_TYPE } from '@kbn/ml-data-frame-analytics-utils'; describe('ML locator', () => { diff --git a/x-pack/plugins/ml/public/locator/ml_locator.ts b/x-pack/packages/ml/locator/ml_locator.ts similarity index 97% rename from x-pack/plugins/ml/public/locator/ml_locator.ts rename to x-pack/packages/ml/locator/ml_locator.ts index d86fd10e7dc87..8126c860521bb 100644 --- a/x-pack/plugins/ml/public/locator/ml_locator.ts +++ b/x-pack/packages/ml/locator/ml_locator.ts @@ -13,8 +13,8 @@ import type { MlLocatorParams, MlLocator, ChangePointDetectionQueryState, -} from '../../common/types/locator'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../common/constants/locator'; +} from './types'; +import { ML_APP_LOCATOR, ML_PAGES } from './constants'; import { formatAnomalyDetectionCreateJobSelectIndex, formatAnomalyDetectionCreateJobSelectType, diff --git a/x-pack/packages/ml/locator/package.json b/x-pack/packages/ml/locator/package.json new file mode 100644 index 0000000000000..8353e5d112446 --- /dev/null +++ b/x-pack/packages/ml/locator/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/ml-locator", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0" +} \ No newline at end of file diff --git a/x-pack/packages/ml/locator/tsconfig.json b/x-pack/packages/ml/locator/tsconfig.json new file mode 100644 index 0000000000000..67d91ad79e541 --- /dev/null +++ b/x-pack/packages/ml/locator/tsconfig.json @@ -0,0 +1,30 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react", + "@emotion/react/types/css-prop" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/kibana-utils-plugin", + "@kbn/ml-url-state", + "@kbn/ml-is-populated-object", + "@kbn/share-plugin", + "@kbn/ml-data-frame-analytics-utils", + "@kbn/utility-types", + "@kbn/data-plugin", + "@kbn/ml-anomaly-utils", + "@kbn/ml-query-utils", + ] +} diff --git a/x-pack/plugins/ml/common/types/locator.ts b/x-pack/packages/ml/locator/types.ts similarity index 98% rename from x-pack/plugins/ml/common/types/locator.ts rename to x-pack/packages/ml/locator/types.ts index 3cc198bb3b3f2..ab8b46e67d92d 100644 --- a/x-pack/plugins/ml/common/types/locator.ts +++ b/x-pack/packages/ml/locator/types.ts @@ -12,11 +12,16 @@ import type { DataFrameAnalysisConfigType } from '@kbn/ml-data-frame-analytics-u import type { InfluencersFilterQuery } from '@kbn/ml-anomaly-utils'; import type { SearchQueryLanguage } from '@kbn/ml-query-utils'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; -import type { JobId } from './anomaly_detection_jobs/job'; -import type { ML_PAGES } from '../constants/locator'; +import type { MlPages, ML_PAGES } from './constants'; + +type JobId = string; type OptionalPageState = object | undefined; +export type AppPageState = { + [key in MlPages]?: Partial; +}; + export type MLPageState = PageState extends OptionalPageState ? { page: PageType; pageState?: PageState } : PageState extends object diff --git a/x-pack/plugins/ml/public/locator/use_ml_href.ts b/x-pack/packages/ml/locator/use_ml_href.ts similarity index 70% rename from x-pack/plugins/ml/public/locator/use_ml_href.ts rename to x-pack/packages/ml/locator/use_ml_href.ts index d4523da2da6e9..d076809094b0b 100644 --- a/x-pack/plugins/ml/public/locator/use_ml_href.ts +++ b/x-pack/packages/ml/locator/use_ml_href.ts @@ -6,21 +6,23 @@ */ import type { DependencyList } from 'react'; -import type { MlPluginSetup } from '..'; -import type { MlLocatorParams } from '../../common/types/locator'; + +import type { LocatorPublic } from '@kbn/share-plugin/public'; + +import type { MlLocatorParams } from './types'; /** * Provides a URL to ML plugin page * TODO remove basePath parameter */ export const useMlHref = ( - ml: MlPluginSetup | undefined, + mlLocator: LocatorPublic | undefined, basePath: string | undefined, params: MlLocatorParams, dependencies?: DependencyList ) => { - return ml && ml.locator - ? ml.locator.useUrl(params, undefined, dependencies) + return mlLocator + ? mlLocator.useUrl(params, undefined, dependencies) : basePath !== undefined ? `${basePath}/app/ml/${params.page}` : ''; diff --git a/x-pack/plugins/ml/common/types/common.ts b/x-pack/plugins/ml/common/types/common.ts index ec75a2b8d525f..0318260af5210 100644 --- a/x-pack/plugins/ml/common/types/common.ts +++ b/x-pack/plugins/ml/common/types/common.ts @@ -5,8 +5,6 @@ * 2.0. */ -import type { MlPages } from '../constants/locator'; - export interface Dictionary { [id: string]: TValue; } @@ -35,10 +33,6 @@ type DeepReadonlyObject = { readonly [P in keyof T]: DeepReadonly; }; -export type AppPageState = { - [key in MlPages]?: Partial; -}; - type Without = { [P in Exclude]?: never }; export type XOR = T | U extends object ? (Without & U) | (Without & T) : T | U; diff --git a/x-pack/plugins/ml/common/util/string_utils.test.ts b/x-pack/plugins/ml/common/util/string_utils.test.ts index 43acc80110001..fca8c1a113cb0 100644 --- a/x-pack/plugins/ml/common/util/string_utils.test.ts +++ b/x-pack/plugins/ml/common/util/string_utils.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { renderTemplate, getMedianStringLength, getGroupQueryText } from './string_utils'; +import { renderTemplate, getMedianStringLength } from './string_utils'; const strings: string[] = [ 'foo', @@ -47,19 +47,4 @@ describe('ML - string utils', () => { expect(result).toBe(0); }); }); - - describe('getGroupQueryText', () => { - const groupIdOne = 'test_group_id_1'; - const groupIdTwo = 'test_group_id_2'; - - it('should get query string for selected group ids', () => { - const actual = getGroupQueryText([groupIdOne, groupIdTwo]); - expect(actual).toBe(`groups:(${groupIdOne} or ${groupIdTwo})`); - }); - - it('should get query string for selected group id', () => { - const actual = getGroupQueryText([groupIdOne]); - expect(actual).toBe(`groups:(${groupIdOne})`); - }); - }); }); diff --git a/x-pack/plugins/ml/common/util/string_utils.ts b/x-pack/plugins/ml/common/util/string_utils.ts index d55d007ceb225..d420d63416f34 100644 --- a/x-pack/plugins/ml/common/util/string_utils.ts +++ b/x-pack/plugins/ml/common/util/string_utils.ts @@ -23,11 +23,3 @@ export function getMedianStringLength(strings: string[]) { const sortedStringLengths = strings.map((s) => s.length).sort((a, b) => a - b); return sortedStringLengths[Math.floor(sortedStringLengths.length / 2)] || 0; } - -export function getGroupQueryText(groupIds: string[]): string { - return `groups:(${groupIds.join(' or ')})`; -} - -export function getJobQueryText(jobIds: string | string[]): string { - return Array.isArray(jobIds) ? `id:(${jobIds.join(' OR ')})` : `id:${jobIds}`; -} diff --git a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx index 3d70b4bbdc16d..25f4c452bebbe 100644 --- a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx @@ -9,14 +9,16 @@ import type { FC } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { EuiSpacer, EuiForm } from '@elastic/eui'; import useMount from 'react-use/lib/useMount'; + import { i18n } from '@kbn/i18n'; import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; import { isDefined } from '@kbn/ml-is-defined'; import { ML_ANOMALY_RESULT_TYPE, ML_ANOMALY_THRESHOLD } from '@kbn/ml-anomaly-utils'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { parseInterval } from '@kbn/ml-parse-interval'; +import { ML_PAGES } from '@kbn/ml-locator'; + import type { MlCapabilities } from '../../../common/types/capabilities'; -import { ML_PAGES } from '../../../common/constants/locator'; import type { MlCoreSetup } from '../../plugin'; import { JobSelectorControl } from '../job_selector'; import { jobsApiProvider } from '../../application/services/ml_api_service/jobs'; diff --git a/x-pack/plugins/ml/public/alerting/register_ml_alerts.ts b/x-pack/plugins/ml/public/alerting/register_ml_alerts.ts index 8d47d4d18d947..cdc29f98e37f3 100644 --- a/x-pack/plugins/ml/public/alerting/register_ml_alerts.ts +++ b/x-pack/plugins/ml/public/alerting/register_ml_alerts.ts @@ -7,12 +7,12 @@ import type { TriggersAndActionsUIPublicPluginSetup } from '@kbn/triggers-actions-ui-plugin/public'; import type { PluginSetupContract as AlertingSetup } from '@kbn/alerting-plugin/public'; +import { formatExplorerUrl } from '@kbn/ml-locator'; import type { MlCapabilities } from '../../common/types/capabilities'; import type { MlCoreSetup } from '../plugin'; import { ML_ALERT_TYPES } from '../../common/constants/alerts'; import type { MlAnomalyDetectionAlertParams } from '../../common/types/alerts'; import { ML_APP_ROUTE, PLUGIN_ID } from '../../common/constants/app'; -import { formatExplorerUrl } from '../locator/formatters/anomaly_detection'; import { registerJobsHealthAlertingRule } from './jobs_health_rule'; import { registerAnomalyDetectionRule } from './anomaly_detection_rule'; diff --git a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js index 95433e3ec7c06..f5548f1d56258 100644 --- a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js +++ b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js @@ -30,6 +30,8 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { withKibana } from '@kbn/kibana-react-plugin/public'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; +import { timeFormatter } from '@kbn/ml-date-utils'; import { addItemToRecentlyAccessed } from '../../../util/recently_accessed'; import { mlJobServiceFactory } from '../../../services/job_service'; @@ -45,8 +47,6 @@ import { ANNOTATION_EVENT_USER, ANNOTATION_EVENT_DELAYED_DATA, } from '../../../../../common/constants/annotations'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../../../../common/constants/locator'; -import { timeFormatter } from '@kbn/ml-date-utils'; import { MlAnnotationUpdatesContext } from '../../../contexts/ml/ml_annotation_updates_context'; import { DatafeedChartFlyout } from '../../../jobs/jobs_list/components/datafeed_chart_flyout'; import { RevertModelSnapshotFlyout } from '../../model_snapshots/revert_model_snapshot_flyout'; diff --git a/x-pack/plugins/ml/public/application/components/anomalies_table/links_menu.tsx b/x-pack/plugins/ml/public/application/components/anomalies_table/links_menu.tsx index 89bb4b800eb91..38bd52f5d56e5 100644 --- a/x-pack/plugins/ml/public/application/components/anomalies_table/links_menu.tsx +++ b/x-pack/plugins/ml/public/application/components/anomalies_table/links_menu.tsx @@ -43,15 +43,14 @@ import { CATEGORIZE_FIELD_TRIGGER } from '@kbn/ml-ui-actions'; import { isDefined } from '@kbn/ml-is-defined'; import { escapeQuotes } from '@kbn/es-query'; import { isQuery } from '@kbn/data-plugin/public'; - import type { TimeRangeBounds } from '@kbn/ml-time-buckets'; import { parseInterval } from '@kbn/ml-parse-interval'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; + import { PLUGIN_ID } from '../../../../common/constants/app'; import { findMessageField } from '../../util/index_utils'; import { getInitialAnomaliesLayers, getInitialSourceIndexFieldLayers } from '../../../maps/util'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../../../common/constants/locator'; import { getFiltersForDSLQuery } from '../../../../common/util/job_utils'; - import { useMlJobService } from '../../services/job_service'; import { escapeKueryForFieldValuePair, replaceStringTokens } from '../../util/string_utils'; import { getUrlForRecord, openCustomUrlWindow } from '../../util/custom_url_utils'; diff --git a/x-pack/plugins/ml/public/application/components/anomaly_results_view_selector/anomaly_results_view_selector.tsx b/x-pack/plugins/ml/public/application/components/anomaly_results_view_selector/anomaly_results_view_selector.tsx index 824c68ef0bf3a..8300d6c5280d1 100644 --- a/x-pack/plugins/ml/public/application/components/anomaly_results_view_selector/anomaly_results_view_selector.tsx +++ b/x-pack/plugins/ml/public/application/components/anomaly_results_view_selector/anomaly_results_view_selector.tsx @@ -13,10 +13,10 @@ import { EuiButtonGroup } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { useUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { ExplorerJob } from '../../explorer/explorer_utils'; import { useMlLocator, useNavigateToPath } from '../../contexts/kibana'; -import { ML_PAGES } from '../../../../common/constants/locator'; interface Props { viewId: typeof ML_PAGES.SINGLE_METRIC_VIEWER | typeof ML_PAGES.ANOMALY_EXPLORER; diff --git a/x-pack/plugins/ml/public/application/components/feedback_button/feedback_button.tsx b/x-pack/plugins/ml/public/application/components/feedback_button/feedback_button.tsx index d7315ef65d6ba..7d5017b3f589e 100644 --- a/x-pack/plugins/ml/public/application/components/feedback_button/feedback_button.tsx +++ b/x-pack/plugins/ml/public/application/components/feedback_button/feedback_button.tsx @@ -8,8 +8,8 @@ import type { FC } from 'react'; import React, { useState, useEffect, useMemo } from 'react'; import useMountedState from 'react-use/lib/useMountedState'; -import type { MlPages } from '../../../locator'; -import { ML_PAGES } from '../../../locator'; +import type { MlPages } from '@kbn/ml-locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlKibana } from '../../contexts/kibana'; import { useEnabledFeatures } from '../../contexts/ml'; diff --git a/x-pack/plugins/ml/public/application/components/job_selector/job_selector.tsx b/x-pack/plugins/ml/public/application/components/job_selector/job_selector.tsx index 063aa303944be..21a895a2c4297 100644 --- a/x-pack/plugins/ml/public/application/components/job_selector/job_selector.tsx +++ b/x-pack/plugins/ml/public/application/components/job_selector/job_selector.tsx @@ -20,7 +20,7 @@ import { useUrlState } from '@kbn/ml-url-state'; import './_index.scss'; import { useStorage } from '@kbn/ml-local-storage'; -import { ML_PAGES } from '../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { Dictionary } from '../../../../common/types/common'; import { IdBadges } from './id_badges'; import type { JobSelectorFlyoutProps } from './job_selector_flyout'; diff --git a/x-pack/plugins/ml/public/application/components/job_selector/job_selector_table/job_selector_table.js b/x-pack/plugins/ml/public/application/components/job_selector/job_selector_table/job_selector_table.js index b9086c31beded..6f3b6f1e323c9 100644 --- a/x-pack/plugins/ml/public/application/components/job_selector/job_selector_table/job_selector_table.js +++ b/x-pack/plugins/ml/public/application/components/job_selector/job_selector_table/job_selector_table.js @@ -25,7 +25,7 @@ import { import { i18n } from '@kbn/i18n'; import { useMlKibana } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { PLUGIN_ID } from '../../../../../common/constants/app'; import { MlNodeAvailableWarningShared } from '../../node_available_warning'; diff --git a/x-pack/plugins/ml/public/application/components/ml_page/side_nav.tsx b/x-pack/plugins/ml/public/application/components/ml_page/side_nav.tsx index fac21b54e43a8..d4dca806c326c 100644 --- a/x-pack/plugins/ml/public/application/components/ml_page/side_nav.tsx +++ b/x-pack/plugins/ml/public/application/components/ml_page/side_nav.tsx @@ -11,12 +11,12 @@ import type { ReactNode } from 'react'; import React, { useCallback, useMemo } from 'react'; import { CHANGE_POINT_DETECTION_ENABLED } from '@kbn/aiops-change-point-detection/constants'; import { useUrlState } from '@kbn/ml-url-state'; +import type { MlLocatorParams } from '@kbn/ml-locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { NotificationsIndicator } from './notifications_indicator'; -import type { MlLocatorParams } from '../../../../common/types/locator'; import { useMlLocator, useNavigateToPath } from '../../contexts/kibana'; import { isFullLicense } from '../../license'; import type { MlRoute } from '../../routing'; -import { ML_PAGES } from '../../../../common/constants/locator'; import { usePermissionCheck } from '../../capabilities/check_capabilities'; export interface Tab { diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.js b/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.js index b2754d729df6f..02b2281eeb0be 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.js @@ -18,7 +18,7 @@ import { ScopeExpression } from './scope_expression'; import { checkPermission } from '../../capabilities/check_capabilities'; import { getScopeFieldDefaults } from './utils'; import { FormattedMessage } from '@kbn/i18n-react'; -import { ML_PAGES } from '../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLocator, useNavigateToPath } from '../../contexts/kibana'; function NoFilterListsCallOut() { diff --git a/x-pack/plugins/ml/public/application/contexts/kibana/use_cases_modal.ts b/x-pack/plugins/ml/public/application/contexts/kibana/use_cases_modal.ts index c6142e715bad7..71f7f246e477e 100644 --- a/x-pack/plugins/ml/public/application/contexts/kibana/use_cases_modal.ts +++ b/x-pack/plugins/ml/public/application/contexts/kibana/use_cases_modal.ts @@ -8,8 +8,9 @@ import { useCallback } from 'react'; import { stringHash } from '@kbn/ml-string-hash'; import { AttachmentType } from '@kbn/cases-plugin/common'; +import type { MlEmbeddableTypes } from '@kbn/ml-embeddables'; import { useMlKibana } from './kibana_context'; -import type { MappedEmbeddableTypeOf, MlEmbeddableTypes } from '../../../embeddables'; +import type { MappedEmbeddableTypeOf } from '../../../embeddables'; /** * Returns a callback for opening the cases modal with provided attachment state. diff --git a/x-pack/plugins/ml/public/application/contexts/kibana/use_create_url.ts b/x-pack/plugins/ml/public/application/contexts/kibana/use_create_url.ts index fa5aeab263fb7..ed93f86ced8f1 100644 --- a/x-pack/plugins/ml/public/application/contexts/kibana/use_create_url.ts +++ b/x-pack/plugins/ml/public/application/contexts/kibana/use_create_url.ts @@ -8,9 +8,9 @@ import { useCallback, useEffect, useState } from 'react'; import type { LocatorGetUrlParams } from '@kbn/share-plugin/common/url_service'; import { useUrlState } from '@kbn/ml-url-state'; +import { ML_APP_LOCATOR } from '@kbn/ml-locator'; +import type { MlLocatorParams } from '@kbn/ml-locator'; import { useMlKibana } from './kibana_context'; -import { ML_APP_LOCATOR } from '../../../../common/constants/locator'; -import type { MlLocatorParams } from '../../../../common/types/locator'; export const useMlLocator = () => { const { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/back_to_list_panel/back_to_list_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/back_to_list_panel/back_to_list_panel.tsx index 93d7fddeea364..22aed50c0073d 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/back_to_list_panel/back_to_list_panel.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/back_to_list_panel/back_to_list_panel.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React, { Fragment } from 'react'; import { EuiCard, EuiIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLink } from '../../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; export const BackToListPanel: FC = () => { const analyticsManagementPageLink = useMlLink({ diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/view_results_panel/view_results_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/view_results_panel/view_results_panel.tsx index a6b88e13ef69e..b214ef73b13e1 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/view_results_panel/view_results_panel.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/view_results_panel/view_results_panel.tsx @@ -10,8 +10,8 @@ import React, { Fragment } from 'react'; import { EuiCard, EuiIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import type { DataFrameAnalysisConfigType } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLink } from '../../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; interface Props { jobId: string; analysisType: DataFrameAnalysisConfigType; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/expandable_section/expandable_section.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/expandable_section/expandable_section.tsx index 68de97b30b575..6e386fc3a478f 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/expandable_section/expandable_section.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/expandable_section/expandable_section.tsx @@ -19,11 +19,11 @@ import { EuiPanel, EuiText, } from '@elastic/eui'; +import type { ExpandablePanels } from '@kbn/ml-locator'; import { getDefaultExplorationPageUrlState, useExplorationUrlState, } from '../../hooks/use_exploration_url_state'; -import type { ExpandablePanels } from '../../../../../../../common/types/locator'; interface HeaderItem { // id is used as the React key and to construct a data-test-subj diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts index 8c3e6d1f1df22..7e8097c730fd6 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/hooks/use_exploration_url_state.ts @@ -8,8 +8,8 @@ import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { usePageUrlState } from '@kbn/ml-url-state'; import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; -import type { ExplorationPageUrlState } from '../../../../../../common/types/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; +import type { ExplorationPageUrlState } from '@kbn/ml-locator'; export function getDefaultExplorationPageUrlState( overrides?: Partial diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_map/use_map_action.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_map/use_map_action.tsx index 19831bf9efcf6..1ecfd823501ef 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_map/use_map_action.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_map/use_map_action.tsx @@ -8,12 +8,12 @@ import React, { useCallback, useMemo } from 'react'; import { cloneDeep } from 'lodash'; import { useUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLocator, useNavigateToPath } from '../../../../../contexts/kibana'; import type { DataFrameAnalyticsListAction, DataFrameAnalyticsListRow, } from '../analytics_list/common'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; import { getViewLinkStatus } from '../action_view/get_view_link_status'; import { mapActionButtonText, MapButton } from './map_button'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_view/use_view_action.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_view/use_view_action.tsx index e61f3de72e8eb..71d825432b178 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_view/use_view_action.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_view/use_view_action.tsx @@ -12,6 +12,7 @@ import { type DataFrameAnalysisConfigType, } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLocator, useNavigateToPath } from '../../../../../contexts/kibana'; import type { @@ -21,7 +22,6 @@ import type { import { getViewLinkStatus } from './get_view_link_status'; import { viewActionButtonText, ViewButton } from './view_button'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; export type ViewAction = ReturnType; export const useViewAction = () => { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx index 8f192f3919e16..08e2c198cac0c 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/analytics_list.tsx @@ -23,10 +23,10 @@ import { type DataFrameAnalyticsId, } from '@kbn/ml-data-frame-analytics-utils'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useRefreshAnalyticsList } from '../../../../common'; import { usePermissionCheck } from '../../../../../capabilities/check_capabilities'; import { useNavigateToPath } from '../../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; import type { DataFrameAnalyticsListRow, ItemIdToExpandedRowMap } from './common'; import { DataFrameAnalyticsListColumn } from './common'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_columns.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_columns.tsx index fb9731c347aca..3d973ce1525d9 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_columns.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_columns.tsx @@ -25,6 +25,7 @@ import { type DataFrameAnalyticsId, type DataFrameAnalyticsStats, } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { DataFrameAnalyticsListRow } from './common'; import { getDataFrameAnalyticsProgressPhase, @@ -35,7 +36,6 @@ import { } from './common'; import { useActions } from './use_actions'; import { useMlLink } from '../../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; const TRUNCATE_TEXT_LINES = 3; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/empty_prompt/empty_prompt.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/empty_prompt/empty_prompt.tsx index 76248b6a9045a..e6043d5ae749b 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/empty_prompt/empty_prompt.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/empty_prompt/empty_prompt.tsx @@ -10,10 +10,10 @@ import React from 'react'; import { EuiButton, EuiEmptyPrompt, EuiImage, EuiLink } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ML_PAGES } from '@kbn/ml-locator'; import dfaImage from './data_frame_analytics_kibana.png'; import { mlNodesAvailable } from '../../../../../ml_nodes_check'; import { useMlKibana, useNavigateToPath } from '../../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; import { usePermissionCheck } from '../../../../../capabilities/check_capabilities'; export const AnalyticsEmptyPrompt: FC = () => { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/page.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/page.tsx index 583bf7449e463..1675faac7cd64 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/page.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/page.tsx @@ -11,6 +11,7 @@ import React, { useMemo, useState } from 'react'; import { useLocation } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n-react'; import { useUrlState, usePageUrlState, type ListingPageUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import { DataFrameAnalyticsList } from './components/analytics_list'; import { useRefreshInterval } from './components/analytics_list/use_refresh_interval'; import { NodeAvailableWarning } from '../../../components/node_available_warning'; @@ -18,7 +19,6 @@ import { SavedObjectsWarning } from '../../../components/saved_objects_warning'; import { UpgradeWarning } from '../../../components/upgrade'; import { JobMap } from '../job_map'; import { DataFrameAnalyticsListColumn } from './components/analytics_list/common'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { HelpMenu } from '../../../components/help_menu'; import { useMlKibana } from '../../../contexts/kibana'; import { useRefreshAnalyticsList } from '../../common'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/controls.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/controls.tsx index 848e56f75e9c9..15bab9bf9eb6e 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/controls.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/components/controls.tsx @@ -30,8 +30,8 @@ import { } from '@elastic/eui'; import { formatHumanReadableDateTimeSeconds } from '@kbn/ml-date-utils'; import { JOB_MAP_NODE_TYPES } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { CytoscapeContext } from './cytoscape'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; import { usePermissionCheck } from '../../../../capabilities/check_capabilities'; import { useMlLocator, diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/job_map.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/job_map.tsx index d03b62bf934a5..e5db5de12900c 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/job_map.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/job_map.tsx @@ -11,9 +11,9 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import { JOB_MAP_NODE_TYPES } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useCurrentThemeVars, useMlKibana, useMlLocator } from '../../../contexts/kibana'; import { Controls, Cytoscape, JobMapLegend } from './components'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import type { EuiThemeType } from '../../../components/color_range_legend'; import { useRefresh } from '../../../routing/use_refresh'; import { useRefDimensions } from './components/use_ref_dimensions'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/data_drift/data_drift_index_patterns_editor.tsx b/x-pack/plugins/ml/public/application/datavisualizer/data_drift/data_drift_index_patterns_editor.tsx index ea66d65de28b1..160d669f806bb 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/data_drift/data_drift_index_patterns_editor.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/data_drift/data_drift_index_patterns_editor.tsx @@ -25,8 +25,8 @@ import type { Observable } from 'rxjs'; import { combineLatest, map } from 'rxjs'; import { debounce, intersectionBy } from 'lodash'; import { type DataViewEditorService } from '@kbn/data-view-editor-plugin/public'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useToastNotificationService } from '../../services/toast_notification_service'; -import { ML_PAGES } from '../../../../common/constants/locator'; import { useMlKibana, useMlLocator, useNavigateToPath } from '../../contexts/kibana'; import { DataViewEditor } from './data_view_editor'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/data_drift/index_patterns_picker.tsx b/x-pack/plugins/ml/public/application/datavisualizer/data_drift/index_patterns_picker.tsx index 04dd9ca764ab0..991decfe35972 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/data_drift/index_patterns_picker.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/data_drift/index_patterns_picker.tsx @@ -14,8 +14,8 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { SavedObjectFinder } from '@kbn/saved-objects-finder-plugin/public'; import { type DataViewEditorService as DataViewEditorServiceSpec } from '@kbn/data-view-editor-plugin/public'; import { INDEX_PATTERN_TYPE } from '@kbn/data-views-plugin/public'; +import { ML_PAGES } from '@kbn/ml-locator'; import { createPath } from '../../routing/router'; -import { ML_PAGES } from '../../../../common/constants/locator'; import { DataDriftIndexPatternsEditor } from './data_drift_index_patterns_editor'; import { MlPageHeader } from '../../components/page_header'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx b/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx index 41b2ac3a47d37..7575980cafe5c 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/datavisualizer_selector.tsx @@ -24,11 +24,11 @@ import { import { FormattedMessage } from '@kbn/i18n-react'; import { useTimefilter } from '@kbn/ml-date-picker'; import { ENABLE_ESQL } from '@kbn/esql-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { isFullLicense } from '../license'; import { useMlKibana, useNavigateToPath } from '../contexts/kibana'; import { HelpMenu } from '../components/help_menu'; import { MlPageHeader } from '../components/page_header'; -import { ML_PAGES } from '../../locator'; function startTrialDescription() { return ( diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx index a4ff83970c9c0..9e478e5891046 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/file_datavisualizer.tsx @@ -16,10 +16,10 @@ import type { } from '@kbn/data-visualizer-plugin/public'; import { useTimefilter } from '@kbn/ml-date-picker'; import type { ResultLinks } from '@kbn/data-visualizer-plugin/common/app'; +import { ML_PAGES } from '@kbn/ml-locator'; import { HelpMenu } from '../../components/help_menu'; -import { useMlApi, useMlKibana, useMlLocator } from '../../contexts/kibana'; -import { ML_PAGES } from '../../../../common/constants/locator'; +import { useMlApi, useMlKibana, useMlLocator } from '../../contexts/kibana'; import { isFullLicense } from '../../license'; import { mlNodesAvailable, getMlNodeCount } from '../../ml_nodes_check/check_ml_nodes'; import { checkPermission } from '../../capabilities/check_capabilities'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx index e85da14ddb808..6ba10dec7eb5e 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/index_data_visualizer.tsx @@ -18,9 +18,9 @@ import type { import { useTimefilter } from '@kbn/ml-date-picker'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import useMountedState from 'react-use/lib/useMountedState'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlApi, useMlKibana, useMlLocator } from '../../contexts/kibana'; import { HelpMenu } from '../../components/help_menu'; -import { ML_PAGES } from '../../../../common/constants/locator'; import { isFullLicense } from '../../license'; import { mlNodesAvailable, getMlNodeCount } from '../../ml_nodes_check/check_ml_nodes'; import { checkPermission } from '../../capabilities/check_capabilities'; diff --git a/x-pack/plugins/ml/public/application/explorer/anomaly_explorer_common_state.ts b/x-pack/plugins/ml/public/application/explorer/anomaly_explorer_common_state.ts index 800b3b2bc5eca..cd6b59993ffcc 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomaly_explorer_common_state.ts +++ b/x-pack/plugins/ml/public/application/explorer/anomaly_explorer_common_state.ts @@ -10,9 +10,9 @@ import { BehaviorSubject } from 'rxjs'; import { distinctUntilChanged, map, shareReplay, filter } from 'rxjs'; import { isEqual } from 'lodash'; import type { InfluencersFilterQuery } from '@kbn/ml-anomaly-utils'; +import type { AnomalyExplorerFilterUrlState } from '@kbn/ml-locator'; import type { ExplorerJob } from './explorer_utils'; import type { AnomalyExplorerUrlStateService } from './hooks/use_explorer_url_state'; -import type { AnomalyExplorerFilterUrlState } from '../../../common/types/locator'; import type { KQLFilterSettings } from './components/explorer_query_bar/explorer_query_bar'; import { StateService } from '../services/state_service'; diff --git a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline_state_service.ts b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline_state_service.ts index 371284d0ac047..88baa8c899d6a 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomaly_timeline_state_service.ts +++ b/x-pack/plugins/ml/public/application/explorer/anomaly_timeline_state_service.ts @@ -24,6 +24,7 @@ import type { TimeRangeBounds } from '@kbn/data-plugin/common'; import { mlTimefilterRefresh$ } from '@kbn/ml-date-picker'; import type { InfluencersFilterQuery } from '@kbn/ml-anomaly-utils'; import type { TimeBucketsInterval } from '@kbn/ml-time-buckets'; +import type { AnomalyExplorerSwimLaneUrlState } from '@kbn/ml-locator'; import type { AnomalyTimelineService } from '../services/anomaly_timeline_service'; import type { AppStateSelectedCells, @@ -32,7 +33,6 @@ import type { ViewBySwimLaneData, } from './explorer_utils'; import type { AnomalyExplorerCommonStateService } from './anomaly_explorer_common_state'; -import type { AnomalyExplorerSwimLaneUrlState } from '../../../common/types/locator'; import { ANOMALY_SWIM_LANE_HARD_LIMIT, SWIMLANE_TYPE, diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_anomalies_container.tsx b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_anomalies_container.tsx index 6198044753687..a93d56ba99d18 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_anomalies_container.tsx +++ b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_anomalies_container.tsx @@ -14,11 +14,12 @@ import type { TimefilterContract } from '@kbn/data-plugin/public'; import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; import type { MlEntityFieldOperation } from '@kbn/ml-anomaly-utils'; import type { TimeBuckets } from '@kbn/ml-time-buckets'; +import type { MlLocator } from '@kbn/ml-locator'; + import { ExplorerChartsContainer } from './explorer_charts_container'; import type { TableSeverity } from '../../components/controls/select_severity/select_severity'; import { SelectSeverityUI } from '../../components/controls/select_severity/select_severity'; import type { ExplorerChartsData } from './explorer_charts_container_service'; -import type { MlLocator } from '../../../../common/types/locator'; import type { AnomaliesTableData } from '../explorer_utils'; interface ExplorerAnomaliesContainerProps { diff --git a/x-pack/plugins/ml/public/application/explorer/hooks/use_explorer_url_state.ts b/x-pack/plugins/ml/public/application/explorer/hooks/use_explorer_url_state.ts index cfa3fdc03d343..49073407e6474 100644 --- a/x-pack/plugins/ml/public/application/explorer/hooks/use_explorer_url_state.ts +++ b/x-pack/plugins/ml/public/application/explorer/hooks/use_explorer_url_state.ts @@ -7,8 +7,8 @@ import type { PageUrlStateService } from '@kbn/ml-url-state'; import { usePageUrlState } from '@kbn/ml-url-state'; -import type { ExplorerAppState } from '../../../../common/types/locator'; -import { ML_PAGES } from '../../../../common/constants/locator'; +import type { ExplorerAppState } from '@kbn/ml-locator'; +import { ML_PAGES } from '@kbn/ml-locator'; export type AnomalyExplorerUrlStateService = PageUrlStateService; diff --git a/x-pack/plugins/ml/public/application/jobs/components/jobs_action_menu/jobs_action_menu.tsx b/x-pack/plugins/ml/public/application/jobs/components/jobs_action_menu/jobs_action_menu.tsx index 8dbf2b4ea22c9..fd4f474559ba0 100644 --- a/x-pack/plugins/ml/public/application/jobs/components/jobs_action_menu/jobs_action_menu.tsx +++ b/x-pack/plugins/ml/public/application/jobs/components/jobs_action_menu/jobs_action_menu.tsx @@ -8,8 +8,8 @@ import { EuiButtonEmpty } from '@elastic/eui'; import type { FC } from 'react'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLocator, useNavigateToPath } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../common/constants/locator'; export const JobsActionMenu: FC = () => { const navigateToPath = useNavigateToPath(); diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/anomaly_detection_empty_state/anomaly_detection_empty_state.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/anomaly_detection_empty_state/anomaly_detection_empty_state.tsx index 980f6587a4d22..2f25762785b17 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/anomaly_detection_empty_state/anomaly_detection_empty_state.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/anomaly_detection_empty_state/anomaly_detection_empty_state.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiButton, EuiEmptyPrompt, EuiImage, EuiLink } from '@elastic/eui'; +import { ML_PAGES } from '@kbn/ml-locator'; import adImage from './anomaly_detection_kibana.png'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; import { useMlKibana, useMlLocator, useNavigateToPath } from '../../../../contexts/kibana'; import { usePermissionCheck } from '../../../../capabilities/check_capabilities'; import { mlNodesAvailable } from '../../../../ml_nodes_check'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/forecasts_table/forecasts_table.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/forecasts_table/forecasts_table.js index 5f1cbb1c76ca0..b95a276a9c896 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/forecasts_table/forecasts_table.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/forecasts_table/forecasts_table.js @@ -23,6 +23,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { context } from '@kbn/kibana-react-plugin/public'; import { timeFormatter } from '@kbn/ml-date-utils'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; import { FORECAST_REQUEST_STATE } from '../../../../../../../common/constants/states'; import { addItemToRecentlyAccessed } from '../../../../../util/recently_accessed'; @@ -31,7 +32,6 @@ import { getLatestDataOrBucketTimestamp, isTimeSeriesViewJob, } from '../../../../../../../common/util/job_utils'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../../../../../../common/constants/locator'; const MAX_FORECASTS = 500; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/job_id_link.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/job_id_link.tsx index fea1c3d7fab3e..cf32d64d7d66b 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/job_id_link.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/job_id_link.tsx @@ -7,9 +7,9 @@ import React, { useEffect, useState } from 'react'; import { EuiLink } from '@elastic/eui'; +import { ML_PAGES } from '@kbn/ml-locator'; +import type { AnomalyDetectionQueryState } from '@kbn/ml-locator'; import { useMlLocator } from '../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; -import type { AnomalyDetectionQueryState } from '../../../../../../common/types/locator'; // @ts-ignore import { JobGroup } from '../job_group'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/new_job_button/new_job_button.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/new_job_button/new_job_button.js index a3f9067fe66b4..ba21a1224fa77 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/new_job_button/new_job_button.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/new_job_button/new_job_button.js @@ -13,7 +13,7 @@ import React from 'react'; import { EuiButton } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { useCreateAndNavigateToMlLink } from '../../../../contexts/kibana/use_create_url'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; export function NewJobButton() { const canCreateJob = usePermissionCheck('canCreateJob'); diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js index 57ee1e5f3ef5f..a4a9b2b4b405a 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js @@ -16,7 +16,7 @@ import { JOB_STATE, DATAFEED_STATE } from '../../../../../common/constants/state import { JOB_ACTION } from '../../../../../common/constants/job_actions'; import { mlCalendarService } from '../../../services/calendar_service'; import { jobCloningService } from '../../../services/job_cloning_service'; -import { ML_PAGES } from '../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { PLUGIN_ID } from '../../../../../common/constants/app'; import { CREATED_BY_LABEL } from '../../../../../common/constants/new_job'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/jobs.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/jobs.tsx index 0516fa1b7986d..783adaae26b89 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/jobs.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/jobs.tsx @@ -10,8 +10,8 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { usePageUrlState } from '@kbn/ml-url-state'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import { JobsListView } from './components/jobs_list_view'; -import { ML_PAGES } from '../../../../common/constants/locator'; import { HelpMenu } from '../../components/help_menu'; import { useMlKibana } from '../../contexts/kibana'; import { MlPageHeader } from '../../components/page_header'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts index 44a10b738256e..c2a6a23edfb80 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/general.ts @@ -21,6 +21,7 @@ import { SPARSE_DATA_AGGREGATIONS, } from '@kbn/ml-anomaly-utils'; import { cloneDeep } from 'lodash'; +import { ML_PAGES } from '@kbn/ml-locator'; import { jobCloningService } from '../../../../../services/job_cloning_service'; import type { Job, @@ -29,7 +30,6 @@ import type { } from '../../../../../../../common/types/anomaly_detection_jobs'; import type { NewJobCapsService } from '../../../../../services/new_job_capabilities/new_job_capabilities_service'; import type { NavigateToPath } from '../../../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../../../common/constants/locator'; import type { JobCreatorType } from '..'; import { CREATED_BY_LABEL, JOB_TYPE } from '../../../../../../../common/constants/new_job'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/utils.ts b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/utils.ts index 9950d1dff9ad5..220939dcabc2a 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/utils.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_lens/utils.ts @@ -21,7 +21,7 @@ import { KBN_FIELD_TYPES } from '@kbn/field-types'; import { ML_JOB_AGGREGATION } from '@kbn/ml-anomaly-utils'; import type { LensApi } from '@kbn/lens-plugin/public'; import type { DashboardApi } from '@kbn/dashboard-plugin/public'; -import { ML_PAGES, ML_APP_LOCATOR } from '../../../../../common/constants/locator'; +import { ML_PAGES, ML_APP_LOCATOR } from '@kbn/ml-locator'; export const COMPATIBLE_SERIES_TYPES = [ 'line', diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_map/utils.ts b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_map/utils.ts index fc9e1f09c556a..e3873428704ec 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_map/utils.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_map/utils.ts @@ -11,7 +11,7 @@ import { apiIsOfType } from '@kbn/presentation-publishing'; import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { MapApi } from '@kbn/maps-plugin/public'; import type { DashboardApi } from '@kbn/dashboard-plugin/public'; -import { ML_PAGES, ML_APP_LOCATOR } from '../../../../../common/constants/locator'; +import { ML_PAGES, ML_APP_LOCATOR } from '@kbn/ml-locator'; export async function redirectToGeoJobWizard( embeddable: MapApi, diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_pattern_analysis/utils.ts b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_pattern_analysis/utils.ts index cde9c58aa914b..f55ecd57e226f 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/job_from_pattern_analysis/utils.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/job_from_pattern_analysis/utils.ts @@ -9,8 +9,8 @@ import type { DataViewField, DataView } from '@kbn/data-views-plugin/common'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { Query, TimeRange } from '@kbn/es-query'; -import { ML_APP_LOCATOR } from '../../../../../common/constants/locator'; -import { ML_PAGES } from '../../../../locator'; +import { ML_APP_LOCATOR } from '@kbn/ml-locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { CategorizationType } from './quick_create_job'; export async function redirectToADJobWizards( diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/components/calendars/calendars_selection.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/components/calendars/calendars_selection.tsx index 06718f175b266..bbb0d787d04dd 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/components/calendars/calendars_selection.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/job_details_step/components/additional_section/components/calendars/calendars_selection.tsx @@ -20,13 +20,13 @@ import { EuiToolTip, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { ML_PAGES } from '@kbn/ml-locator'; import { JobCreatorContext } from '../../../../../job_creator_context'; import { Description } from './description'; import { PLUGIN_ID } from '../../../../../../../../../../../common/constants/app'; import type { Calendar } from '../../../../../../../../../../../common/types/calendars'; import { useMlApi, useMlKibana } from '../../../../../../../../../contexts/kibana'; import { GLOBAL_CALENDAR } from '../../../../../../../../../../../common/constants/calendars'; -import { ML_PAGES } from '../../../../../../../../../../../common/constants/locator'; export const CalendarsSelection: FC = () => { const { diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/job_type/page.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/job_type/page.tsx index 2d49f1f17727e..b6c4c0d210604 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/job_type/page.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/job_type/page.tsx @@ -19,6 +19,8 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { ES_FIELD_TYPES } from '@kbn/field-types'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; + import { useMlKibana, useNavigateToPath } from '../../../../contexts/kibana'; import { useDataSource } from '../../../../contexts/ml'; @@ -26,7 +28,6 @@ import { DataRecognizer } from '../../../../components/data_recognizer'; import { addItemToRecentlyAccessed } from '../../../../util/recently_accessed'; import { LinkCard } from '../../../../components/link_card'; import { CategorizationIcon } from './categorization_job_icon'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../../../../../common/constants/locator'; import { RareIcon } from './rare_job_icon'; import { GeoIcon } from './geo_job_icon'; import { useCreateAndNavigateToMlLink } from '../../../../contexts/kibana/use_create_url'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx index c65f9b83f8595..f07b1338efa83 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/page.tsx @@ -24,6 +24,7 @@ import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import { addExcludeFrozenToQuery } from '@kbn/ml-query-utils'; import { TIME_FORMAT } from '@kbn/ml-date-utils'; import { type RuntimeMappings } from '@kbn/ml-runtime-field-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { Module } from '../../../../../common/types/modules'; import { useDataSource } from '../../../contexts/ml'; import { useMlKibana, useMlLocator } from '../../../contexts/kibana'; @@ -43,7 +44,6 @@ import type { JobSettingsFormValues } from './components/job_settings_form'; import { JobSettingsForm } from './components/job_settings_form'; import type { TimeRange } from '../common/components'; import type { JobId } from '../../../../../common/types/anomaly_detection_jobs'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { JobsAwaitingNodeWarning } from '../../../components/jobs_awaiting_node_warning'; import { MlPageHeader } from '../../../components/page_header'; diff --git a/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/nodes_list.tsx b/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/nodes_list.tsx index d31981decb7e9..387cf876b2425 100644 --- a/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/nodes_list.tsx +++ b/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/nodes_list.tsx @@ -20,10 +20,10 @@ import { cloneDeep } from 'lodash'; import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common'; import { usePageUrlState } from '@kbn/ml-url-state'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { ModelsBarStats } from '../../components/stats_bar'; import { StatsBar } from '../../components/stats_bar'; import type { NodeDeploymentStatsResponse } from '../../../../common/types/trained_models'; -import { ML_PAGES } from '../../../../common/constants/locator'; import { useTrainedModelsApiService } from '../../services/ml_api_service/trained_models'; import { useTableSettings } from '../../data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings'; import { ExpandedRow } from './expanded_row'; diff --git a/x-pack/plugins/ml/public/application/model_management/model_actions.tsx b/x-pack/plugins/ml/public/application/model_management/model_actions.tsx index e9d323a8f6407..d25d25de412fc 100644 --- a/x-pack/plugins/ml/public/application/model_management/model_actions.tsx +++ b/x-pack/plugins/ml/public/application/model_management/model_actions.tsx @@ -20,12 +20,12 @@ import { getAnalysisType, type DataFrameAnalysisConfigType, } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useTrainedModelsApiService } from '../services/ml_api_service/trained_models'; import { getUserConfirmationProvider } from './force_stop_dialog'; import { useToastNotificationService } from '../services/toast_notification_service'; import { getUserInputModelDeploymentParamsProvider } from './deployment_setup'; import { useMlKibana, useMlLocator, useNavigateToPath } from '../contexts/kibana'; -import { ML_PAGES } from '../../../common/constants/locator'; import { isTestable, isDfaTrainedModel } from './test_models'; import type { ModelItem } from './models_list'; import { usePermissionCheck } from '../capabilities/check_capabilities'; diff --git a/x-pack/plugins/ml/public/application/model_management/model_link.tsx b/x-pack/plugins/ml/public/application/model_management/model_link.tsx index 7a1f3392476d7..6656b52e82d48 100644 --- a/x-pack/plugins/ml/public/application/model_management/model_link.tsx +++ b/x-pack/plugins/ml/public/application/model_management/model_link.tsx @@ -8,8 +8,8 @@ import { EuiLink } from '@elastic/eui'; import type { FC } from 'react'; import React from 'react'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLink } from '../contexts/kibana'; -import { ML_PAGES } from '../../../common/constants/locator'; export interface TrainedModelLinkProps { id: string; diff --git a/x-pack/plugins/ml/public/application/model_management/models_list.tsx b/x-pack/plugins/ml/public/application/model_management/models_list.tsx index a7d969d013a25..c3d339eaecda6 100644 --- a/x-pack/plugins/ml/public/application/model_management/models_list.tsx +++ b/x-pack/plugins/ml/public/application/model_management/models_list.tsx @@ -53,6 +53,7 @@ import { useStorage } from '@kbn/ml-local-storage'; import { dynamic } from '@kbn/shared-ux-utility'; import useMountedState from 'react-use/lib/useMountedState'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; +import { ML_PAGES } from '@kbn/ml-locator'; import { getModelStateColor, getModelDeploymentState } from './get_model_state'; import { ML_ELSER_CALLOUT_DISMISSED } from '../../../common/types/storage'; import { TechnicalPreviewBadge } from '../components/technical_preview_badge'; @@ -70,7 +71,6 @@ import type { TrainedModelStat, } from '../../../common/types/trained_models'; import { DeleteModelsModal } from './delete_models_modal'; -import { ML_PAGES } from '../../../common/constants/locator'; import { useTableSettings } from '../data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings'; import { useToastNotificationService } from '../services/toast_notification_service'; import { useFieldFormatter } from '../contexts/kibana/use_field_formatter'; diff --git a/x-pack/plugins/ml/public/application/notifications/components/notifications_list.tsx b/x-pack/plugins/ml/public/application/notifications/components/notifications_list.tsx index 399b880c6a331..1867fa24c3344 100644 --- a/x-pack/plugins/ml/public/application/notifications/components/notifications_list.tsx +++ b/x-pack/plugins/ml/public/application/notifications/components/notifications_list.tsx @@ -19,6 +19,7 @@ import useMount from 'react-use/lib/useMount'; import { usePageUrlState } from '@kbn/ml-url-state'; import type { ListingPageUrlState } from '@kbn/ml-url-state'; import { useTimefilter, useTimeRangeUpdates } from '@kbn/ml-date-picker'; +import { ML_PAGES } from '@kbn/ml-locator'; import { EntityFilter } from './entity_filter'; import { useMlNotifications } from '../../contexts/ml/ml_notifications_context'; import { ML_NOTIFICATIONS_MESSAGE_LEVEL } from '../../../../common/constants/notifications'; @@ -27,7 +28,6 @@ import { useToastNotificationService } from '../../services/toast_notification_s import { useFieldFormatter } from '../../contexts/kibana/use_field_formatter'; import { useRefresh } from '../../routing/use_refresh'; import { useTableSettings } from '../../data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings'; -import { ML_PAGES } from '../../../../common/constants/locator'; import type { MlNotificationMessageLevel, NotificationItem, diff --git a/x-pack/plugins/ml/public/application/overview/components/analytics_panel/actions.tsx b/x-pack/plugins/ml/public/application/overview/components/analytics_panel/actions.tsx index dd8cb3db16af0..8ef728324a3c2 100644 --- a/x-pack/plugins/ml/public/application/overview/components/analytics_panel/actions.tsx +++ b/x-pack/plugins/ml/public/application/overview/components/analytics_panel/actions.tsx @@ -14,10 +14,10 @@ import { getAnalysisType, type DataFrameAnalysisConfigType, } from '@kbn/ml-data-frame-analytics-utils'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLink, useMlLocator, useNavigateToPath } from '../../../contexts/kibana'; import type { DataFrameAnalyticsListRow } from '../../../data_frame_analytics/pages/analytics_management/components/analytics_list/common'; import { getViewLinkStatus } from '../../../data_frame_analytics/pages/analytics_management/components/action_view/get_view_link_status'; -import { ML_PAGES } from '../../../../../common/constants/locator'; interface Props { item: DataFrameAnalyticsListRow; diff --git a/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx b/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx index c94f594f548c5..a872fcd00790b 100644 --- a/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx +++ b/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx @@ -12,6 +12,7 @@ import { i18n } from '@kbn/i18n'; import { useStorage } from '@kbn/ml-local-storage'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ML_PAGES } from '@kbn/ml-locator'; import { type AnalyticStatsBarStats } from '../../../components/stats_bar'; import { OverviewStatsBar, @@ -23,7 +24,6 @@ import { AnalyticsTable } from './table'; import { useGetAnalytics } from '../../../data_frame_analytics/pages/analytics_management/services/analytics_service'; import type { DataFrameAnalyticsListRow } from '../../../data_frame_analytics/pages/analytics_management/components/analytics_list/common'; import { useMlLink } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { useRefresh } from '../../../routing/use_refresh'; import type { GetDataFrameAnalyticsStatsResponseError } from '../../../services/ml_api_service/data_frame_analytics'; import { AnalyticsEmptyPrompt } from '../../../data_frame_analytics/pages/analytics_management/components/empty_prompt'; diff --git a/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx b/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx index d46610a69483f..42e367af025ba 100644 --- a/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx +++ b/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/actions.tsx @@ -8,8 +8,8 @@ import { i18n } from '@kbn/i18n'; import type { Action } from '@elastic/eui/src/components/basic_table/action_types'; import { useTimefilter } from '@kbn/ml-date-picker'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLocator, useNavigateToPath } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import type { Group } from './anomaly_detection_panel'; export function useGroupActions(): Array> { diff --git a/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx b/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx index 5e17304fff1c4..e0981dee9746a 100644 --- a/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx +++ b/x-pack/plugins/ml/public/application/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx @@ -12,9 +12,9 @@ import { i18n } from '@kbn/i18n'; import { zipObject, groupBy } from 'lodash'; import { FormattedMessage } from '@kbn/i18n-react'; import { useStorage } from '@kbn/ml-local-storage'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { MlStorageKey, TMlStorageMapped } from '../../../../../common/types/storage'; import { ML_OVERVIEW_PANELS } from '../../../../../common/types/storage'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { OverviewStatsBar } from '../../../components/collapsible_panel/collapsible_panel'; import { CollapsiblePanel } from '../../../components/collapsible_panel'; import { useMlApi, useMlKibana, useMlLink } from '../../../contexts/kibana'; diff --git a/x-pack/plugins/ml/public/application/overview/overview_page.tsx b/x-pack/plugins/ml/public/application/overview/overview_page.tsx index c66bc6e1ea7e4..02798c5f9e618 100644 --- a/x-pack/plugins/ml/public/application/overview/overview_page.tsx +++ b/x-pack/plugins/ml/public/application/overview/overview_page.tsx @@ -12,8 +12,8 @@ import { EuiLink, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { mlTimefilterRefresh$, useTimefilter } from '@kbn/ml-date-picker'; import { useStorage } from '@kbn/ml-local-storage'; +import { ML_PAGES } from '@kbn/ml-locator'; import { OverviewStatsBar } from '../components/collapsible_panel/collapsible_panel'; -import { ML_PAGES } from '../../../common/constants/locator'; import type { MlStorageKey, TMlStorageMapped } from '../../../common/types/storage'; import { ML_OVERVIEW_PANELS } from '../../../common/types/storage'; import { CollapsiblePanel } from '../components/collapsible_panel'; diff --git a/x-pack/plugins/ml/public/application/routing/router.tsx b/x-pack/plugins/ml/public/application/routing/router.tsx index 522d62d09b000..1763486027a92 100644 --- a/x-pack/plugins/ml/public/application/routing/router.tsx +++ b/x-pack/plugins/ml/public/application/routing/router.tsx @@ -15,10 +15,10 @@ import type { AppMountParameters, ChromeStart, ChromeBreadcrumb } from '@kbn/cor import { EuiSkeletonText } from '@elastic/eui'; import { UrlStateProvider } from '@kbn/ml-url-state'; -import { MlNotificationsContextProvider } from '../contexts/ml/ml_notifications_context'; +import type { MlPages } from '@kbn/ml-locator'; +import { MlNotificationsContextProvider } from '../contexts/ml/ml_notifications_context'; import { MlPage } from '../components/ml_page'; -import type { MlPages } from '../../locator'; import { type RouteResolverContext } from './use_resolver'; // custom RouteProps making location non-optional diff --git a/x-pack/plugins/ml/public/application/routing/routes/aiops/change_point_detection.tsx b/x-pack/plugins/ml/public/application/routing/routes/aiops/change_point_detection.tsx index 13bdf1f77f756..0e0430890acbf 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/aiops/change_point_detection.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/aiops/change_point_detection.tsx @@ -10,8 +10,8 @@ import { i18n } from '@kbn/i18n'; import type { FC } from 'react'; import React from 'react'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { DataSourceContextProvider } from '../../../contexts/ml'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../..'; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/aiops/log_categorization.tsx b/x-pack/plugins/ml/public/application/routing/routes/aiops/log_categorization.tsx index 2804c120f21b6..8e989f60e33f6 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/aiops/log_categorization.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/aiops/log_categorization.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/aiops/log_rate_analysis.tsx b/x-pack/plugins/ml/public/application/routing/routes/aiops/log_rate_analysis.tsx index a4441821a97e0..2db42fff97d51 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/aiops/log_rate_analysis.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/aiops/log_rate_analysis.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { useLocation, Redirect } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx index d48efb079af34..8178ee3c57416 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx @@ -10,8 +10,8 @@ import React from 'react'; import { parse } from 'query-string'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { DataSourceContextProvider } from '../../../contexts/ml'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import { useMlApi } from '../../../contexts/kibana'; import { useMlKibana } from '../../../contexts/kibana'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_exploration.tsx b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_exploration.tsx index 269c18f9735ef..2feac79a494cf 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_exploration.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_exploration.tsx @@ -11,8 +11,8 @@ import { i18n } from '@kbn/i18n'; import { useUrlState } from '@kbn/ml-url-state'; import type { DataFrameAnalysisConfigType } from '@kbn/ml-data-frame-analytics-utils'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { basicResolvers } from '../../resolvers'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_jobs_list.tsx b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_jobs_list.tsx index cdfb854314a72..5d00148159829 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_jobs_list.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_jobs_list.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_map.tsx b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_map.tsx index e18a7e8d3b72d..723c708b71553 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_map.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_map.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_source_selection.tsx b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_source_selection.tsx index 7f8901499b8b9..b351043760c37 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_source_selection.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_source_selection.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_comparison.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_comparison.tsx index c9de2de9472a4..36d9495e3401b 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_comparison.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_comparison.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { DataSourceContextProvider } from '../../../contexts/ml'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute, PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_drift.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_drift.tsx index a59fbb195a8c4..43e9b412e9449 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_drift.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/data_drift.tsx @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import type { FC } from 'react'; import React from 'react'; +import { ML_PAGES } from '@kbn/ml-locator'; import { DataDriftIndexOrSearchRedirect, DataDriftIndexPatternsPicker, @@ -16,7 +17,6 @@ import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../..'; import type { PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { breadcrumbOnClickFactory, DATA_DRIFT_BREADCRUMB, diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/datavisualizer.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/datavisualizer.tsx index 9b3256b9623d1..9007363aaf8b5 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/datavisualizer.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/datavisualizer.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx index e56c65511860b..94858558b77fb 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/file_based.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx index 08043e4498857..ab493225fac7a 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/datavisualizer/index_based.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/explorer/explorer.tsx b/x-pack/plugins/ml/public/application/routing/routes/explorer/explorer.tsx index 648cceee7ce3b..ba7d1f0380a00 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/explorer/explorer.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/explorer/explorer.tsx @@ -11,8 +11,8 @@ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { basicResolvers } from '../../resolvers'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import { useMlKibana } from '../../../contexts/kibana'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/jobs_list.tsx b/x-pack/plugins/ml/public/application/routing/routes/jobs_list.tsx index 28a71b5e7c819..c977d4e690ddf 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/jobs_list.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/jobs_list.tsx @@ -15,7 +15,7 @@ import { useTimefilter, } from '@kbn/ml-date-picker'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../contexts/kibana'; import { DEFAULT_REFRESH_INTERVAL_MS } from '../../../../common/constants/jobs_list'; import type { MlRoute } from '../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/memory_usage.tsx b/x-pack/plugins/ml/public/application/routing/routes/memory_usage.tsx index 527e870557c68..43871681471be 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/memory_usage.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/memory_usage.tsx @@ -9,8 +9,9 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; + import { basicResolvers } from '../resolvers'; -import { ML_PAGES } from '../../../locator'; import type { NavigateToPath } from '../../contexts/kibana'; import type { MlRoute } from '../router'; import { createPath, PageLoader } from '../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/from_lens.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/from_lens.tsx index 74b61559d9f3f..242339a6a7e5e 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/from_lens.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/from_lens.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React from 'react'; import { Redirect } from 'react-router-dom'; import { parse } from 'query-string'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlKibana } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../locator'; import type { MlRoute, PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; import { useRouteResolver } from '../../use_resolver'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/from_map.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/from_map.tsx index 026f219e5104f..0e9b1004bbdbe 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/from_map.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/from_map.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React from 'react'; import { Redirect } from 'react-router-dom'; import { parse } from 'query-string'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlKibana } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../locator'; import type { MlRoute, PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; import { useRouteResolver } from '../../use_resolver'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx index 6252e54d6ae7e..cbcce8a858ced 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React from 'react'; import { Redirect } from 'react-router-dom'; import { parse } from 'query-string'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlKibana } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../locator'; import type { MlRoute, PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; import { useRouteResolver } from '../../use_resolver'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/index_or_search.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/index_or_search.tsx index d08ab910fdb26..cb0766584da04 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/index_or_search.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/index_or_search.tsx @@ -11,7 +11,7 @@ import { Redirect } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import { useMlKibana } from '../../../contexts/kibana'; import type { MlRoute, PageProps } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/job_type.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/job_type.tsx index ebcb6697fa6d6..442bc497d73d0 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/job_type.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/job_type.tsx @@ -9,8 +9,8 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { basicResolvers } from '../../resolvers'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/new_job.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/new_job.tsx index a224b1f504194..da3b449acd897 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/new_job.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/new_job.tsx @@ -8,7 +8,8 @@ import type { FC } from 'react'; import React from 'react'; import { Redirect } from 'react-router-dom'; -import { ML_PAGES } from '../../../../locator'; + +import { ML_PAGES } from '@kbn/ml-locator'; import type { MlRoute } from '../../router'; import { createPath } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/recognize.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/recognize.tsx index 035675e5ca3c1..9f1b52cf1ab61 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/recognize.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/recognize.tsx @@ -10,8 +10,8 @@ import type { FC } from 'react'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { basicResolvers } from '../../resolvers'; -import { ML_PAGES } from '../../../../locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import { useMlApi, useMlKibana, useNavigateToPath } from '../../../contexts/kibana'; import type { MlRoute, PageProps } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/new_job/wizard.tsx b/x-pack/plugins/ml/public/application/routing/routes/new_job/wizard.tsx index 248dcd6d84771..c912a6ce831f6 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/new_job/wizard.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/new_job/wizard.tsx @@ -11,6 +11,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { Redirect } from 'react-router-dom'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import { DataSourceContextProvider } from '../../../contexts/ml/data_source_context'; import type { NavigateToPath } from '../../../contexts/kibana'; import { useMlKibana } from '../../../contexts/kibana'; @@ -26,7 +27,6 @@ import { import { checkCreateJobsCapabilitiesResolver } from '../../../capabilities/check_capabilities'; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs'; import { useCreateAndNavigateToMlLink } from '../../../contexts/kibana/use_create_url'; -import { ML_PAGES } from '../../../../../common/constants/locator'; interface WizardPageProps extends PageProps { jobType: JOB_TYPE; diff --git a/x-pack/plugins/ml/public/application/routing/routes/notifications.tsx b/x-pack/plugins/ml/public/application/routing/routes/notifications.tsx index c162b9854c7c5..be80c31f227bb 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/notifications.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/notifications.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React, { Suspense } from 'react'; import { i18n } from '@kbn/i18n'; import { useTimefilter } from '@kbn/ml-date-picker'; -import { ML_PAGES } from '../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { createPath, PageLoader } from '../router'; import { useRouteResolver } from '../use_resolver'; import { getMlNodeCount } from '../../ml_nodes_check'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/overview.tsx b/x-pack/plugins/ml/public/application/routing/routes/overview.tsx index 4fec14bc41294..b358d2a3866b9 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/overview.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/overview.tsx @@ -10,7 +10,7 @@ import { useTimefilter } from '@kbn/ml-date-picker'; import type { FC } from 'react'; import React, { Suspense } from 'react'; import { Redirect } from 'react-router-dom'; -import { ML_PAGES } from '../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../contexts/kibana'; import { useEnabledFeatures } from '../../contexts/ml/serverless_context'; import { getMlNodeCount } from '../../ml_nodes_check'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_list.tsx b/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_list.tsx index 088c403378de0..0177892615739 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_list.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_list.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { useTimefilter } from '@kbn/ml-date-picker'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute, PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_new_edit.tsx b/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_new_edit.tsx index 61d5406871283..5ddb907cb74ca 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_new_edit.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/settings/calendar_new_edit.tsx @@ -10,13 +10,13 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { useTimefilter } from '@kbn/ml-date-picker'; import { dynamic } from '@kbn/shared-ux-utility'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute, PageProps } from '../../router'; import { createPath, PageLoader } from '../../router'; import { useRouteResolver } from '../../use_resolver'; import { usePermissionCheck } from '../../../capabilities/check_capabilities'; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { getMlNodeCount } from '../../../ml_nodes_check'; enum MODE { diff --git a/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list.tsx b/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list.tsx index 128d9845d41f9..a9dc9b5ca859b 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { useTimefilter } from '@kbn/ml-date-picker'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list_new_edit.tsx b/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list_new_edit.tsx index 763826e02552c..faec98d4ab7c9 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list_new_edit.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/settings/filter_list_new_edit.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { useTimefilter } from '@kbn/ml-date-picker'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { usePermissionCheck } from '../../../capabilities/check_capabilities'; import { getMlNodeCount } from '../../../ml_nodes_check/check_ml_nodes'; import type { NavigateToPath } from '../../../contexts/kibana'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/settings/settings.tsx b/x-pack/plugins/ml/public/application/routing/routes/settings/settings.tsx index 581594e0c4bc7..52b689e903fab 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/settings/settings.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/settings/settings.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { useTimefilter } from '@kbn/ml-date-picker'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/supplied_configurations/supplied_configurations_view.tsx b/x-pack/plugins/ml/public/application/routing/routes/supplied_configurations/supplied_configurations_view.tsx index 4709603de2d6c..1ea23789f7446 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/supplied_configurations/supplied_configurations_view.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/supplied_configurations/supplied_configurations_view.tsx @@ -11,7 +11,8 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; + import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/state_manager.tsx b/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/state_manager.tsx index fa1753a4342fc..32688c9b41392 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/state_manager.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/state_manager.tsx @@ -14,6 +14,7 @@ import { useUrlState } from '@kbn/ml-url-state'; import { useTimefilter } from '@kbn/ml-date-picker'; import type { IUiSettingsClient } from '@kbn/core/public'; import type { TimeRangeBounds } from '@kbn/ml-time-buckets'; +import type { TimeSeriesExplorerAppState } from '@kbn/ml-locator'; import { getViewableDetectors } from '../../../timeseriesexplorer/timeseriesexplorer_utils/get_viewable_detectors'; import { useNotifications } from '../../../contexts/kibana'; import type { MlJobWithTimeRange } from '../../../../../common/types/anomaly_detection_jobs'; @@ -29,7 +30,6 @@ import { TimeseriesexplorerNoJobsFound } from '../../../timeseriesexplorer/compo import { useTableInterval } from '../../../components/controls/select_interval'; import { useTableSeverity } from '../../../components/controls/select_severity'; import { useTimeSeriesExplorerUrlState } from '../../../timeseriesexplorer/hooks/use_timeseriesexplorer_url_state'; -import type { TimeSeriesExplorerAppState } from '../../../../../common/types/locator'; import { useJobSelectionFlyout } from '../../../contexts/ml/use_job_selection_flyout'; import { useRefresh } from '../../use_refresh'; import { TimeseriesexplorerNoChartData } from '../../../timeseriesexplorer/components/timeseriesexplorer_no_chart_data'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/timeseriesexplorer.tsx b/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/timeseriesexplorer.tsx index 14abe1b8029b7..2189cd26c79f2 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/timeseriesexplorer.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/timeseriesexplorer/timeseriesexplorer.tsx @@ -9,7 +9,7 @@ import type { FC } from 'react'; import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import { useMlApi, useUiSettings } from '../../../contexts/kibana'; import { getDateFormatTz } from '../../../explorer/explorer_utils'; diff --git a/x-pack/plugins/ml/public/application/routing/routes/trained_models/models_list.tsx b/x-pack/plugins/ml/public/application/routing/routes/trained_models/models_list.tsx index ebebb25671f5a..9776a95467cd0 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/trained_models/models_list.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/trained_models/models_list.tsx @@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { dynamic } from '@kbn/shared-ux-utility'; -import { ML_PAGES } from '../../../../locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { NavigateToPath } from '../../../contexts/kibana'; import type { MlRoute } from '../../router'; import { createPath, PageLoader } from '../../router'; diff --git a/x-pack/plugins/ml/public/application/routing/use_resolver.tsx b/x-pack/plugins/ml/public/application/routing/use_resolver.tsx index d65107410012b..2f966898d4412 100644 --- a/x-pack/plugins/ml/public/application/routing/use_resolver.tsx +++ b/x-pack/plugins/ml/public/application/routing/use_resolver.tsx @@ -8,13 +8,13 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { i18n } from '@kbn/i18n'; import useMount from 'react-use/lib/useMount'; +import { ML_PAGES } from '@kbn/ml-locator'; import { AccessDeniedCallout } from '../access_denied'; import { PLUGIN_ID } from '../../../common/constants/app'; import { useMlApi, useMlKibana, useMlLicenseInfo } from '../contexts/kibana'; import { type MlCapabilitiesKey } from '../../../common/types/capabilities'; import { usePermissionCheck } from '../capabilities/check_capabilities'; import type { ResolverResults, Resolvers } from './resolvers'; -import { ML_PAGES } from '../../../common/constants/locator'; export interface RouteResolverContext { initialized: boolean; diff --git a/x-pack/plugins/ml/public/application/settings/anomaly_detection_settings.tsx b/x-pack/plugins/ml/public/application/settings/anomaly_detection_settings.tsx index e5fce41df2e18..cf172cd1b5b8b 100644 --- a/x-pack/plugins/ml/public/application/settings/anomaly_detection_settings.tsx +++ b/x-pack/plugins/ml/public/application/settings/anomaly_detection_settings.tsx @@ -21,11 +21,11 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlApi } from '../contexts/kibana'; import { AnomalyDetectionSettingsContext } from './anomaly_detection_settings_context'; import { useToastNotificationService } from '../services/toast_notification_service'; -import { ML_PAGES } from '../../../common/constants/locator'; import { useCreateAndNavigateToMlLink } from '../contexts/kibana/use_create_url'; export const AnomalyDetectionSettings: FC = () => { diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js index 103d11821437f..bcd5e9d9f7d90 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.js @@ -25,7 +25,7 @@ import { EventsTable } from '../events_table'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useCreateAndNavigateToMlLink } from '../../../../contexts/kibana/use_create_url'; import { MlPageHeader } from '../../../../components/page_header'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.js index 51939aaba639a..cf68e97ce1b34 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.js @@ -18,7 +18,7 @@ import { NewEventModal } from './new_event_modal'; import { ImportModal } from './import_modal'; import { withKibana } from '@kbn/kibana-react-plugin/public'; import { GLOBAL_CALENDAR } from '../../../../../common/constants/calendars'; -import { ML_PAGES } from '../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { toastNotificationServiceProvider } from '../../../services/toast_notification_service'; import { HelpMenu } from '../../../components/help_menu'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.js b/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.js index e9240557d2a68..635a365d49283 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.js @@ -15,7 +15,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { GLOBAL_CALENDAR } from '../../../../../../common/constants/calendars'; import { useCreateAndNavigateToMlLink } from '../../../../contexts/kibana/use_create_url'; -import { ML_PAGES } from '../../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; export const CalendarsListTable = ({ calendarsList, diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.js b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.js index c203da50ce0bd..5bb843756a4b8 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.js @@ -31,7 +31,7 @@ import { EditFilterListToolbar } from './toolbar'; import { ItemsGrid } from '../../../components/items_grid'; import { isValidFilterListId, saveFilterList } from './utils'; import { toastNotificationServiceProvider } from '../../../services/toast_notification_service'; -import { ML_PAGES } from '../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; import { HelpMenu } from '../../../components/help_menu'; const DEFAULT_ITEMS_PER_PAGE = 50; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.js b/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.js index a97c70d8c1a2c..323e7f82497eb 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.js @@ -28,7 +28,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { DeleteFilterListModal } from '../components/delete_filter_list_modal'; import { useCreateAndNavigateToMlLink } from '../../../contexts/kibana/use_create_url'; -import { ML_PAGES } from '../../../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; function UsedByIcon({ usedBy }) { // Renders a tick or cross in the 'usedBy' column to indicate whether diff --git a/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations.tsx b/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations.tsx index f98502c1c5f89..26890e1cc790c 100644 --- a/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations.tsx +++ b/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations.tsx @@ -21,9 +21,9 @@ import { usePageUrlState, type PageUrlState } from '@kbn/ml-url-state'; import useMountedState from 'react-use/lib/useMountedState'; import useMount from 'react-use/lib/useMount'; import { isPopulatedObject } from '@kbn/ml-is-populated-object'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlKibana } from '../contexts/kibana'; import type { Module } from '../../../common/types/modules'; -import { ML_PAGES } from '../../../common/constants/locator'; import { LoadingIndicator } from '../components/loading_indicator'; import { filterModules } from './utils'; import { SuppliedConfigurationsFlyout } from './supplied_configurations_flyout'; diff --git a/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations_flyout/data_views_table.tsx b/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations_flyout/data_views_table.tsx index 53aa7d468e480..181442aa5c32c 100644 --- a/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations_flyout/data_views_table.tsx +++ b/x-pack/plugins/ml/public/application/supplied_configurations/supplied_configurations_flyout/data_views_table.tsx @@ -11,9 +11,9 @@ import { FormattedMessage } from '@kbn/i18n-react'; import React, { useCallback } from 'react'; import type { EuiTableFieldDataColumnType, EuiTableActionsColumnType } from '@elastic/eui'; import { EuiButtonEmpty, EuiInMemoryTable } from '@elastic/eui'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlKibana, useMlLocator } from '../../contexts/kibana'; -import { ML_PAGES } from '../../../../common/constants/locator'; import type { RecognizeModuleResult, RecognizeModuleResultDataView, diff --git a/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_no_jobs_found/timeseriesexplorer_no_jobs_found.tsx b/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_no_jobs_found/timeseriesexplorer_no_jobs_found.tsx index c2f52addb0b39..7e33b81624e71 100644 --- a/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_no_jobs_found/timeseriesexplorer_no_jobs_found.tsx +++ b/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_no_jobs_found/timeseriesexplorer_no_jobs_found.tsx @@ -13,8 +13,8 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiEmptyPrompt, EuiButton } from '@elastic/eui'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLink } from '../../../contexts/kibana'; -import { ML_PAGES } from '../../../../../common/constants/locator'; import { usePermissionCheck } from '../../../capabilities/check_capabilities'; import { mlNodesAvailable } from '../../../ml_nodes_check'; diff --git a/x-pack/plugins/ml/public/application/timeseriesexplorer/hooks/use_timeseriesexplorer_url_state.ts b/x-pack/plugins/ml/public/application/timeseriesexplorer/hooks/use_timeseriesexplorer_url_state.ts index 5093f07eb6e70..0884eb36c75c1 100644 --- a/x-pack/plugins/ml/public/application/timeseriesexplorer/hooks/use_timeseriesexplorer_url_state.ts +++ b/x-pack/plugins/ml/public/application/timeseriesexplorer/hooks/use_timeseriesexplorer_url_state.ts @@ -6,8 +6,8 @@ */ import { usePageUrlState } from '@kbn/ml-url-state'; -import type { TimeSeriesExplorerAppState } from '../../../../common/types/locator'; -import { ML_PAGES } from '../../../../common/constants/locator'; +import type { TimeSeriesExplorerAppState } from '@kbn/ml-locator'; +import { ML_PAGES } from '@kbn/ml-locator'; interface TimeSeriesExplorerPageUrlState { pageKey: typeof ML_PAGES.SINGLE_METRIC_VIEWER; diff --git a/x-pack/plugins/ml/public/application/util/chart_utils.js b/x-pack/plugins/ml/public/application/util/chart_utils.js index 19b53177d6868..80c4597b7ab28 100644 --- a/x-pack/plugins/ml/public/application/util/chart_utils.js +++ b/x-pack/plugins/ml/public/application/util/chart_utils.js @@ -10,7 +10,7 @@ import { getAnomalyScoreExplanationImpactValue } from '@kbn/ml-anomaly-utils'; import { calculateTextWidth } from './string_utils'; import moment from 'moment'; import { CHART_TYPE } from '../explorer/explorer_constants'; -import { ML_PAGES } from '../../../common/constants/locator'; +import { ML_PAGES } from '@kbn/ml-locator'; export const LINE_CHART_ANOMALY_RADIUS = 7; export const SCHEDULED_EVENT_SYMBOL_HEIGHT = 5; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_initializer.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_initializer.tsx index 862d0425523aa..a720a73bf3325 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_initializer.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_initializer.tsx @@ -22,10 +22,10 @@ import { EuiFlexGroup, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { AnomalyChartsEmbeddableState } from '..'; import { DEFAULT_MAX_SERIES_TO_PLOT } from '../../application/services/anomaly_explorer_charts_service'; import { JobSelectorControl } from '../../alerting/job_selector'; -import { ML_PAGES } from '../../../common/constants/locator'; import { getDefaultExplorerChartsPanelTitle } from './utils'; import { useMlLink } from '../../application/contexts/kibana'; import { getJobSelectionErrors } from '../utils'; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_react_container.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_react_container.tsx index aefdac533f859..4e33babee0061 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_react_container.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_charts/anomaly_charts_react_container.tsx @@ -22,6 +22,9 @@ import { import { TimeBuckets } from '@kbn/ml-time-buckets'; import useObservable from 'react-use/lib/useObservable'; import type { TimeRange } from '@kbn/es-query'; +import { ML_APP_LOCATOR } from '@kbn/ml-locator'; +import type { MlLocatorParams } from '@kbn/ml-locator'; + import type { AnomalyChartsEmbeddableOverridableState, AnomalyChartsEmbeddableServices, @@ -31,10 +34,8 @@ import type { import type { AnomaliesTableData, ExplorerJob } from '../../application/explorer/explorer_utils'; import { ExplorerAnomaliesContainer } from '../../application/explorer/explorer_charts/explorer_anomalies_container'; -import { ML_APP_LOCATOR } from '../../../common/constants/locator'; import { optionValueToThreshold } from '../../application/components/controls/select_severity/select_severity'; import { EXPLORER_ENTITY_FIELD_SELECTION_TRIGGER } from '../../ui_actions/triggers'; -import type { MlLocatorParams } from '../../../common/types/locator'; import { useAnomalyChartsData } from './use_anomaly_charts_data'; import { useDateFormatTz, loadAnomaliesTableData } from '../../application/explorer/explorer_utils'; import { useMlJobService } from '../../application/services/job_service'; diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx index 21df1ad4f18bb..dc31a92cdb573 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx @@ -24,8 +24,8 @@ import { import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import useMountedState from 'react-use/lib/useMountedState'; +import { ML_PAGES } from '@kbn/ml-locator'; import { useMlLink } from '../../application/contexts/kibana'; -import { ML_PAGES } from '../../../common/constants/locator'; import type { MlApi } from '../../application/services/ml_api_service'; import { extractInfluencers } from '../../../common/util/job_utils'; import { JobSelectorControl } from '../../alerting/job_selector'; diff --git a/x-pack/plugins/ml/public/embeddables/job_creation/common/job_details.tsx b/x-pack/plugins/ml/public/embeddables/job_creation/common/job_details.tsx index 0e843da22a74b..52de264f81103 100644 --- a/x-pack/plugins/ml/public/embeddables/job_creation/common/job_details.tsx +++ b/x-pack/plugins/ml/public/embeddables/job_creation/common/job_details.tsx @@ -32,6 +32,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { extractErrorMessage } from '@kbn/ml-error-utils'; import type { TimeRange } from '@kbn/es-query'; import { JOB_ID_MAX_LENGTH } from '@kbn/ml-validators'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; import type { QuickLensJobCreator } from '../../../application/jobs/new_job/job_from_lens'; import type { LayerResult } from '../../../application/jobs/new_job/job_from_lens'; @@ -39,7 +40,6 @@ import type { CreateState } from '../../../application/jobs/new_job/job_from_das import { JOB_TYPE, DEFAULT_BUCKET_SPAN } from '../../../../common/constants/new_job'; import { basicJobValidation } from '../../../../common/util/job_utils'; import { invalidTimeIntervalMessage } from '../../../application/jobs/new_job/common/job_validator/util'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../../../common/constants/locator'; import { useMlFromLensKibanaContext } from './context'; export interface CreateADJobParams { diff --git a/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_embeddable_factory.tsx b/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_embeddable_factory.tsx index 8f81be21a8ccb..dd86d7b6bbe9f 100644 --- a/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_embeddable_factory.tsx +++ b/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_embeddable_factory.tsx @@ -18,7 +18,7 @@ import { useStateFromPublishingSubject, } from '@kbn/presentation-publishing'; import { BehaviorSubject, Subscription } from 'rxjs'; -import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '..'; +import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { MlPluginStart, MlStartDependencies } from '../../plugin'; import type { SingleMetricViewerRuntimeState, diff --git a/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_initializer.tsx b/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_initializer.tsx index c14bfc1cb1744..70b80475dc5a7 100644 --- a/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_initializer.tsx +++ b/x-pack/plugins/ml/public/embeddables/single_metric_viewer/single_metric_viewer_initializer.tsx @@ -26,9 +26,9 @@ import useMountedState from 'react-use/lib/useMountedState'; import { extractErrorMessage } from '@kbn/ml-error-utils'; import type { MlJob } from '@elastic/elasticsearch/lib/api/types'; import type { TimeRangeBounds } from '@kbn/ml-time-buckets'; +import { ML_PAGES } from '@kbn/ml-locator'; import type { MlApi } from '../../application/services/ml_api_service'; import type { SingleMetricViewerEmbeddableInput } from '..'; -import { ML_PAGES } from '../../../common/constants/locator'; import { SeriesControls } from '../../application/timeseriesexplorer/components/series_controls'; import { APP_STATE_ACTION, diff --git a/x-pack/plugins/ml/public/embeddables/types.ts b/x-pack/plugins/ml/public/embeddables/types.ts index 1bcb0f9ae3579..b70263c4d8fbc 100644 --- a/x-pack/plugins/ml/public/embeddables/types.ts +++ b/x-pack/plugins/ml/public/embeddables/types.ts @@ -23,6 +23,11 @@ import type { SerializedTitles, } from '@kbn/presentation-publishing'; import { type BehaviorSubject } from 'rxjs'; +import type { + AnomalyExplorerChartsEmbeddableType, + AnomalySwimLaneEmbeddableType, + MlEmbeddableTypes, +} from '@kbn/ml-embeddables'; import type { JobId } from '../../common/types/anomaly_detection_jobs'; import type { MlDependencies } from '../application/app'; import type { MlCapabilitiesService } from '../application/capabilities/check_capabilities'; @@ -37,11 +42,6 @@ import type { MlResultsService } from '../application/services/results_service'; import type { MlTimeSeriesSearchService } from '../application/timeseriesexplorer/timeseriesexplorer_utils/time_series_search_service'; import type { TimeSeriesExplorerService } from '../application/util/time_series_explorer_service'; import type { ToastNotificationService } from '../application/services/toast_notification_service'; -import type { - AnomalyExplorerChartsEmbeddableType, - AnomalySwimLaneEmbeddableType, - MlEmbeddableTypes, -} from './constants'; export type { AnomalySwimLaneEmbeddableState, diff --git a/x-pack/plugins/ml/public/index.ts b/x-pack/plugins/ml/public/index.ts index 92d0bb1ca2107..59082241cba5d 100755 --- a/x-pack/plugins/ml/public/index.ts +++ b/x-pack/plugins/ml/public/index.ts @@ -35,8 +35,5 @@ export type { DataRecognizerConfigResponse } from '../common/types/modules'; export type { AnomalySwimLaneEmbeddableApi, AnomalySwimLaneEmbeddableState } from './embeddables'; -export type { MlLocator } from './locator'; -export { useMlHref, ML_PAGES, MlLocatorDefinition } from './locator'; - export { MLJobsAwaitingNodeWarning } from './application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared'; export { MlNodeAvailableWarningShared } from './application/components/node_available_warning'; diff --git a/x-pack/plugins/ml/public/locator/index.ts b/x-pack/plugins/ml/public/locator/index.ts deleted file mode 100644 index 7a37805f1f36d..0000000000000 --- a/x-pack/plugins/ml/public/locator/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export { ML_PAGES, type MlPages } from '../../common/constants/locator'; -export * from './ml_locator'; -export { useMlHref } from './use_ml_href'; diff --git a/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx b/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx index fdc4f532b8a4f..42c96eb47f42c 100644 --- a/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx +++ b/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx @@ -16,7 +16,7 @@ import type { VectorLayerDescriptor, VectorStylePropertiesDescriptor, } from '@kbn/maps-plugin/common/descriptor_types'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../common/constants/locator'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; import { CUSTOM_COLOR_RAMP } from './util'; import { CreateAnomalySourceEditor } from './create_anomaly_source_editor'; import type { AnomalySourceDescriptor } from './anomaly_source'; diff --git a/x-pack/plugins/ml/public/maps/anomaly_source.tsx b/x-pack/plugins/ml/public/maps/anomaly_source.tsx index c426cdcd78919..c249d02ed1858 100644 --- a/x-pack/plugins/ml/public/maps/anomaly_source.tsx +++ b/x-pack/plugins/ml/public/maps/anomaly_source.tsx @@ -26,12 +26,12 @@ import type { Attribution, ImmutableSourceProperty } from '@kbn/maps-plugin/publ import type { SourceEditorArgs } from '@kbn/maps-plugin/public'; import type { DataRequest } from '@kbn/maps-plugin/public'; import type { GetFeatureActionsArgs, IVectorSource, SourceStatus } from '@kbn/maps-plugin/public'; +import { ML_PAGES } from '@kbn/ml-locator'; import { AnomalySourceField, AnomalySourceTooltipProperty, ANOMALY_SOURCE_FIELDS, } from './anomaly_source_field'; -import { ML_PAGES } from '../../common/constants/locator'; import type { MlAnomalyLayersType } from './util'; import { getResultsForJobId, ML_ANOMALY_LAYERS } from './util'; import { UpdateAnomalySourceEditor } from './update_anomaly_source_editor'; diff --git a/x-pack/plugins/ml/public/maps/anomaly_source_factory.ts b/x-pack/plugins/ml/public/maps/anomaly_source_factory.ts index 60390e030a61b..4e86fd650db94 100644 --- a/x-pack/plugins/ml/public/maps/anomaly_source_factory.ts +++ b/x-pack/plugins/ml/public/maps/anomaly_source_factory.ts @@ -9,9 +9,9 @@ import type { StartServicesAccessor } from '@kbn/core/public'; import { SOURCE_TYPES } from '@kbn/maps-plugin/common'; import type { LocatorPublic } from '@kbn/share-plugin/common'; import type { SerializableRecord } from '@kbn/utility-types'; +import { ML_APP_LOCATOR } from '@kbn/ml-locator'; import { HttpService } from '../application/services/http_service'; import type { MlPluginStart, MlStartDependencies } from '../plugin'; -import { ML_APP_LOCATOR } from '../../common/constants/locator'; import type { MlApi } from '../application/services/ml_api_service'; export class AnomalySourceFactory { diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index be6e0c3305230..f752241adb8fc 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -52,11 +52,10 @@ import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/ import type { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public'; import type { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common'; import { ENABLE_ESQL } from '@kbn/esql-utils'; +import { MlLocatorDefinition, type MlLocator, type MlLocatorParams } from '@kbn/ml-locator'; import type { MlSharedServices } from './application/services/get_shared_ml_services'; import { getMlSharedServices } from './application/services/get_shared_ml_services'; import { registerManagementSection } from './application/management'; -import type { MlLocatorParams } from './locator'; -import { MlLocatorDefinition, type MlLocator } from './locator'; import { registerHomeFeature } from './register_home_feature'; import { isFullLicense, isMlEnabled } from '../common/license'; import { diff --git a/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts b/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts index 784c8a87dcc6f..dc9ec2f90df1a 100644 --- a/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts +++ b/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts @@ -7,10 +7,10 @@ import { i18n } from '@kbn/i18n'; import type { LinkId } from '@kbn/deeplinks-ml'; +import type { AppDeepLink } from '@kbn/core/public'; +import { ML_PAGES } from '@kbn/ml-locator'; -import { type AppDeepLink } from '@kbn/core/public'; import type { MlCapabilities } from '../../../common/types/capabilities'; -import { ML_PAGES } from '../../../common/constants/locator'; function createDeepLinks( mlCapabilities: MlCapabilities, diff --git a/x-pack/plugins/ml/public/ui_actions/create_single_metric_viewer.tsx b/x-pack/plugins/ml/public/ui_actions/create_single_metric_viewer.tsx index 721f830e01627..7dbcec1383746 100644 --- a/x-pack/plugins/ml/public/ui_actions/create_single_metric_viewer.tsx +++ b/x-pack/plugins/ml/public/ui_actions/create_single_metric_viewer.tsx @@ -10,10 +10,10 @@ import type { PresentationContainer } from '@kbn/presentation-containers'; import type { EmbeddableApiContext } from '@kbn/presentation-publishing'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; +import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import { HttpService } from '../application/services/http_service'; import type { MlApi } from '../application/services/ml_api_service'; import { ML_APP_NAME, PLUGIN_ICON, PLUGIN_ID } from '../../common/constants/app'; -import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '../embeddables'; import type { SingleMetricViewerEmbeddableApi } from '../embeddables/types'; import type { MlCoreSetup } from '../plugin'; diff --git a/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx b/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx index 195309b4e0c5f..3f6f31e577aa6 100644 --- a/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx @@ -14,8 +14,7 @@ import { apiIsOfType } from '@kbn/presentation-publishing'; import type { UiActionsActionDefinition } from '@kbn/ui-actions-plugin/public'; import type { SerializableRecord } from '@kbn/utility-types'; import { ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; -import { ML_APP_LOCATOR } from '../../common/constants/locator'; -import type { ExplorerAppState } from '../../common/types/locator'; +import { ML_APP_LOCATOR, type ExplorerAppState } from '@kbn/ml-locator'; import type { AppStateSelectedCells } from '../application/explorer/explorer_utils'; import type { AnomalyChartsApi, AnomalyChartsEmbeddableApi } from '../embeddables'; import type { AnomalySwimLaneEmbeddableApi } from '../embeddables/anomaly_swimlane/types'; diff --git a/x-pack/plugins/ml/public/ui_actions/open_in_single_metric_viewer_action.tsx b/x-pack/plugins/ml/public/ui_actions/open_in_single_metric_viewer_action.tsx index da3255c765c3b..254813744205c 100644 --- a/x-pack/plugins/ml/public/ui_actions/open_in_single_metric_viewer_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/open_in_single_metric_viewer_action.tsx @@ -12,9 +12,9 @@ import { IncompatibleActionError, type UiActionsActionDefinition, } from '@kbn/ui-actions-plugin/public'; -import { ML_APP_LOCATOR, ML_PAGES } from '../../common/constants/locator'; +import { ML_APP_LOCATOR, ML_PAGES } from '@kbn/ml-locator'; +import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '@kbn/ml-embeddables'; import type { SingleMetricViewerEmbeddableApi } from '../embeddables'; -import { ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE } from '../embeddables'; import type { MlCoreSetup } from '../plugin'; import { getEmbeddableTimeRange } from './get_embeddable_time_range'; diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index b625562ab2674..2718a75436015 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -131,6 +131,8 @@ "@kbn/json-schemas", "@kbn/ml-field-stats-flyout", "@kbn/ml-parse-interval", - "@kbn/ml-validators" + "@kbn/ml-validators", + "@kbn/ml-embeddables", + "@kbn/ml-locator" ] } diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx index af5ec49635db0..6c9e2b7426889 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx @@ -7,7 +7,7 @@ import React, { ReactNode } from 'react'; import { EuiLink } from '@elastic/eui'; -import { useMlHref, ML_PAGES } from '@kbn/ml-plugin/public'; +import { useMlHref, ML_PAGES } from '@kbn/ml-locator'; import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params'; import { DEFAULT_REFRESH_INTERVAL } from '../../date_picker/apm_date_picker'; @@ -45,7 +45,7 @@ export function useExplorerHref({ jobId }: { jobId: string }) { rangeTo = 'now', } = urlParams; - const href = useMlHref(ml, core.http.basePath.get(), { + const href = useMlHref(ml?.locator, core.http.basePath.get(), { page: ML_PAGES.ANOMALY_EXPLORER, pageState: { jobIds: [jobId], diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx index 122e790efb4c6..3e462cbede507 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx @@ -7,7 +7,7 @@ import React, { ReactNode } from 'react'; import { EuiLink } from '@elastic/eui'; -import { useMlHref, ML_PAGES } from '@kbn/ml-plugin/public'; +import { useMlHref, ML_PAGES } from '@kbn/ml-locator'; import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params'; import { DEFAULT_REFRESH_INTERVAL } from '../../date_picker/apm_date_picker'; @@ -71,7 +71,7 @@ function useSingleMetricHref({ } : {}; - const href = useMlHref(ml, core.http.basePath.get(), { + const href = useMlHref(ml?.locator, core.http.basePath.get(), { page: ML_PAGES.SINGLE_METRIC_VIEWER, pageState: { jobIds: [jobId], diff --git a/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx b/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx index 961ac7c733e50..173d7d9e92ff7 100644 --- a/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx +++ b/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_context.tsx @@ -13,7 +13,7 @@ import { NodeLogsLocatorParams, TraceLogsLocatorParams, } from '@kbn/logs-shared-plugin/common'; -import { MlLocatorDefinition } from '@kbn/ml-plugin/public'; +import { MlLocatorDefinition } from '@kbn/ml-locator'; import { apmEnableProfilingIntegration } from '@kbn/observability-plugin/common'; import { createObservabilityRuleTypeRegistryMock, diff --git a/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_storybook.tsx b/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_storybook.tsx index 14d8d4404a719..5730fa20af4f3 100644 --- a/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_storybook.tsx +++ b/x-pack/plugins/observability_solution/apm/public/context/apm_plugin/mock_apm_plugin_storybook.tsx @@ -7,7 +7,7 @@ import { CoreStart } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; -import { MlLocatorDefinition } from '@kbn/ml-plugin/public'; +import { MlLocatorDefinition } from '@kbn/ml-locator'; import { enableInspectEsQueries } from '@kbn/observability-plugin/common'; import { UI_SETTINGS } from '@kbn/observability-shared-plugin/public/hooks/use_kibana_ui_settings'; import { UrlService } from '@kbn/share-plugin/common/url_service'; diff --git a/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts b/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts index c5b9b0dba5a3a..115d9088397ba 100644 --- a/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts +++ b/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ML_PAGES, useMlHref } from '@kbn/ml-plugin/public'; +import { ML_PAGES, useMlHref } from '@kbn/ml-locator'; import { useApmPluginContext } from '../context/apm_plugin/use_apm_plugin_context'; import { useLegacyUrlParams } from '../context/url_params_context/use_url_params'; @@ -23,7 +23,7 @@ export function useMlManageJobsHref({ jobId }: { jobId?: string } = {}) { rangeTo = 'now', } = urlParams; - const mlADLink = useMlHref(ml, core.http.basePath.get(), { + const mlADLink = useMlHref(ml?.locator, core.http.basePath.get(), { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, pageState: { groupIds: ['apm'], diff --git a/x-pack/plugins/observability_solution/apm/tsconfig.json b/x-pack/plugins/observability_solution/apm/tsconfig.json index 9195c2547a71a..0f1ba7bc79f5d 100644 --- a/x-pack/plugins/observability_solution/apm/tsconfig.json +++ b/x-pack/plugins/observability_solution/apm/tsconfig.json @@ -131,6 +131,7 @@ "@kbn/serverless", "@kbn/aiops-log-rate-analysis", "@kbn/router-utils", + "@kbn/ml-locator", ], "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx index e1db34f31a5e0..d96b58fb4ab36 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx @@ -13,7 +13,8 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import useInterval from 'react-use/lib/useInterval'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { MLJobsAwaitingNodeWarning, ML_PAGES, useMlHref } from '@kbn/ml-plugin/public'; +import { MLJobsAwaitingNodeWarning } from '@kbn/ml-plugin/public'; +import { ML_PAGES, useMlHref } from '@kbn/ml-locator'; import { useTrackPageview } from '@kbn/observability-shared-plugin/public'; import { useLogViewContext } from '@kbn/logs-shared-plugin/public'; import { logEntryCategoriesJobType } from '../../../../common/log_analysis'; @@ -196,7 +197,7 @@ export const LogEntryCategoriesResultsContent: React.FunctionComponent< autoRefresh.isPaused ? null : autoRefresh.interval ); - const analyzeInMlLink = useMlHref(ml, http.basePath.get(), { + const analyzeInMlLink = useMlHref(ml?.locator, http.basePath.get(), { page: ML_PAGES.ANOMALY_EXPLORER, pageState: { jobIds: [jobIds[logEntryCategoriesJobType]], diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx index 088f54a149974..1f194dbd1e0ce 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx @@ -9,7 +9,7 @@ import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; import moment from 'moment'; import { i18n } from '@kbn/i18n'; import React, { useCallback } from 'react'; -import { useMlHref, ML_PAGES } from '@kbn/ml-plugin/public'; +import { useMlHref, ML_PAGES } from '@kbn/ml-locator'; import { shouldHandleLinkEvent } from '@kbn/observability-shared-plugin/public'; import { useKibanaContextForPlugin } from '../../../../../hooks/use_kibana'; import { TimeRange } from '../../../../../../common/time/time_range'; @@ -26,7 +26,7 @@ export const AnalyzeCategoryDatasetInMlAction: React.FunctionComponent<{ } = useKibanaContextForPlugin(); const viewAnomalyInMachineLearningLink = useMlHref( - ml, + ml?.locator, http.basePath.get(), { page: ML_PAGES.SINGLE_METRIC_VIEWER, diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx index 6c545beb4b9cd..fe254560ea823 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx @@ -9,7 +9,7 @@ import React, { useMemo, useCallback, useState } from 'react'; import moment from 'moment'; import { encode } from '@kbn/rison'; import { i18n } from '@kbn/i18n'; -import { useMlHref, ML_PAGES } from '@kbn/ml-plugin/public'; +import { useMlHref, ML_PAGES } from '@kbn/ml-locator'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; import { useLinkProps, shouldHandleLinkEvent } from '@kbn/observability-shared-plugin/public'; import { @@ -122,7 +122,7 @@ export const LogEntryExampleMessage: React.FunctionComponent = ({ }, }); - const viewAnomalyInMachineLearningLink = useMlHref(ml, http.basePath.get(), { + const viewAnomalyInMachineLearningLink = useMlHref(ml?.locator, http.basePath.get(), { page: ML_PAGES.SINGLE_METRIC_VIEWER, pageState: { jobIds: [anomaly.jobId], diff --git a/x-pack/plugins/observability_solution/infra/tsconfig.json b/x-pack/plugins/observability_solution/infra/tsconfig.json index 45a03b23b4b9b..1f2a1c1053862 100644 --- a/x-pack/plugins/observability_solution/infra/tsconfig.json +++ b/x-pack/plugins/observability_solution/infra/tsconfig.json @@ -109,7 +109,10 @@ "@kbn/core-analytics-browser", "@kbn/observability-alerting-rule-utils", "@kbn/core-application-browser", - "@kbn/shared-ux-page-no-data-types" + "@kbn/shared-ux-page-no-data-types", + "@kbn/ml-ui-actions", + "@kbn/ml-embeddables", + "@kbn/ml-locator" ], "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/search_inference_endpoints/public/hooks/use_trained_model_stats.ts b/x-pack/plugins/search_inference_endpoints/public/hooks/use_trained_model_stats.ts index 57b643b78dc3a..c67cc5f791385 100644 --- a/x-pack/plugins/search_inference_endpoints/public/hooks/use_trained_model_stats.ts +++ b/x-pack/plugins/search_inference_endpoints/public/hooks/use_trained_model_stats.ts @@ -6,7 +6,7 @@ */ import { useQuery } from '@tanstack/react-query'; -import { InferenceStatsResponse } from '@kbn/ml-plugin/public/application/services/ml_api_service/trained_models'; +import type { InferenceStatsResponse } from '@kbn/ml-plugin/public/application/services/ml_api_service/trained_models'; import { useKibana } from './use_kibana'; import { TRAINED_MODEL_STATS_QUERY_KEY } from '../../common/constants'; diff --git a/x-pack/plugins/search_inference_endpoints/public/types.ts b/x-pack/plugins/search_inference_endpoints/public/types.ts index 6ac241fbe87b0..9ee206ea1b4db 100644 --- a/x-pack/plugins/search_inference_endpoints/public/types.ts +++ b/x-pack/plugins/search_inference_endpoints/public/types.ts @@ -8,7 +8,7 @@ import type { ConsolePluginStart } from '@kbn/console-plugin/public'; import { HttpStart } from '@kbn/core-http-browser'; import { AppMountParameters } from '@kbn/core/public'; -import { MlPluginStart } from '@kbn/ml-plugin/public'; +import type { MlPluginStart } from '@kbn/ml-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public'; import React from 'react'; import type { App } from './components/app'; diff --git a/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.test.tsx b/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.test.tsx index 28d70edcce46a..a10c5117dd1ef 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.test.tsx @@ -11,7 +11,7 @@ import { mockAnomalies } from '../mock'; import { cloneDeep } from 'lodash/fp'; import { ExplorerLink } from './create_explorer_link'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public/context'; -import { MlLocatorDefinition } from '@kbn/ml-plugin/public/locator'; +import { MlLocatorDefinition } from '@kbn/ml-locator'; import { MockUrlService } from '@kbn/share-plugin/common/mocks'; describe('create_explorer_link', () => { diff --git a/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_host_table.test.tsx b/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_host_table.test.tsx index 13139c3a369d4..2406ecbfcafc8 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_host_table.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_host_table.test.tsx @@ -15,7 +15,7 @@ import { hasMlUserPermissions } from '../../../../../common/machine_learning/has import { fireEvent, render } from '@testing-library/react'; import { useInstalledSecurityJobNameById } from '../hooks/use_installed_security_jobs'; import { mockAnomalies } from '../mock'; -import { useMlHref } from '@kbn/ml-plugin/public'; +import { useMlHref } from '@kbn/ml-locator'; jest.mock('../../../containers/query_toggle'); jest.mock('../anomaly/use_anomalies_table_data'); diff --git a/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_network_table.test.tsx b/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_network_table.test.tsx index f69d6c212eb55..a661d3e1a8e74 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_network_table.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_network_table.test.tsx @@ -16,7 +16,7 @@ import { FlowTarget } from '../../../../../common/search_strategy'; import { fireEvent, render } from '@testing-library/react'; import { mockAnomalies } from '../mock'; import { useInstalledSecurityJobNameById } from '../hooks/use_installed_security_jobs'; -import { useMlHref } from '@kbn/ml-plugin/public'; +import { useMlHref } from '@kbn/ml-locator'; jest.mock('../../../containers/query_toggle'); jest.mock('../anomaly/use_anomalies_table_data'); diff --git a/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_user_table.test.tsx b/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_user_table.test.tsx index c4384979801c2..db04d625e7652 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_user_table.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/tables/anomalies_user_table.test.tsx @@ -14,7 +14,7 @@ import { hasMlUserPermissions } from '../../../../../common/machine_learning/has import { fireEvent, render } from '@testing-library/react'; import { useInstalledSecurityJobNameById } from '../hooks/use_installed_security_jobs'; import { mockAnomalies } from '../mock'; -import { useMlHref } from '@kbn/ml-plugin/public'; +import { useMlHref } from '@kbn/ml-locator'; jest.mock('../../../containers/query_toggle'); jest.mock('../anomaly/use_anomalies_table_data'); diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx index 8426ccb39e0f7..e692bb2edeabe 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx @@ -19,7 +19,7 @@ import { } from '@elastic/eui'; import styled from 'styled-components'; -import { useMlHref, ML_PAGES } from '@kbn/ml-plugin/public'; +import { useMlHref, ML_PAGES } from '@kbn/ml-locator'; import { PopoverItems } from '../../popover_items'; import { useBasePath, useKibana } from '../../../lib/kibana'; import * as i18n from './translations'; @@ -48,7 +48,7 @@ const JobName = ({ id, name, description, basePath }: JobNameProps) => { } = useKibana(); const jobUrl = useMlHref( - ml, + ml?.locator, basePath, { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, @@ -194,7 +194,7 @@ export const NoItemsMessage = React.memo(({ basePath }: { basePath: string }) => services: { ml }, } = useKibana(); - const createNewAnomalyDetectionJoUrl = useMlHref(ml, basePath, { + const createNewAnomalyDetectionJoUrl = useMlHref(ml?.locator, basePath, { page: ML_PAGES.ANOMALY_DETECTION_CREATE_JOB_SELECT_INDEX, }); diff --git a/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts b/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts index 07a9220b3dfa4..5ebb5e7231cc2 100644 --- a/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts +++ b/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts @@ -36,7 +36,7 @@ import { } from '../../../../common/constants'; import type { StartServices } from '../../../types'; import { createSecuritySolutionStorageMock } from '../../mock/mock_local_storage'; -import { MlLocatorDefinition } from '@kbn/ml-plugin/public'; +import { MlLocatorDefinition } from '@kbn/ml-locator'; import type { EuiTheme } from '@kbn/kibana-react-plugin/common'; import { MockUrlService } from '@kbn/share-plugin/common/mocks'; import { fleetMock } from '@kbn/fleet-plugin/public/mocks'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx index cbdddae858085..453ff46746cf8 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx @@ -9,7 +9,7 @@ import React, { memo } from 'react'; import styled from 'styled-components'; import { EuiLink } from '@elastic/eui'; -import { ML_PAGES, useMlHref } from '@kbn/ml-plugin/public'; +import { ML_PAGES, useMlHref } from '@kbn/ml-locator'; import { useKibana } from '../../../../common/lib/kibana'; const StyledJobEuiLInk = styled(EuiLink)` @@ -26,7 +26,7 @@ const MlJobLinkComponent: React.FC = ({ jobId, jobName }) => { services: { http, ml }, } = useKibana(); const jobUrl = useMlHref( - ml, + ml?.locator, http.basePath.get(), { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.test.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.test.tsx index 8c511ad19fe17..dd4002f05e293 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.test.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.test.tsx @@ -53,8 +53,8 @@ jest.mock('../../../common/components/ml/anomaly/use_anomalies_search', () => { }; }); -jest.mock('@kbn/ml-plugin/public', () => { - const original = jest.requireActual('@kbn/ml-plugin/public'); +jest.mock('@kbn/ml-locator', () => { + const original = jest.requireActual('@kbn/ml-locator'); return { ...original, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx index 5102cb40124e2..23a769374a65b 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx @@ -14,7 +14,8 @@ import { EuiSpacer, } from '@elastic/eui'; -import { MLJobsAwaitingNodeWarning, ML_PAGES, useMlHref } from '@kbn/ml-plugin/public'; +import { MLJobsAwaitingNodeWarning } from '@kbn/ml-plugin/public'; +import { ML_PAGES, useMlHref } from '@kbn/ml-locator'; import { FormattedMessage } from '@kbn/i18n-react'; import { HeaderSection } from '../../../common/components/header_section'; import { useQueryToggle } from '../../../common/containers/query_toggle'; @@ -55,7 +56,7 @@ export const EntityAnalyticsAnomalies = () => { services: { ml, http, docLinks }, } = useKibana(); - const jobsUrl = useMlHref(ml, http.basePath.get(), { + const jobsUrl = useMlHref(ml?.locator, http.basePath.get(), { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, }); diff --git a/x-pack/plugins/security_solution/tsconfig.json b/x-pack/plugins/security_solution/tsconfig.json index e33ecb852b5b1..33f95454d1cc6 100644 --- a/x-pack/plugins/security_solution/tsconfig.json +++ b/x-pack/plugins/security_solution/tsconfig.json @@ -226,5 +226,6 @@ "@kbn/entityManager-plugin", "@kbn/entities-schema", "@kbn/inference-plugin", + "@kbn/ml-locator", ] } diff --git a/yarn.lock b/yarn.lock index 5bc37ad95eb38..be062ac76816c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5727,6 +5727,10 @@ version "0.0.0" uid "" +"@kbn/ml-locator@link:x-pack/packages/ml/locator": + version "0.0.0" + uid "" + "@kbn/ml-nested-property@link:x-pack/packages/ml/nested_property": version "0.0.0" uid "" From fbf35d4aafffdb6b2b4e5d3fd7ee9ff0aeea15f7 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Tue, 24 Sep 2024 11:37:50 +0200 Subject: [PATCH 4/4] refactor locator --- x-pack/packages/ml/locator/use_ml_href.ts | 28 +++++++++++++++++-- .../ml_anomaly_alert_trigger.tsx | 5 ++-- .../maps/anomaly_layer_wizard_factory.tsx | 2 ++ x-pack/plugins/ml/public/mocks.ts | 3 -- x-pack/plugins/ml/public/plugin.ts | 17 ++--------- .../mlexplorer_link.tsx | 7 ++--- .../mlsingle_metric_link.tsx | 7 ++--- .../public/hooks/use_ml_manage_jobs_href.ts | 7 ++--- .../page_results_content.tsx | 4 +-- .../analyze_dataset_in_ml_action.tsx | 3 +- .../sections/anomalies/log_entry_example.tsx | 4 +-- .../mock_profiling_dependencies_storybook.tsx | 2 +- x-pack/plugins/security_solution/kibana.jsonc | 3 +- .../ml/links/create_explorer_link.tsx | 5 ++-- .../ml_popover/jobs_table/jobs_table.tsx | 13 ++------- .../components/ml_job_link/ml_job_link.tsx | 3 +- .../entity_analytics_anomalies/index.tsx | 4 +-- .../plugins/security_solution/public/types.ts | 2 ++ 18 files changed, 56 insertions(+), 63 deletions(-) diff --git a/x-pack/packages/ml/locator/use_ml_href.ts b/x-pack/packages/ml/locator/use_ml_href.ts index d076809094b0b..3cc5ae80353b8 100644 --- a/x-pack/packages/ml/locator/use_ml_href.ts +++ b/x-pack/packages/ml/locator/use_ml_href.ts @@ -5,22 +5,46 @@ * 2.0. */ +import { useMemo } from 'react'; import type { DependencyList } from 'react'; -import type { LocatorPublic } from '@kbn/share-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; +import { useKibana } from '@kbn/kibana-react-plugin/public'; +import { MlLocatorDefinition } from './ml_locator'; import type { MlLocatorParams } from './types'; +function useKibanaShareService() { + const { + services: { share }, + } = useKibana<{ + share: SharePluginStart; + }>(); + + if (!share) { + throw new Error('Kibana share service not available.'); + } + + return share; +} + /** * Provides a URL to ML plugin page * TODO remove basePath parameter */ export const useMlHref = ( - mlLocator: LocatorPublic | undefined, basePath: string | undefined, params: MlLocatorParams, dependencies?: DependencyList ) => { + const share = useKibanaShareService(); + + const mlLocator = useMemo( + () => share.url.locators.create(new MlLocatorDefinition()), + // eslint-disable-next-line react-hooks/exhaustive-deps + [] + ); + return mlLocator ? mlLocator.useUrl(params, undefined, dependencies) : basePath !== undefined diff --git a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx index 25f4c452bebbe..23e3c0f0df0c2 100644 --- a/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/anomaly_detection_rule/ml_anomaly_alert_trigger.tsx @@ -16,7 +16,7 @@ import { isDefined } from '@kbn/ml-is-defined'; import { ML_ANOMALY_RESULT_TYPE, ML_ANOMALY_THRESHOLD } from '@kbn/ml-anomaly-utils'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { parseInterval } from '@kbn/ml-parse-interval'; -import { ML_PAGES } from '@kbn/ml-locator'; +import { MlLocatorDefinition, ML_PAGES } from '@kbn/ml-locator'; import type { MlCapabilities } from '../../../common/types/capabilities'; import type { MlCoreSetup } from '../../plugin'; @@ -66,7 +66,8 @@ const MlAnomalyAlertTrigger: FC = ({ if (!mlCapabilities.canCreateJob) return; getStartServices().then((startServices) => { - const locator = startServices[2].locator; + const share = startServices[1].share; + const locator = share.url.locators.create(new MlLocatorDefinition()); if (!locator) return; locator.getUrl({ page: ML_PAGES.ANOMALY_DETECTION_CREATE_JOB }).then((url) => { if (mounted) { diff --git a/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx b/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx index 42c96eb47f42c..3ed1a2bf3bb17 100644 --- a/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx +++ b/x-pack/plugins/ml/public/maps/anomaly_layer_wizard_factory.tsx @@ -46,9 +46,11 @@ export class AnomalyLayerWizardFactory { }> { const [coreStart, pluginStart] = await this.getStartServices(); const { jobsApiProvider } = await import('../application/services/ml_api_service/jobs'); + const { MlLocatorDefinition } = await import('@kbn/ml-locator'); const httpService = new HttpService(coreStart.http); const mlJobsService = jobsApiProvider(httpService); + pluginStart.share.url.locators.create(new MlLocatorDefinition()); const mlLocator = pluginStart.share.url.locators.get(ML_APP_LOCATOR); return { mlJobsService, mlLocator }; diff --git a/x-pack/plugins/ml/public/mocks.ts b/x-pack/plugins/ml/public/mocks.ts index 246d7b14d3cba..a1701cd5dfbaa 100644 --- a/x-pack/plugins/ml/public/mocks.ts +++ b/x-pack/plugins/ml/public/mocks.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { sharePluginMock } from '@kbn/share-plugin/public/mocks'; import { type ElasticModels } from './application/services/elastic_models_service'; import type { MlPluginSetup, MlPluginStart } from './plugin'; import type { AnomalySwimLane } from './shared_components'; @@ -28,14 +27,12 @@ const createElasticModelsMock = (): jest.Mocked => { const createSetupContract = (): jest.Mocked => { return { - locator: sharePluginMock.createLocator(), elasticModels: createElasticModelsMock(), }; }; const createStartContract = (): jest.Mocked => { return { - locator: sharePluginMock.createLocator(), elasticModels: createElasticModelsMock(), components: { AnomalySwimLane: jest.fn() as unknown as jest.Mocked, diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index f752241adb8fc..5e0c93935e516 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -19,7 +19,7 @@ import { take } from 'rxjs'; import type { ObservabilityAIAssistantPublicStart } from '@kbn/observability-ai-assistant-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { ManagementSetup } from '@kbn/management-plugin/public'; -import type { LocatorPublic, SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; +import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { HomePublicPluginSetup } from '@kbn/home-plugin/public'; import type { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public'; @@ -52,7 +52,6 @@ import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/ import type { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public'; import type { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common'; import { ENABLE_ESQL } from '@kbn/esql-utils'; -import { MlLocatorDefinition, type MlLocator, type MlLocatorParams } from '@kbn/ml-locator'; import type { MlSharedServices } from './application/services/get_shared_ml_services'; import { getMlSharedServices } from './application/services/get_shared_ml_services'; import { registerManagementSection } from './application/management'; @@ -121,8 +120,6 @@ export type MlCoreSetup = CoreSetup; export class MlPlugin implements Plugin { private appUpdater$ = new BehaviorSubject(() => ({})); - private locator: undefined | MlLocator; - private sharedMlServices: MlSharedServices | undefined; private isServerless: boolean = false; @@ -141,10 +138,7 @@ export class MlPlugin implements Plugin { initExperimentalFeatures(this.experimentalFeatures, initializerContext.config.get()); } - setup( - core: MlCoreSetup, - pluginsSetup: MlSetupDependencies - ): { locator?: LocatorPublic; elasticModels?: ElasticModels } { + setup(core: MlCoreSetup, pluginsSetup: MlSetupDependencies): { elasticModels?: ElasticModels } { this.sharedMlServices = getMlSharedServices(core.http); core.application.register({ @@ -198,10 +192,6 @@ export class MlPlugin implements Plugin { }, }); - if (pluginsSetup.share) { - this.locator = pluginsSetup.share.url.locators.create(new MlLocatorDefinition()); - } - if (pluginsSetup.management) { registerManagementSection( pluginsSetup.management, @@ -300,7 +290,6 @@ export class MlPlugin implements Plugin { .subscribe(); return { - locator: this.locator, elasticModels: this.sharedMlServices.elasticModels, }; } @@ -309,13 +298,11 @@ export class MlPlugin implements Plugin { core: CoreStart, deps: MlStartDependencies ): { - locator?: LocatorPublic; elasticModels?: ElasticModels; mlApi?: MlApi; components: { AnomalySwimLane: typeof AnomalySwimLane }; } { return { - locator: this.locator, elasticModels: this.sharedMlServices?.elasticModels, mlApi: this.sharedMlServices?.mlApi, components: { diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx index 6c9e2b7426889..59683f6e9442d 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlexplorer_link.tsx @@ -33,10 +33,7 @@ export function MLExplorerLink({ jobId, external, children }: Props) { } export function useExplorerHref({ jobId }: { jobId: string }) { - const { - core, - plugins: { ml }, - } = useApmPluginContext(); + const { core } = useApmPluginContext(); const { urlParams } = useLegacyUrlParams(); const { @@ -45,7 +42,7 @@ export function useExplorerHref({ jobId }: { jobId: string }) { rangeTo = 'now', } = urlParams; - const href = useMlHref(ml?.locator, core.http.basePath.get(), { + const href = useMlHref(core.http.basePath.get(), { page: ML_PAGES.ANOMALY_EXPLORER, pageState: { jobIds: [jobId], diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx index 3e462cbede507..8398fabe83116 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/links/machine_learning_links/mlsingle_metric_link.tsx @@ -49,10 +49,7 @@ function useSingleMetricHref({ serviceName?: string; transactionType?: string; }) { - const { - core, - plugins: { ml }, - } = useApmPluginContext(); + const { core } = useApmPluginContext(); const { urlParams } = useLegacyUrlParams(); const { @@ -71,7 +68,7 @@ function useSingleMetricHref({ } : {}; - const href = useMlHref(ml?.locator, core.http.basePath.get(), { + const href = useMlHref(core.http.basePath.get(), { page: ML_PAGES.SINGLE_METRIC_VIEWER, pageState: { jobIds: [jobId], diff --git a/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts b/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts index 115d9088397ba..28948116437f3 100644 --- a/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts +++ b/x-pack/plugins/observability_solution/apm/public/hooks/use_ml_manage_jobs_href.ts @@ -10,10 +10,7 @@ import { useApmPluginContext } from '../context/apm_plugin/use_apm_plugin_contex import { useLegacyUrlParams } from '../context/url_params_context/use_url_params'; export function useMlManageJobsHref({ jobId }: { jobId?: string } = {}) { - const { - core, - plugins: { ml }, - } = useApmPluginContext(); + const { core } = useApmPluginContext(); const { urlParams } = useLegacyUrlParams(); @@ -23,7 +20,7 @@ export function useMlManageJobsHref({ jobId }: { jobId?: string } = {}) { rangeTo = 'now', } = urlParams; - const mlADLink = useMlHref(ml?.locator, core.http.basePath.get(), { + const mlADLink = useMlHref(core.http.basePath.get(), { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, pageState: { groupIds: ['apm'], diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx index d96b58fb4ab36..084582b315f05 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/page_results_content.tsx @@ -52,7 +52,7 @@ export const LogEntryCategoriesResultsContent: React.FunctionComponent< useTrackPageview({ app: 'infra_logs', path: 'log_entry_categories_results', delay: 15000 }); const { - services: { ml, http }, + services: { http }, } = useKibanaContextForPlugin(); const { logViewStatus } = useLogViewContext(); @@ -197,7 +197,7 @@ export const LogEntryCategoriesResultsContent: React.FunctionComponent< autoRefresh.isPaused ? null : autoRefresh.interval ); - const analyzeInMlLink = useMlHref(ml?.locator, http.basePath.get(), { + const analyzeInMlLink = useMlHref(http.basePath.get(), { page: ML_PAGES.ANOMALY_EXPLORER, pageState: { jobIds: [jobIds[logEntryCategoriesJobType]], diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx index 1f194dbd1e0ce..cd35af32e12e8 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_categories/sections/top_categories/analyze_dataset_in_ml_action.tsx @@ -22,11 +22,10 @@ export const AnalyzeCategoryDatasetInMlAction: React.FunctionComponent<{ timeRange: TimeRange; }> = ({ categorizationJobId, categoryId, dataset, timeRange }) => { const { - services: { ml, http, application }, + services: { http, application }, } = useKibanaContextForPlugin(); const viewAnomalyInMachineLearningLink = useMlHref( - ml?.locator, http.basePath.get(), { page: ML_PAGES.SINGLE_METRIC_VIEWER, diff --git a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx index fe254560ea823..cfcf77b6b785d 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx +++ b/x-pack/plugins/observability_solution/infra/public/pages/logs/log_entry_rate/sections/anomalies/log_entry_example.tsx @@ -82,7 +82,7 @@ export const LogEntryExampleMessage: React.FunctionComponent = ({ anomaly, }) => { const { - services: { ml, http, application }, + services: { http, application }, } = useKibanaContextForPlugin(); const [isHovered, setIsHovered] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false); @@ -122,7 +122,7 @@ export const LogEntryExampleMessage: React.FunctionComponent = ({ }, }); - const viewAnomalyInMachineLearningLink = useMlHref(ml?.locator, http.basePath.get(), { + const viewAnomalyInMachineLearningLink = useMlHref(http.basePath.get(), { page: ML_PAGES.SINGLE_METRIC_VIEWER, pageState: { jobIds: [anomaly.jobId], diff --git a/x-pack/plugins/observability_solution/profiling/public/components/contexts/profiling_dependencies/mock_profiling_dependencies_storybook.tsx b/x-pack/plugins/observability_solution/profiling/public/components/contexts/profiling_dependencies/mock_profiling_dependencies_storybook.tsx index 3508f3f090c6a..d22411da70d23 100644 --- a/x-pack/plugins/observability_solution/profiling/public/components/contexts/profiling_dependencies/mock_profiling_dependencies_storybook.tsx +++ b/x-pack/plugins/observability_solution/profiling/public/components/contexts/profiling_dependencies/mock_profiling_dependencies_storybook.tsx @@ -7,7 +7,7 @@ import { CoreStart } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; -import { MlLocatorDefinition } from '@kbn/ml-plugin/public'; +import { MlLocatorDefinition } from '@kbn/ml-locator'; import { UrlService } from '@kbn/share-plugin/common/url_service'; import { createMemoryHistory } from 'history'; import { merge } from 'lodash'; diff --git a/x-pack/plugins/security_solution/kibana.jsonc b/x-pack/plugins/security_solution/kibana.jsonc index 075da90b44a0f..b04cceca3265e 100644 --- a/x-pack/plugins/security_solution/kibana.jsonc +++ b/x-pack/plugins/security_solution/kibana.jsonc @@ -36,6 +36,7 @@ "navigation", "ruleRegistry", "sessionView", + "share", "spaces", "taskManager", "threatIntelligence", @@ -87,4 +88,4 @@ "common" ] } -} \ No newline at end of file +} diff --git a/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.tsx b/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.tsx index f698f4c36abc5..84fc594f0c300 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml/links/create_explorer_link.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiLink } from '@elastic/eui'; -import { useMlHref } from '@kbn/ml-plugin/public'; +import { useMlHref } from '@kbn/ml-locator'; import type { Anomaly } from '../types'; import { useKibana } from '../../../lib/kibana'; @@ -25,11 +25,10 @@ export const ExplorerLink: React.FC = ({ linkName, }) => { const { - services: { ml, http }, + services: { http }, } = useKibana(); const explorerUrl = useMlHref( - ml, http.basePath.get(), { page: 'explorer', diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx index e692bb2edeabe..dc7d1c1cf4fd1 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx @@ -21,7 +21,7 @@ import { import styled from 'styled-components'; import { useMlHref, ML_PAGES } from '@kbn/ml-locator'; import { PopoverItems } from '../../popover_items'; -import { useBasePath, useKibana } from '../../../lib/kibana'; +import { useBasePath } from '../../../lib/kibana'; import * as i18n from './translations'; import { JobSwitch } from './job_switch'; import type { SecurityJob } from '../types'; @@ -43,12 +43,7 @@ interface JobNameProps { } const JobName = ({ id, name, description, basePath }: JobNameProps) => { - const { - services: { ml }, - } = useKibana(); - const jobUrl = useMlHref( - ml?.locator, basePath, { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, @@ -190,11 +185,7 @@ export const JobsTable = React.memo(JobsTableComponent); JobsTable.displayName = 'JobsTable'; export const NoItemsMessage = React.memo(({ basePath }: { basePath: string }) => { - const { - services: { ml }, - } = useKibana(); - - const createNewAnomalyDetectionJoUrl = useMlHref(ml?.locator, basePath, { + const createNewAnomalyDetectionJoUrl = useMlHref(basePath, { page: ML_PAGES.ANOMALY_DETECTION_CREATE_JOB_SELECT_INDEX, }); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx index 453ff46746cf8..9547d55a6fe0e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/ml_job_link/ml_job_link.tsx @@ -23,10 +23,9 @@ interface MlJobLinkProps { const MlJobLinkComponent: React.FC = ({ jobId, jobName }) => { const { - services: { http, ml }, + services: { http }, } = useKibana(); const jobUrl = useMlHref( - ml?.locator, http.basePath.get(), { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx index 23a769374a65b..2d6b1de96b959 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_anomalies/index.tsx @@ -53,10 +53,10 @@ export const EntityAnalyticsAnomalies = () => { const [recentlyEnabledJobIds, setRecentlyEnabledJobIds] = useState([]); const { - services: { ml, http, docLinks }, + services: { http, docLinks }, } = useKibana(); - const jobsUrl = useMlHref(ml?.locator, http.basePath.get(), { + const jobsUrl = useMlHref(http.basePath.get(), { page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, }); diff --git a/x-pack/plugins/security_solution/public/types.ts b/x-pack/plugins/security_solution/public/types.ts index ca144c21d7847..6e0dcef1be269 100644 --- a/x-pack/plugins/security_solution/public/types.ts +++ b/x-pack/plugins/security_solution/public/types.ts @@ -17,6 +17,7 @@ import type { NewsfeedPublicPluginStart } from '@kbn/newsfeed-plugin/public'; import type { Start as InspectorStart } from '@kbn/inspector-plugin/public'; import type { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { Storage } from '@kbn/kibana-utils-plugin/public'; import type { FleetStart } from '@kbn/fleet-plugin/public'; import type { PluginStart as ListsPluginStart } from '@kbn/lists-plugin/public'; @@ -134,6 +135,7 @@ export interface StartPlugins { uiActions: UiActionsStart; maps: MapsStartApi; ml?: MlPluginStart; + share: SharePluginStart; spaces?: SpacesPluginStart; dataViewFieldEditor: IndexPatternFieldEditorStart; osquery: OsqueryPluginStart;