diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/close_jobs_confirm_modal.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/close_jobs_confirm_modal.tsx index 8fbc34d5282d3..45a94e618b12a 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/close_jobs_confirm_modal.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/close_jobs_confirm_modal.tsx @@ -19,7 +19,7 @@ import { EuiButton, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { useMlApiContext, useMlKibana } from '../../../../contexts/kibana'; +import { useMlApi, useMlKibana } from '../../../../contexts/kibana'; import type { MlSummaryJob } from '../../../../../../common/types/anomaly_detection_jobs'; import { isManagedJob } from '../../../jobs_utils'; import { closeJobs } from '../utils'; @@ -43,7 +43,7 @@ export const CloseJobsConfirmModal: FC = ({ notifications: { toasts }, }, } = useMlKibana(); - const mlApiService = useMlApiContext(); + const mlApi = useMlApi(); const [modalVisible, setModalVisible] = useState(false); const [hasManagedJob, setHasManaged] = useState(true); const [jobsToReset, setJobsToReset] = useState([]); @@ -120,7 +120,7 @@ export const CloseJobsConfirmModal: FC = ({ { - closeJobs(toasts, mlApiService, jobsToReset, refreshJobs); + closeJobs(toasts, mlApi, jobsToReset, refreshJobs); closeModal(); }} fill diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/stop_datafeeds_confirm_modal.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/stop_datafeeds_confirm_modal.tsx index e99134402fe44..6d12deb9ebaed 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/stop_datafeeds_confirm_modal.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/confirm_modals/stop_datafeeds_confirm_modal.tsx @@ -19,7 +19,7 @@ import { EuiButton, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { useMlApiContext, useMlKibana } from '../../../../contexts/kibana'; +import { useMlApi, useMlKibana } from '../../../../contexts/kibana'; import type { MlSummaryJob } from '../../../../../../common/types/anomaly_detection_jobs'; import { isManagedJob } from '../../../jobs_utils'; import { stopDatafeeds } from '../utils'; @@ -44,7 +44,7 @@ export const StopDatafeedsConfirmModal: FC = ({ notifications: { toasts }, }, } = useMlKibana(); - const mlApiServices = useMlApiContext(); + const mlApi = useMlApi(); const [modalVisible, setModalVisible] = useState(false); const [hasManagedJob, setHasManaged] = useState(true); const [jobsToStop, setJobsToStop] = useState([]); @@ -121,7 +121,7 @@ export const StopDatafeedsConfirmModal: FC = ({ { - stopDatafeeds(toasts, mlApiServices, jobsToStop, refreshJobs); + stopDatafeeds(toasts, mlApi, jobsToStop, refreshJobs); closeModal(); }} fill diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/delete_job_modal/delete_job_modal.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/delete_job_modal/delete_job_modal.tsx index 029c0df4dcdad..c8296c5afbef7 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/delete_job_modal/delete_job_modal.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/delete_job_modal/delete_job_modal.tsx @@ -23,7 +23,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { useMlApiContext, useMlKibana } from '../../../../contexts/kibana'; +import { useMlApi, useMlKibana } from '../../../../contexts/kibana'; import { deleteJobs } from '../utils'; import { BLOCKED_JOBS_REFRESH_INTERVAL_MS } from '../../../../../../common/constants/jobs_list'; import { DeleteSpaceAwareItemCheckModal } from '../../../../components/delete_space_aware_item_check_modal'; @@ -45,7 +45,7 @@ export const DeleteJobModal: FC = ({ setShowFunction, unsetShowFunction, notifications: { toasts }, }, } = useMlKibana(); - const mlApiServices = useMlApiContext(); + const mlApi = useMlApi(); const [deleting, setDeleting] = useState(false); const [modalVisible, setModalVisible] = useState(false); const [adJobs, setAdJobs] = useState([]); @@ -91,7 +91,7 @@ export const DeleteJobModal: FC = ({ setShowFunction, unsetShowFunction, setDeleting(true); deleteJobs( toasts, - mlApiServices, + mlApi, jobIds.map((id) => ({ id })), deleteUserAnnotations, deleteAlertingRules @@ -101,15 +101,7 @@ export const DeleteJobModal: FC = ({ setShowFunction, unsetShowFunction, closeModal(); refreshJobs(); }, BLOCKED_JOBS_REFRESH_INTERVAL_MS); - }, [ - toasts, - mlApiServices, - jobIds, - deleteUserAnnotations, - deleteAlertingRules, - closeModal, - refreshJobs, - ]); + }, [toasts, mlApi, jobIds, deleteUserAnnotations, deleteAlertingRules, closeModal, refreshJobs]); if (modalVisible === false || jobIds.length === 0) { return null; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/multi_job_actions/actions_menu.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/multi_job_actions/actions_menu.js index d35629e9cb021..02eef7d83f5b0 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/multi_job_actions/actions_menu.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/multi_job_actions/actions_menu.js @@ -44,17 +44,8 @@ class MultiJobActionsMenuUI extends Component { this.canResetJob = checkPermission('canResetJob') && mlNodesAvailable(); this.canCreateMlAlerts = checkPermission('canCreateMlAlerts'); -<<<<<<< HEAD this.toastNotifications = constructorContext.services.notifications.toasts; - this.mlApiServices = constructorContext.services.mlServices.mlApiServices; -======= - this.toastNoticiations = constructorContext.services.notifications.toasts; - const mlApi = constructorContext.services.mlServices.mlApi; - const toastNotificationService = toastNotificationServiceProvider( - constructorContext.services.notifications.toasts - ); - this.mlJobService = mlJobServiceFactory(toastNotificationService, mlApi); ->>>>>>> origin/main + this.mlApi = constructorContext.services.mlServices.mlApi; } onButtonClick = () => { @@ -119,7 +110,7 @@ class MultiJobActionsMenuUI extends Component { if (this.props.jobs.some((j) => isManagedJob(j))) { this.props.showCloseJobsConfirmModal(this.props.jobs); } else { - closeJobs(this.toastNotifications, this.mlApiServices, this.props.jobs); + closeJobs(this.toastNotifications, this.mlApi, this.props.jobs); } this.closePopover(); @@ -168,7 +159,7 @@ class MultiJobActionsMenuUI extends Component { } else { stopDatafeeds( this.toastNotifications, - this.mlApiServices, + this.mlApi, this.props.jobs, this.props.refreshJobs ); diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/reset_job_modal/reset_job_modal.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/reset_job_modal/reset_job_modal.tsx index 813b457efe841..cce101c9305e5 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/reset_job_modal/reset_job_modal.tsx +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/reset_job_modal/reset_job_modal.tsx @@ -25,7 +25,7 @@ import { i18n } from '@kbn/i18n'; import { resetJobs } from '../utils'; import type { MlSummaryJob } from '../../../../../../common/types/anomaly_detection_jobs'; import { RESETTING_JOBS_REFRESH_INTERVAL_MS } from '../../../../../../common/constants/jobs_list'; -import { useMlApiContext, useMlKibana } from '../../../../contexts/kibana'; +import { useMlApi, useMlKibana } from '../../../../contexts/kibana'; import { OpenJobsWarningCallout } from './open_jobs_warning_callout'; import { isManagedJob } from '../../../jobs_utils'; import { ManagedJobsWarningCallout } from '../confirm_modals/managed_jobs_warning_callout'; @@ -44,7 +44,7 @@ export const ResetJobModal: FC = ({ setShowFunction, unsetShowFunction, r notifications: { toasts }, }, } = useMlKibana(); - const mlApiServices = useMlApiContext(); + const mlApi = useMlApi(); const [resetting, setResetting] = useState(false); const [modalVisible, setModalVisible] = useState(false); const [jobIds, setJobIds] = useState([]); @@ -80,12 +80,12 @@ export const ResetJobModal: FC = ({ setShowFunction, unsetShowFunction, r const resetJob = useCallback(async () => { setResetting(true); - await resetJobs(toasts, mlApiServices, jobIds, deleteUserAnnotations); + await resetJobs(toasts, mlApi, jobIds, deleteUserAnnotations); closeModal(); setTimeout(() => { refreshJobs(); }, RESETTING_JOBS_REFRESH_INTERVAL_MS); - }, [closeModal, deleteUserAnnotations, jobIds, mlApiServices, refreshJobs, toasts]); + }, [closeModal, deleteUserAnnotations, jobIds, mlApi, refreshJobs, toasts]); if (modalVisible === false || jobIds.length === 0) { return null;