Skip to content

Commit

Permalink
[ML] Fixing groups dropdown in AD job wizards (elastic#180785)
Browse files Browse the repository at this point in the history
Fixing bug introduced in elastic#176788
The `jobService` hasn't been initialised when being used to load the
groups.
  • Loading branch information
jgowdyelastic authored Apr 15, 2024
1 parent 59055c6 commit e7e5105
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useMlKibana, useNavigateToPath } from '../../../contexts/kibana';
import type { MlRoute, PageProps } from '../../router';
import { createPath, PageLoader } from '../../router';
import { useRouteResolver } from '../../use_resolver';
import { mlJobService } from '../../../services/job_service';
import { mlJobServiceFactory } from '../../../services/job_service';
import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs';
import { useCreateADLinks } from '../../../components/custom_hooks/use_create_ad_links';
import { DataSourceContextProvider } from '../../../contexts/ml';
Expand Down Expand Up @@ -54,10 +54,15 @@ export const checkViewOrCreateRouteFactory = (): MlRoute => ({

const PageWrapper: FC<PageProps> = ({ location }) => {
const { id } = parse(location.search, { sort: false });
const {
services: {
mlServices: { mlApiServices },
},
} = useMlKibana();

const { context, results } = useRouteResolver('full', ['canGetJobs'], {
...basicResolvers(),
existingJobsAndGroups: mlJobService.getJobAndGroupIds,
existingJobsAndGroups: () => mlJobServiceFactory(undefined, mlApiServices).getJobAndGroupIds(),
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { MlRoute, PageProps } from '../../router';
import { createPath, PageLoader } from '../../router';
import { useRouteResolver } from '../../use_resolver';
import { JOB_TYPE } from '../../../../../common/constants/new_job';
import { mlJobService } from '../../../services/job_service';
import { mlJobServiceFactory } from '../../../services/job_service';
import {
loadNewJobCapabilities,
ANOMALY_DETECTOR,
Expand Down Expand Up @@ -206,6 +206,7 @@ const PageWrapper: FC<WizardPageProps> = ({ location, jobType }) => {
services: {
data: { dataViews: dataViewsService },
savedSearch: savedSearchService,
mlServices: { mlApiServices },
},
} = useMlKibana();

Expand All @@ -221,7 +222,7 @@ const PageWrapper: FC<WizardPageProps> = ({ location, jobType }) => {
savedSearchService,
ANOMALY_DETECTOR
),
existingJobsAndGroups: mlJobService.getJobAndGroupIds,
existingJobsAndGroups: () => mlJobServiceFactory(undefined, mlApiServices).getJobAndGroupIds(),
});

return (
Expand Down

0 comments on commit e7e5105

Please sign in to comment.