From 7a5a8a29ba1ab8352c2ba4a17cc5f54f1e6715e2 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 3 Mar 2025 11:10:58 -0700 Subject: [PATCH 1/7] [dashboard] remove dashboardFeatureFlagConfig from Dashboard start contract --- .../plugins/shared/dashboard/public/plugin.tsx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/platform/plugins/shared/dashboard/public/plugin.tsx b/src/platform/plugins/shared/dashboard/public/plugin.tsx index b538f8ca1e94c..689ecfdd4db1c 100644 --- a/src/platform/plugins/shared/dashboard/public/plugin.tsx +++ b/src/platform/plugins/shared/dashboard/public/plugin.tsx @@ -80,10 +80,7 @@ import type { FindDashboardsService } from './services/dashboard_content_managem import { setKibanaServices, untilPluginStartServicesReady } from './services/kibana_services'; import { setLogger } from './services/logger'; import { registerActions } from './dashboard_actions/register_actions'; - -export interface DashboardFeatureFlagConfig { - allowByValueEmbeddables: boolean; -} +import type { ConfigSchema } from '../server/config'; export interface DashboardSetupDependencies { data: DataPublicPluginSetup; @@ -141,7 +138,6 @@ export interface DashboardStart { * Use `shareStartService.url.locators.get(DASHBOARD_APP_LOCATOR)` instead. */ locator?: DashboardAppLocator; - dashboardFeatureFlagConfig: DashboardFeatureFlagConfig; findDashboardsService: () => Promise; registerDashboardPanelPlacementSetting: ( embeddableType: string, @@ -149,8 +145,6 @@ export interface DashboardStart { ) => void; } -export let resolveServicesReady: () => void; - export class DashboardPlugin implements Plugin @@ -162,16 +156,12 @@ export class DashboardPlugin private appStateUpdater = new BehaviorSubject(() => ({})); private stopUrlTracking: (() => void) | undefined = undefined; private currentHistory: ScopedHistory | undefined = undefined; - private dashboardFeatureFlagConfig?: DashboardFeatureFlagConfig; private locator?: DashboardAppLocator; public setup( core: CoreSetup, { share, embeddable, home, urlForwarding, data, contentManagement }: DashboardSetupDependencies ): DashboardSetup { - this.dashboardFeatureFlagConfig = - this.initializerContext.config.get(); - core.analytics.registerEventType({ eventType: 'dashboard_loaded_with_data', schema: {}, @@ -340,13 +330,13 @@ export class DashboardPlugin untilPluginStartServicesReady().then(() => { registerActions({ plugins, - allowByValueEmbeddables: this.dashboardFeatureFlagConfig?.allowByValueEmbeddables, + allowByValueEmbeddables: + this.initializerContext.config.get()?.allowByValueEmbeddables ?? true, }); }); return { locator: this.locator, - dashboardFeatureFlagConfig: this.dashboardFeatureFlagConfig!, registerDashboardPanelPlacementSetting, findDashboardsService: async () => { const { getDashboardContentManagementService } = await import( From 7d794955f7962eaea193af90c30a192757dc5f43 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 3 Mar 2025 11:31:17 -0700 Subject: [PATCH 2/7] tslint --- src/platform/plugins/shared/dashboard/public/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/dashboard/public/index.ts b/src/platform/plugins/shared/dashboard/public/index.ts index c04fba87a851d..7336d84ed6886 100644 --- a/src/platform/plugins/shared/dashboard/public/index.ts +++ b/src/platform/plugins/shared/dashboard/public/index.ts @@ -20,7 +20,7 @@ export type { DashboardApi, DashboardCreationOptions } from './dashboard_api/typ export { DASHBOARD_API_TYPE } from './dashboard_api/types'; export { LazyDashboardRenderer as DashboardRenderer } from './dashboard_container/external_api/lazy_dashboard_renderer'; export type { DashboardLocatorParams } from './dashboard_container/types'; -export type { DashboardSetup, DashboardStart, DashboardFeatureFlagConfig } from './plugin'; +export type { DashboardSetup, DashboardStart } from './plugin'; export { DashboardListingTable } from './dashboard_listing'; export { DashboardTopNav } from './dashboard_top_nav'; From fea861ed5568fd48c6acac2d83a1061f89a89daf Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 3 Mar 2025 13:05:37 -0700 Subject: [PATCH 3/7] remove locator from dashboard setup and start contract --- .../plugins/shared/dashboard/public/index.ts | 2 +- .../shared/dashboard/public/plugin.tsx | 31 ++++--------------- .../shared/dashboard_enhanced/kibana.jsonc | 2 +- .../dashboard_enhanced/public/plugin.ts | 2 -- .../abstract_dashboard_drilldown.tsx | 8 ++--- ...embeddable_to_dashboard_drilldown.test.tsx | 18 ++++++----- 6 files changed, 23 insertions(+), 40 deletions(-) diff --git a/src/platform/plugins/shared/dashboard/public/index.ts b/src/platform/plugins/shared/dashboard/public/index.ts index 7336d84ed6886..c1fbd476e1295 100644 --- a/src/platform/plugins/shared/dashboard/public/index.ts +++ b/src/platform/plugins/shared/dashboard/public/index.ts @@ -20,7 +20,7 @@ export type { DashboardApi, DashboardCreationOptions } from './dashboard_api/typ export { DASHBOARD_API_TYPE } from './dashboard_api/types'; export { LazyDashboardRenderer as DashboardRenderer } from './dashboard_container/external_api/lazy_dashboard_renderer'; export type { DashboardLocatorParams } from './dashboard_container/types'; -export type { DashboardSetup, DashboardStart } from './plugin'; +export type { DashboardStart } from './plugin'; export { DashboardListingTable } from './dashboard_listing'; export { DashboardTopNav } from './dashboard_top_nav'; diff --git a/src/platform/plugins/shared/dashboard/public/plugin.tsx b/src/platform/plugins/shared/dashboard/public/plugin.tsx index 689ecfdd4db1c..66ec78cf978fc 100644 --- a/src/platform/plugins/shared/dashboard/public/plugin.tsx +++ b/src/platform/plugins/shared/dashboard/public/plugin.tsx @@ -61,10 +61,7 @@ import type { } from '@kbn/usage-collection-plugin/public'; import { CONTENT_ID, LATEST_VERSION } from '../common/content_management'; -import { - DashboardAppLocatorDefinition, - type DashboardAppLocator, -} from './dashboard_app/locator/locator'; +import { DashboardAppLocatorDefinition } from './dashboard_app/locator/locator'; import { DashboardMountContextProps } from './dashboard_app/types'; import { DASHBOARD_APP_ID, @@ -122,22 +119,10 @@ export interface DashboardStartDependencies { observabilityAIAssistant?: ObservabilityAIAssistantPublicStart; } -export interface DashboardSetup { - /** - * @deprecated - * - * Use `shareStartService.url.locators.get(DASHBOARD_APP_LOCATOR)` instead. - */ - locator?: DashboardAppLocator; -} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +interface DashboardSetup {} export interface DashboardStart { - /** - * @deprecated - * - * Use `shareStartService.url.locators.get(DASHBOARD_APP_LOCATOR)` instead. - */ - locator?: DashboardAppLocator; findDashboardsService: () => Promise; registerDashboardPanelPlacementSetting: ( embeddableType: string, @@ -156,19 +141,18 @@ export class DashboardPlugin private appStateUpdater = new BehaviorSubject(() => ({})); private stopUrlTracking: (() => void) | undefined = undefined; private currentHistory: ScopedHistory | undefined = undefined; - private locator?: DashboardAppLocator; public setup( core: CoreSetup, { share, embeddable, home, urlForwarding, data, contentManagement }: DashboardSetupDependencies - ): DashboardSetup { + ) { core.analytics.registerEventType({ eventType: 'dashboard_loaded_with_data', schema: {}, }); if (share) { - this.locator = share.url.locators.create( + share.url.locators.create( new DashboardAppLocatorDefinition({ useHashedUrl: core.uiSettings.get('state:storeInSessionStorage'), getDashboardFilterFields: async (dashboardId: string) => { @@ -319,9 +303,7 @@ export class DashboardPlugin name: dashboardAppTitle, }); - return { - locator: this.locator, - }; + return {}; } public start(core: CoreStart, plugins: DashboardStartDependencies): DashboardStart { @@ -336,7 +318,6 @@ export class DashboardPlugin }); return { - locator: this.locator, registerDashboardPanelPlacementSetting, findDashboardsService: async () => { const { getDashboardContentManagementService } = await import( diff --git a/x-pack/platform/plugins/shared/dashboard_enhanced/kibana.jsonc b/x-pack/platform/plugins/shared/dashboard_enhanced/kibana.jsonc index ae6902cc3c714..fd892f156ad8a 100644 --- a/x-pack/platform/plugins/shared/dashboard_enhanced/kibana.jsonc +++ b/x-pack/platform/plugins/shared/dashboard_enhanced/kibana.jsonc @@ -15,7 +15,6 @@ "dashboardEnhanced" ], "requiredPlugins": [ - "dashboard", "data", "embeddable", "share", @@ -23,6 +22,7 @@ "unifiedSearch" ], "requiredBundles": [ + "dashboard", "embeddable", "embeddableEnhanced", "kibanaUtils", diff --git a/x-pack/platform/plugins/shared/dashboard_enhanced/public/plugin.ts b/x-pack/platform/plugins/shared/dashboard_enhanced/public/plugin.ts index 43f281ebed599..ecbd6c3a73abc 100644 --- a/x-pack/platform/plugins/shared/dashboard_enhanced/public/plugin.ts +++ b/x-pack/platform/plugins/shared/dashboard_enhanced/public/plugin.ts @@ -13,7 +13,6 @@ import { AdvancedUiActionsSetup, AdvancedUiActionsStart, } from '@kbn/ui-actions-enhanced-plugin/public'; -import { DashboardStart } from '@kbn/dashboard-plugin/public'; import { DashboardDrilldownsService } from './services'; export interface SetupDependencies { @@ -27,7 +26,6 @@ export interface StartDependencies { data: DataPublicPluginStart; embeddable: EmbeddableStart; share: SharePluginStart; - dashboard: DashboardStart; } // eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx b/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx index a7d887e690f3a..957d2343361fc 100644 --- a/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx +++ b/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx @@ -5,10 +5,9 @@ * 2.0. */ -import type { KibanaLocation } from '@kbn/share-plugin/public'; +import type { KibanaLocation, SharePluginStart } from '@kbn/share-plugin/public'; import React from 'react'; import { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import { DashboardStart } from '@kbn/dashboard-plugin/public'; import { AdvancedUiActionsStart, UiActionsEnhancedBaseActionFactoryContext as BaseActionFactoryContext, @@ -16,6 +15,7 @@ import { } from '@kbn/ui-actions-enhanced-plugin/public'; import { CollectConfigProps, StartServicesGetter } from '@kbn/kibana-utils-plugin/public'; import { DEFAULT_DASHBOARD_DRILLDOWN_OPTIONS } from '@kbn/presentation-util-plugin/public'; +import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics'; import { CollectConfigContainer } from './components'; import { txtGoToDashboard } from './i18n'; @@ -24,7 +24,7 @@ export interface Params { start: StartServicesGetter<{ uiActionsEnhanced: AdvancedUiActionsStart; data: DataPublicPluginStart; - dashboard: DashboardStart; + share: SharePluginStart; }>; } @@ -87,7 +87,7 @@ export abstract class AbstractDashboardDrilldown { }, plugins: { uiActionsEnhanced: {}, - dashboard: { - locator: { - getLocation: async (params: DashboardLocatorParams) => { - return await definition.getLocation(params); - }, - }, + share: { + url: { + locators: { + get: () => ({ + getLocation: async (params: DashboardLocatorParams) => { + return await definition.getLocation(params); + }, + }) + } + } }, }, self: {}, })) as unknown as StartServicesGetter< - Pick + Pick >, }); From d8ec4133c20089e6c5a010cb08aee9286b136334 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 3 Mar 2025 14:26:07 -0700 Subject: [PATCH 4/7] ml tslint --- .../custom_urls/custom_url_editor/utils.ts | 8 ++- .../components/custom_urls/custom_urls.tsx | 60 ++++++++++--------- .../quick_create_job_base.ts | 14 ++--- .../new_job/job_from_lens/quick_create_job.ts | 6 +- .../new_job/job_from_lens/route_resolver.ts | 8 +-- .../new_job/job_from_map/quick_create_job.ts | 6 +- .../new_job/job_from_map/route_resolver.ts | 14 ++--- .../quick_create_job.ts | 6 +- .../route_resolver.ts | 8 +-- .../routing/routes/new_job/from_lens.tsx | 4 +- .../routing/routes/new_job/from_map.tsx | 4 +- .../routes/new_job/from_pattern_analysis.tsx | 4 +- .../services/dashboard_service.test.ts | 17 +++++- .../application/services/dashboard_service.ts | 13 ++-- .../job_creation/aiops/flyout/create_job.tsx | 5 +- .../job_creation/common/context.ts | 2 - .../layer/compatible_layer.tsx | 3 +- .../layer/compatible_layer.tsx | 3 +- .../plugins/shared/ml/public/plugin.ts | 3 +- 19 files changed, 100 insertions(+), 88 deletions(-) diff --git a/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_url_editor/utils.ts b/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_url_editor/utils.ts index a55d4ffe343c8..6b020bed5f992 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_url_editor/utils.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_url_editor/utils.ts @@ -28,6 +28,8 @@ import { import { isDefined } from '@kbn/ml-is-defined'; import { parseInterval } from '@kbn/ml-parse-interval'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; +import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics'; import type { DashboardItems } from '../../../services/dashboard_service'; import { categoryFieldTypes } from '../../../../../common/util/fields_utils'; import { TIME_RANGE_TYPE, URL_TYPE } from './constants'; @@ -221,12 +223,13 @@ export function isValidCustomUrlSettings( export function buildCustomUrlFromSettings( dashboardService: DashboardStart, + share: SharePluginStart, settings: CustomUrlSettings ): Promise { // Dashboard URL returns a Promise as a query is made to obtain the full dashboard config. // So wrap the other two return types in a Promise for consistent return type. if (settings.type === URL_TYPE.KIBANA_DASHBOARD) { - return buildDashboardUrlFromSettings(dashboardService, settings); + return buildDashboardUrlFromSettings(dashboardService, share, settings); } else if (settings.type === URL_TYPE.KIBANA_DISCOVER) { return Promise.resolve(buildDiscoverUrlFromSettings(settings)); } else { @@ -256,6 +259,7 @@ function getUrlRangeFromSettings(settings: CustomUrlSettings) { async function buildDashboardUrlFromSettings( dashboardService: DashboardStart, + share: SharePluginStart, settings: CustomUrlSettings, isPartialDFAJob?: boolean ): Promise { @@ -300,7 +304,7 @@ async function buildDashboardUrlFromSettings( const { from, to } = getUrlRangeFromSettings(settings); - const location = await dashboardService.locator?.getLocation({ + const location = await share.url.locators.get(DASHBOARD_APP_LOCATOR)?.getLocation({ dashboardId, timeRange: { from, diff --git a/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_urls.tsx b/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_urls.tsx index 7bec64f3bf6b3..8dcf7b15ad544 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_urls.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/components/custom_urls/custom_urls.tsx @@ -151,9 +151,9 @@ export class CustomUrls extends Component { }; addNewCustomUrl = () => { - const { dashboard } = this.context.services; + const { dashboard, share } = this.context.services; - buildCustomUrlFromSettings(dashboard, this.state.editorSettings as CustomUrlSettings) + buildCustomUrlFromSettings(dashboard, share, this.state.editorSettings as CustomUrlSettings) .then((customUrl) => { const customUrls = [...this.state.customUrls, customUrl]; this.props.setCustomUrls(customUrls); @@ -179,6 +179,7 @@ export class CustomUrls extends Component { data: { dataViews }, dashboard, mlServices: { mlApi }, + share, } = this.context.services; const dataViewId = this.state?.editorSettings?.kibanaSettings?.discoverIndexPatternId; const job = this.props.job; @@ -191,33 +192,34 @@ export class CustomUrls extends Component { }) .then((dataView) => { const timefieldName = dataView?.timeFieldName ?? null; - buildCustomUrlFromSettings(dashboard, this.state.editorSettings as CustomUrlSettings).then( - (customUrl) => { - getTestUrl( - mlApi, - job, - customUrl, - timefieldName, - this.props.currentTimeFilter, - this.props.isPartialDFAJob - ) - .then((testUrl) => { - openCustomUrlWindow(testUrl, customUrl, basePath.get()); - }) - .catch((error) => { - this.toastNotificationService!.displayErrorToast( - error, - i18n.translate( - 'xpack.ml.jobsList.editJobFlyout.customUrls.getTestUrlErrorNotificationMessage', - { - defaultMessage: - 'An error occurred obtaining the URL to test the configuration', - } - ) - ); - }); - } - ); + buildCustomUrlFromSettings( + dashboard, + share, + this.state.editorSettings as CustomUrlSettings + ).then((customUrl) => { + getTestUrl( + mlApi, + job, + customUrl, + timefieldName, + this.props.currentTimeFilter, + this.props.isPartialDFAJob + ) + .then((testUrl) => { + openCustomUrlWindow(testUrl, customUrl, basePath.get()); + }) + .catch((error) => { + this.toastNotificationService!.displayErrorToast( + error, + i18n.translate( + 'xpack.ml.jobsList.editJobFlyout.customUrls.getTestUrlErrorNotificationMessage', + { + defaultMessage: 'An error occurred obtaining the URL to test the configuration', + } + ) + ); + }); + }); }) .catch((error) => { this.toastNotificationService!.displayErrorToast( diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts index 0cf35e1a2128c..391280e365995 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts @@ -11,16 +11,14 @@ import type { IUiSettingsClient } from '@kbn/core/public'; import type { TimefilterContract } from '@kbn/data-plugin/public'; import { firstValueFrom } from 'rxjs'; import type { estypes } from '@elastic/elasticsearch'; -import type { - DashboardApi, - DashboardLocatorParams, - DashboardStart, -} from '@kbn/dashboard-plugin/public'; +import type { DashboardApi, DashboardLocatorParams } from '@kbn/dashboard-plugin/public'; import { getTitle } from '@kbn/presentation-publishing'; import type { Filter, Query, DataViewBase } from '@kbn/es-query'; import { FilterStateStore } from '@kbn/es-query'; import type { ErrorType } from '@kbn/ml-error-utils'; import type { DataViewsContract } from '@kbn/data-views-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; +import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics'; import type { MlApi } from '../../../services/ml_api_service'; import type { Job, Datafeed } from '../../../../../common/types/anomaly_detection_jobs'; import { getFiltersForDSLQuery } from '../../../../../common/util/job_utils'; @@ -55,7 +53,7 @@ export class QuickJobCreatorBase { protected readonly dataViews: DataViewsContract, protected readonly kibanaConfig: IUiSettingsClient, protected readonly timeFilter: TimefilterContract, - protected readonly dashboardService: DashboardStart, + protected readonly shareService: SharePluginStart, protected readonly mlApi: MlApi ) {} @@ -246,7 +244,9 @@ export class QuickJobCreatorBase { ), }; - const location = await this.dashboardService.locator?.getLocation(params); + const location = await this.shareService.url.locators + .get(DASHBOARD_APP_LOCATOR) + ?.getLocation(params); if (location === undefined) { return null; } diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts index cda0e842f2c95..20d5f3ab9f745 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts @@ -15,7 +15,7 @@ import type { IUiSettingsClient } from '@kbn/core/public'; import type { TimefilterContract } from '@kbn/data-plugin/public'; import type { DataViewsContract } from '@kbn/data-views-plugin/public'; import { isOfAggregateQueryType, type Filter, type Query } from '@kbn/es-query'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { LensApi } from '@kbn/lens-plugin/public'; import type { JobCreatorType } from '../common/job_creator'; import { createEmptyJob, createEmptyDatafeed } from '../common/job_creator/util/default_configs'; @@ -41,10 +41,10 @@ export class QuickLensJobCreator extends QuickJobCreatorBase { dataViews: DataViewsContract, kibanaConfig: IUiSettingsClient, timeFilter: TimefilterContract, - dashboardService: DashboardStart, + shareService: SharePluginStart, mlApi: MlApi ) { - super(dataViews, kibanaConfig, timeFilter, dashboardService, mlApi); + super(dataViews, kibanaConfig, timeFilter, shareService, mlApi); } public async createAndSaveJob( diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/route_resolver.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/route_resolver.ts index 45d54593ab237..b33e374e4c0f3 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/route_resolver.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/route_resolver.ts @@ -11,7 +11,7 @@ import type { Filter } from '@kbn/es-query'; import type { LensPublicStart, LensSavedObjectAttributes } from '@kbn/lens-plugin/public'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import type { TimefilterContract } from '@kbn/data-plugin/public'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { DataViewsContract } from '@kbn/data-views-plugin/public'; import { QuickLensJobCreator } from './quick_create_job'; import type { MlApi } from '../../../services/ml_api_service'; @@ -23,7 +23,7 @@ interface Dependencies { dataViews: DataViewsContract; kibanaConfig: IUiSettingsClient; timeFilter: TimefilterContract; - dashboardService: DashboardStart; + share: SharePluginStart; mlApi: MlApi; } export async function resolver( @@ -35,7 +35,7 @@ export async function resolver( filtersRisonString: string, layerIndexRisonString: string ) { - const { dataViews, lens, mlApi, timeFilter, kibanaConfig, dashboardService } = deps; + const { dataViews, lens, mlApi, timeFilter, kibanaConfig, share } = deps; if (lensSavedObjectRisonString === undefined) { throw new Error('Cannot create visualization'); } @@ -56,7 +56,7 @@ export async function resolver( dataViews, kibanaConfig, timeFilter, - dashboardService, + share, mlApi ); await jobCreator.createAndStashADJob(vis, from, to, query, filters, layerIndex); diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts index a507eb53116af..fa5008755bc46 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts @@ -10,7 +10,7 @@ import type { IUiSettingsClient } from '@kbn/core/public'; import type { TimefilterContract } from '@kbn/data-plugin/public'; import type { Filter, Query } from '@kbn/es-query'; import type { DataView, DataViewsContract } from '@kbn/data-views-plugin/public'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { MapApi } from '@kbn/maps-plugin/public'; import type { MlApi } from '../../../services/ml_api_service'; import { @@ -42,10 +42,10 @@ export class QuickGeoJobCreator extends QuickJobCreatorBase { dataViews: DataViewsContract, kibanaConfig: IUiSettingsClient, timeFilter: TimefilterContract, - dashboardService: DashboardStart, + shareService: SharePluginStart, mlApi: MlApi ) { - super(dataViews, kibanaConfig, timeFilter, dashboardService, mlApi); + super(dataViews, kibanaConfig, timeFilter, shareService, mlApi); } public async createAndSaveGeoJob({ diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/route_resolver.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/route_resolver.ts index efc69e324de3d..14d07ce464809 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/route_resolver.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/route_resolver.ts @@ -7,7 +7,7 @@ import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import type { TimefilterContract } from '@kbn/data-plugin/public'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { DataViewsContract } from '@kbn/data-views-plugin/public'; import type { MlApi } from '../../../services/ml_api_service'; import { QuickGeoJobCreator } from './quick_create_job'; @@ -18,7 +18,7 @@ interface Dependencies { dataViews: DataViewsContract; kibanaConfig: IUiSettingsClient; timeFilter: TimefilterContract; - dashboardService: DashboardStart; + share: SharePluginStart; mlApi: MlApi; } export async function resolver( @@ -32,7 +32,7 @@ export async function resolver( toRisonString: string, layerRisonString?: string ) { - const { dataViews, kibanaConfig, timeFilter, dashboardService, mlApi } = deps; + const { dataViews, kibanaConfig, timeFilter, share, mlApi } = deps; const defaultLayer = { query: getDefaultQuery(), filters: [] }; const dashboard = getRisonValue(dashboardRisonString, defaultLayer); @@ -50,13 +50,7 @@ export async function resolver( const from = getRisonValue(fromRisonString, ''); const to = getRisonValue(toRisonString, ''); - const jobCreator = new QuickGeoJobCreator( - dataViews, - kibanaConfig, - timeFilter, - dashboardService, - mlApi - ); + const jobCreator = new QuickGeoJobCreator(dataViews, kibanaConfig, timeFilter, share, mlApi); await jobCreator.createAndStashGeoJob( dataViewId, diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts index 28e5ddd01f439..eae64ffbda5c1 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts @@ -7,7 +7,7 @@ import type { IUiSettingsClient } from '@kbn/core/public'; import type { DataPublicPluginStart, TimefilterContract } from '@kbn/data-plugin/public'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { DataViewField, DataView } from '@kbn/data-views-plugin/common'; import type { DataViewsContract } from '@kbn/data-views-plugin/public'; import type { TimeRange } from '@kbn/es-query'; @@ -34,11 +34,11 @@ export class QuickCategorizationJobCreator extends QuickJobCreatorBase { dataViews: DataViewsContract, kibanaConfig: IUiSettingsClient, timeFilter: TimefilterContract, - dashboardService: DashboardStart, + shareService: SharePluginStart, private data: DataPublicPluginStart, mlApi: MlApi ) { - super(dataViews, kibanaConfig, timeFilter, dashboardService, mlApi); + super(dataViews, kibanaConfig, timeFilter, shareService, mlApi); } public async createAndSaveJob( diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/route_resolver.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/route_resolver.ts index 1ed579a1838cc..bf8c43a53888e 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/route_resolver.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/route_resolver.ts @@ -7,7 +7,7 @@ import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; import type { DataPublicPluginStart, TimefilterContract } from '@kbn/data-plugin/public'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types'; import { type CategorizationType, @@ -21,9 +21,9 @@ import { getDefaultDatafeedQuery, getRisonValue } from '../utils/new_job_utils'; interface Dependencies { kibanaConfig: IUiSettingsClient; timeFilter: TimefilterContract; - dashboardService: DashboardStart; data: DataPublicPluginStart; mlApi: MlApi; + share: SharePluginStart; } export async function resolver( deps: Dependencies, @@ -36,7 +36,7 @@ export async function resolver( toRisonString: string, queryRisonString: string ) { - const { mlApi, timeFilter, kibanaConfig, dashboardService, data } = deps; + const { mlApi, timeFilter, kibanaConfig, share, data } = deps; const query = getRisonValue(queryRisonString, getDefaultDatafeedQuery()); const from = getRisonValue(fromRisonString, ''); @@ -55,7 +55,7 @@ export async function resolver( data.dataViews, kibanaConfig, timeFilter, - dashboardService, + share, data, mlApi ); diff --git a/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_lens.tsx b/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_lens.tsx index 74b61559d9f3f..d68b94943f5a2 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_lens.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_lens.tsx @@ -37,10 +37,10 @@ const PageWrapper: FC = ({ location }) => { timefilter: { timefilter: timeFilter }, }, }, - dashboard: dashboardService, uiSettings: kibanaConfig, mlServices: { mlApi }, lens, + share, }, } = useMlKibana(); @@ -53,7 +53,7 @@ const PageWrapper: FC = ({ location }) => { mlApi, timeFilter, kibanaConfig, - dashboardService, + share, }, vis, from, diff --git a/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_map.tsx b/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_map.tsx index 026f219e5104f..833c9811e8d06 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_map.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_map.tsx @@ -44,16 +44,16 @@ const PageWrapper: FC = ({ location }) => { timefilter: { timefilter: timeFilter }, }, }, - dashboard: dashboardService, uiSettings: kibanaConfig, mlServices: { mlApi }, + share, }, } = useMlKibana(); const { context } = useRouteResolver('full', ['canCreateJob'], { redirect: () => resolver( - { dataViews, mlApi, timeFilter, kibanaConfig, dashboardService }, + { dataViews, mlApi, timeFilter, kibanaConfig, share }, dashboard, dataViewId, embeddable, diff --git a/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx b/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx index 6252e54d6ae7e..2f2725dc785f1 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/routing/routes/new_job/from_pattern_analysis.tsx @@ -38,9 +38,9 @@ const PageWrapper: FC = ({ location }) => { const { services: { data, - dashboard: dashboardService, uiSettings: kibanaConfig, mlServices: { mlApi }, + share, }, } = useMlKibana(); @@ -51,7 +51,7 @@ const PageWrapper: FC = ({ location }) => { mlApi, timeFilter: data.query.timefilter.timefilter, kibanaConfig, - dashboardService, + share, data, }, categorizationType, diff --git a/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts b/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts index e3ff58510374d..e51fdf0e0dc6c 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts @@ -5,10 +5,12 @@ * 2.0. */ +import type { SharePluginStart } from '@kbn/share-plugin/public'; import { dashboardServiceProvider } from './dashboard_service'; import type { DashboardStart } from '@kbn/dashboard-plugin/public'; describe('DashboardService', () => { + const getUrlMock = jest.fn(); const dashboard: DashboardStart = { // @ts-expect-error Only partial mock of full plugin locator: { @@ -22,7 +24,18 @@ describe('DashboardService', () => { }), }; - const dashboardService = dashboardServiceProvider(dashboard); + const share: SharePluginStart = { + url: { + locators: { + // @ts-expect-error Only partial mock of full plugin + get: () => ({ + getUrl: getUrlMock, + }), + }, + }, + }; + + const dashboardService = dashboardServiceProvider(dashboard, share); test('should fetch dashboard', async () => { // act @@ -37,7 +50,7 @@ describe('DashboardService', () => { }); test('should generate url to the dashboard', () => { dashboardService.getDashboardUrl('test-id'); - expect(dashboard.locator?.getUrl).toHaveBeenCalledWith({ + expect(getUrlMock).toHaveBeenCalledWith({ dashboardId: 'test-id', useHash: false, viewMode: 'edit', diff --git a/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.ts b/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.ts index ffa6f6a5d3ede..c687efe1d4cfe 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.ts @@ -8,12 +8,17 @@ import { useMemo } from 'react'; import type { DashboardStart } from '@kbn/dashboard-plugin/public'; import { ViewMode } from '@kbn/embeddable-plugin/public'; +import type { SharePluginStart } from '@kbn/share-plugin/public'; +import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics'; import { useMlKibana } from '../contexts/kibana'; export type DashboardService = ReturnType; export type DashboardItems = Awaited>; -export function dashboardServiceProvider(dashboardService: DashboardStart) { +export function dashboardServiceProvider( + dashboardService: DashboardStart, + share: SharePluginStart +) { return { /** * Fetches dashboards @@ -39,7 +44,7 @@ export function dashboardServiceProvider(dashboardService: DashboardStart) { * Generates dashboard url */ async getDashboardUrl(dashboardId: string, viewMode: ViewMode = ViewMode.EDIT) { - return await dashboardService.locator?.getUrl({ + return await share.url.locators.get(DASHBOARD_APP_LOCATOR)?.getUrl({ dashboardId, viewMode: ViewMode.EDIT, useHash: false, @@ -53,8 +58,8 @@ export function dashboardServiceProvider(dashboardService: DashboardStart) { */ export function useDashboardService(): DashboardService { const { - services: { dashboard }, + services: { dashboard, share }, } = useMlKibana(); - return useMemo(() => dashboardServiceProvider(dashboard), [dashboard]); + return useMemo(() => dashboardServiceProvider(dashboard, share), [dashboard, share]); } diff --git a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/aiops/flyout/create_job.tsx b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/aiops/flyout/create_job.tsx index 3bf418d2c9db3..68c9b72567fee 100644 --- a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/aiops/flyout/create_job.tsx +++ b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/aiops/flyout/create_job.tsx @@ -48,7 +48,6 @@ export const CreateJob: FC = ({ dataView, field, query, timeRange }) => { data, share, uiSettings, - dashboardService, mlServices: { mlApi }, }, } = useMlFromLensKibanaContext(); @@ -88,11 +87,11 @@ export const CreateJob: FC = ({ dataView, field, query, timeRange }) => { data.dataViews, uiSettings, data.query.timefilter.timefilter, - dashboardService, + share, data, mlApi ), - [dashboardService, data, mlApi, uiSettings] + [share, data, mlApi, uiSettings] ); function createADJobInWizard() { diff --git a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/common/context.ts b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/common/context.ts index 5f94b7c3030f9..7b6ffa30fe629 100644 --- a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/common/context.ts +++ b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/common/context.ts @@ -12,14 +12,12 @@ import { useKibana } from '@kbn/kibana-react-plugin/public'; import type { SharePluginStart } from '@kbn/share-plugin/public'; import type { LensPublicStart } from '@kbn/lens-plugin/public'; -import type { DashboardStart } from '@kbn/dashboard-plugin/public'; import type { MlServicesContext } from '../../../application/app'; interface StartPlugins { data: DataPublicPluginStart; share: SharePluginStart; lens: LensPublicStart; - dashboardService: DashboardStart; } export type StartServices = CoreStart & StartPlugins & MlServicesContext; export const useMlFromLensKibanaContext = () => useKibana(); diff --git a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/lens/lens_vis_layer_selection_flyout/layer/compatible_layer.tsx b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/lens/lens_vis_layer_selection_flyout/layer/compatible_layer.tsx index 463f432db28b5..b55c85821adf7 100644 --- a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/lens/lens_vis_layer_selection_flyout/layer/compatible_layer.tsx +++ b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/lens/lens_vis_layer_selection_flyout/layer/compatible_layer.tsx @@ -33,7 +33,6 @@ export const CompatibleLayer: FC = ({ layer, layerIndex, embeddable }) => share, uiSettings, lens, - dashboardService, mlServices: { mlApi }, }, } = useMlFromLensKibanaContext(); @@ -45,7 +44,7 @@ export const CompatibleLayer: FC = ({ layer, layerIndex, embeddable }) => data.dataViews, uiSettings, data.query.timefilter.timefilter, - dashboardService, + share, mlApi ), // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/map/map_vis_layer_selection_flyout/layer/compatible_layer.tsx b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/map/map_vis_layer_selection_flyout/layer/compatible_layer.tsx index 8847d21b2f4e3..92fbc56c98c76 100644 --- a/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/map/map_vis_layer_selection_flyout/layer/compatible_layer.tsx +++ b/x-pack/platform/plugins/shared/ml/public/embeddables/job_creation/map/map_vis_layer_selection_flyout/layer/compatible_layer.tsx @@ -50,7 +50,6 @@ export const CompatibleLayer: FC = ({ embeddable, layer, layerIndex }) => data, share, uiSettings, - dashboardService, mlServices: { mlApi }, }, } = useMlFromLensKibanaContext(); @@ -61,7 +60,7 @@ export const CompatibleLayer: FC = ({ embeddable, layer, layerIndex }) => data.dataViews, uiSettings, data.query.timefilter.timefilter, - dashboardService, + share, mlApi ), // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/x-pack/platform/plugins/shared/ml/public/plugin.ts b/x-pack/platform/plugins/shared/ml/public/plugin.ts index 9f634ca9cbcbd..a06f0470a80d4 100644 --- a/x-pack/platform/plugins/shared/ml/public/plugin.ts +++ b/x-pack/platform/plugins/shared/ml/public/plugin.ts @@ -44,7 +44,7 @@ import type { DataVisualizerPluginStart } from '@kbn/data-visualizer-plugin/publ import type { PluginSetupContract as AlertingSetup } from '@kbn/alerting-plugin/public'; import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; import type { FieldFormatsSetup } from '@kbn/field-formats-plugin/public'; -import type { DashboardSetup, DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { DashboardStart } from '@kbn/dashboard-plugin/public'; import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; import type { CasesPublicSetup, CasesPublicStart } from '@kbn/cases-plugin/public'; import type { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public'; @@ -107,7 +107,6 @@ export interface MlStartDependencies { export interface MlSetupDependencies { alerting?: AlertingSetup; cases?: CasesPublicSetup; - dashboard: DashboardSetup; embeddable: EmbeddableSetup; fieldFormats: FieldFormatsSetup; home?: HomePublicPluginSetup; From 42a9cc742cac4cd076d8ebfc66c2e9a8ab6411b4 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 3 Mar 2025 14:29:44 -0700 Subject: [PATCH 5/7] clean up --- .../new_job/job_from_dashboard/quick_create_job_base.ts | 4 ++-- .../jobs/new_job/job_from_lens/quick_create_job.ts | 4 ++-- .../jobs/new_job/job_from_map/quick_create_job.ts | 4 ++-- .../new_job/job_from_pattern_analysis/quick_create_job.ts | 4 ++-- .../public/application/services/dashboard_service.test.ts | 7 +++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts index 391280e365995..9a8e8bc881aec 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts @@ -53,7 +53,7 @@ export class QuickJobCreatorBase { protected readonly dataViews: DataViewsContract, protected readonly kibanaConfig: IUiSettingsClient, protected readonly timeFilter: TimefilterContract, - protected readonly shareService: SharePluginStart, + protected readonly share: SharePluginStart, protected readonly mlApi: MlApi ) {} @@ -244,7 +244,7 @@ export class QuickJobCreatorBase { ), }; - const location = await this.shareService.url.locators + const location = await this.share.url.locators .get(DASHBOARD_APP_LOCATOR) ?.getLocation(params); if (location === undefined) { diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts index 20d5f3ab9f745..f83923c9605be 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_lens/quick_create_job.ts @@ -41,10 +41,10 @@ export class QuickLensJobCreator extends QuickJobCreatorBase { dataViews: DataViewsContract, kibanaConfig: IUiSettingsClient, timeFilter: TimefilterContract, - shareService: SharePluginStart, + share: SharePluginStart, mlApi: MlApi ) { - super(dataViews, kibanaConfig, timeFilter, shareService, mlApi); + super(dataViews, kibanaConfig, timeFilter, share, mlApi); } public async createAndSaveJob( diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts index fa5008755bc46..3db89c6cef34e 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_map/quick_create_job.ts @@ -42,10 +42,10 @@ export class QuickGeoJobCreator extends QuickJobCreatorBase { dataViews: DataViewsContract, kibanaConfig: IUiSettingsClient, timeFilter: TimefilterContract, - shareService: SharePluginStart, + share: SharePluginStart, mlApi: MlApi ) { - super(dataViews, kibanaConfig, timeFilter, shareService, mlApi); + super(dataViews, kibanaConfig, timeFilter, share, mlApi); } public async createAndSaveGeoJob({ diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts index eae64ffbda5c1..01531dad4d6d1 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_pattern_analysis/quick_create_job.ts @@ -34,11 +34,11 @@ export class QuickCategorizationJobCreator extends QuickJobCreatorBase { dataViews: DataViewsContract, kibanaConfig: IUiSettingsClient, timeFilter: TimefilterContract, - shareService: SharePluginStart, + share: SharePluginStart, private data: DataPublicPluginStart, mlApi: MlApi ) { - super(dataViews, kibanaConfig, timeFilter, shareService, mlApi); + super(dataViews, kibanaConfig, timeFilter, share, mlApi); } public async createAndSaveJob( diff --git a/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts b/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts index e51fdf0e0dc6c..b3d3915397f33 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/services/dashboard_service.test.ts @@ -24,18 +24,17 @@ describe('DashboardService', () => { }), }; - const share: SharePluginStart = { + const shareMock = { url: { locators: { - // @ts-expect-error Only partial mock of full plugin get: () => ({ getUrl: getUrlMock, }), }, }, - }; + } as unknown as SharePluginStart; - const dashboardService = dashboardServiceProvider(dashboard, share); + const dashboardService = dashboardServiceProvider(dashboard, shareMock); test('should fetch dashboard', async () => { // act From a3e91011f412f481fd87180f0d824d3285266b4b Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:36:27 +0000 Subject: [PATCH 6/7] [CI] Auto-commit changed files from 'node scripts/yarn_deduplicate' --- .../platform/plugins/shared/dashboard_enhanced/tsconfig.json | 3 ++- x-pack/platform/plugins/shared/ml/tsconfig.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/platform/plugins/shared/dashboard_enhanced/tsconfig.json b/x-pack/platform/plugins/shared/dashboard_enhanced/tsconfig.json index b8026be8652b2..4addfafe9fc33 100644 --- a/x-pack/platform/plugins/shared/dashboard_enhanced/tsconfig.json +++ b/x-pack/platform/plugins/shared/dashboard_enhanced/tsconfig.json @@ -21,7 +21,8 @@ "@kbn/presentation-util-plugin", "@kbn/presentation-containers", "@kbn/presentation-publishing", - "@kbn/react-kibana-mount" + "@kbn/react-kibana-mount", + "@kbn/deeplinks-analytics" ], "exclude": ["target/**/*"] } diff --git a/x-pack/platform/plugins/shared/ml/tsconfig.json b/x-pack/platform/plugins/shared/ml/tsconfig.json index 82f32e5a0c7e1..415f507611cde 100644 --- a/x-pack/platform/plugins/shared/ml/tsconfig.json +++ b/x-pack/platform/plugins/shared/ml/tsconfig.json @@ -140,5 +140,6 @@ "@kbn/response-ops-rule-params", "@kbn/unsaved-changes-prompt", "@kbn/core-analytics-browser", + "@kbn/deeplinks-analytics", ] } From 6c2bedebba7771601fc6fad856ce777d08695425 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 3 Mar 2025 22:01:25 +0000 Subject: [PATCH 7/7] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../embeddable_to_dashboard_drilldown.test.tsx | 6 +++--- .../new_job/job_from_dashboard/quick_create_job_base.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx b/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx index 474de384eedbb..83728cb2ec8bf 100644 --- a/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx +++ b/x-pack/platform/plugins/shared/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx @@ -99,9 +99,9 @@ describe('.execute() & getHref', () => { getLocation: async (params: DashboardLocatorParams) => { return await definition.getLocation(params); }, - }) - } - } + }), + }, + }, }, }, self: {}, diff --git a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts index 9a8e8bc881aec..5a16659027f2b 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/job_from_dashboard/quick_create_job_base.ts @@ -244,9 +244,7 @@ export class QuickJobCreatorBase { ), }; - const location = await this.share.url.locators - .get(DASHBOARD_APP_LOCATOR) - ?.getLocation(params); + const location = await this.share.url.locators.get(DASHBOARD_APP_LOCATOR)?.getLocation(params); if (location === undefined) { return null; }