Skip to content

Commit

Permalink
fixes after merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 4, 2024
1 parent 4ed9297 commit a670bd0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -43,7 +43,7 @@ export const CloseJobsConfirmModal: FC<Props> = ({
notifications: { toasts },
},
} = useMlKibana();
const mlApiService = useMlApiContext();
const mlApi = useMlApi();
const [modalVisible, setModalVisible] = useState(false);
const [hasManagedJob, setHasManaged] = useState(true);
const [jobsToReset, setJobsToReset] = useState<MlSummaryJob[]>([]);
Expand Down Expand Up @@ -120,7 +120,7 @@ export const CloseJobsConfirmModal: FC<Props> = ({

<EuiButton
onClick={() => {
closeJobs(toasts, mlApiService, jobsToReset, refreshJobs);
closeJobs(toasts, mlApi, jobsToReset, refreshJobs);
closeModal();
}}
fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -44,7 +44,7 @@ export const StopDatafeedsConfirmModal: FC<Props> = ({
notifications: { toasts },
},
} = useMlKibana();
const mlApiServices = useMlApiContext();
const mlApi = useMlApi();
const [modalVisible, setModalVisible] = useState(false);
const [hasManagedJob, setHasManaged] = useState(true);
const [jobsToStop, setJobsToStop] = useState<MlSummaryJob[]>([]);
Expand Down Expand Up @@ -121,7 +121,7 @@ export const StopDatafeedsConfirmModal: FC<Props> = ({

<EuiButton
onClick={() => {
stopDatafeeds(toasts, mlApiServices, jobsToStop, refreshJobs);
stopDatafeeds(toasts, mlApi, jobsToStop, refreshJobs);
closeModal();
}}
fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -45,7 +45,7 @@ export const DeleteJobModal: FC<Props> = ({ 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<MlSummaryJob[]>([]);
Expand Down Expand Up @@ -91,7 +91,7 @@ export const DeleteJobModal: FC<Props> = ({ setShowFunction, unsetShowFunction,
setDeleting(true);
deleteJobs(
toasts,
mlApiServices,
mlApi,
jobIds.map((id) => ({ id })),
deleteUserAnnotations,
deleteAlertingRules
Expand All @@ -101,15 +101,7 @@ export const DeleteJobModal: FC<Props> = ({ 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -168,7 +159,7 @@ class MultiJobActionsMenuUI extends Component {
} else {
stopDatafeeds(
this.toastNotifications,
this.mlApiServices,
this.mlApi,
this.props.jobs,
this.props.refreshJobs
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -44,7 +44,7 @@ export const ResetJobModal: FC<Props> = ({ 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<string[]>([]);
Expand Down Expand Up @@ -80,12 +80,12 @@ export const ResetJobModal: FC<Props> = ({ 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;
Expand Down

0 comments on commit a670bd0

Please sign in to comment.