diff --git a/x-pack/plugins/ml/common/constants/jobs_list.js b/x-pack/plugins/ml/common/constants/jobs_list.js new file mode 100644 index 000000000000..2055316d2bba --- /dev/null +++ b/x-pack/plugins/ml/common/constants/jobs_list.js @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + +export const DEFAULT_REFRESH_INTERVAL_MS = 30000; +export const MINIMUM_REFRESH_INTERVAL_MS = 5000; +export const DELETING_JOBS_REFRESH_INTERVAL_MS = 2000; diff --git a/x-pack/plugins/ml/common/constants/states.js b/x-pack/plugins/ml/common/constants/states.js index 92cce766ddaf..4584171c713f 100644 --- a/x-pack/plugins/ml/common/constants/states.js +++ b/x-pack/plugins/ml/common/constants/states.js @@ -12,14 +12,14 @@ export const DATAFEED_STATE = { STARTING: 'starting', STOPPED: 'stopped', STOPPING: 'stopping', - DELETED: 'deleted' + DELETED: 'deleted', }; export const FORECAST_REQUEST_STATE = { FAILED: 'failed', FINISHED: 'finished', SCHEDULED: 'scheduled', - STARTED: 'started' + STARTED: 'started', }; export const JOB_STATE = { @@ -27,5 +27,6 @@ export const JOB_STATE = { CLOSING: 'closing', FAILED: 'failed', OPENED: 'opened', - OPENING: 'opening' + OPENING: 'opening', + DELETED: 'deleted', }; diff --git a/x-pack/plugins/ml/public/jobs/jobs_list/components/delete_job_modal/delete_job_modal.js b/x-pack/plugins/ml/public/jobs/jobs_list/components/delete_job_modal/delete_job_modal.js index 578c6ad76b93..c8ff5b2a6072 100644 --- a/x-pack/plugins/ml/public/jobs/jobs_list/components/delete_job_modal/delete_job_modal.js +++ b/x-pack/plugins/ml/public/jobs/jobs_list/components/delete_job_modal/delete_job_modal.js @@ -19,6 +19,7 @@ import { } from '@elastic/eui'; import { deleteJobs } from '../utils'; +import { DELETING_JOBS_REFRESH_INTERVAL_MS } from '../../../../../common/constants/jobs_list'; import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; export const DeleteJobModal = injectI18n(class extends Component { @@ -70,9 +71,9 @@ export const DeleteJobModal = injectI18n(class extends Component { deleteJobs(this.state.jobs); setTimeout(() => { + this.closeModal(); this.refreshJobs(); - }, 500); - this.closeModal(); + }, DELETING_JOBS_REFRESH_INTERVAL_MS); } setEL = (el) => { diff --git a/x-pack/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js b/x-pack/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js index d0683eef0531..cc2acc170afb 100644 --- a/x-pack/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js +++ b/x-pack/plugins/ml/public/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js @@ -24,6 +24,12 @@ import { UpgradeWarning } from '../../../../components/upgrade'; import { RefreshJobsListButton } from '../refresh_jobs_list_button'; import { isEqual } from 'lodash'; +import { + DEFAULT_REFRESH_INTERVAL_MS, + MINIMUM_REFRESH_INTERVAL_MS, + DELETING_JOBS_REFRESH_INTERVAL_MS, +} from '../../../../../common/constants/jobs_list'; + import React, { Component } from 'react'; @@ -34,9 +40,7 @@ import { EuiSpacer, } from '@elastic/eui'; -const DEFAULT_REFRESH_INTERVAL_MS = 30000; -const MINIMUM_REFRESH_INTERVAL_MS = 5000; -const DELETING_JOBS_REFRESH_INTERVAL_MS = 2000; + let jobsRefreshInterval = null; let deletingJobsRefreshTimeout = null; diff --git a/x-pack/plugins/ml/public/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/jobs/jobs_list/components/utils.js index 173daf41c4b0..ad442db8897f 100644 --- a/x-pack/plugins/ml/public/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/jobs/jobs_list/components/utils.js @@ -179,7 +179,7 @@ export function deleteJobs(jobs, finish = () => {}) { const jobIds = jobs.map(j => j.id); mlJobService.deleteJobs(jobIds) .then((resp) => { - showResults(resp, DATAFEED_STATE.DELETED); + showResults(resp, JOB_STATE.DELETED); finish(); }) .catch((error) => {