Skip to content

Commit

Permalink
use shared constant for job state
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Jul 9, 2020
1 parent c37ceb4 commit 469e59f
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useMlKibana } from '../../../../../contexts/kibana';
import { getDataFrameAnalyticsProgressPhase } from '../../../analytics_management/components/analytics_list/common';
import {
getDataFrameAnalyticsProgressPhase,
DATA_FRAME_TASK_STATE,
} from '../../../analytics_management/components/analytics_list/common';
import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics';
import { ml } from '../../../../../services/ml_api_service';
import { DataFrameAnalyticsId } from '../../../../common/analytics';

export const PROGRESS_REFRESH_INTERVAL_MS = 1000;
const FAILED = 'failed';
const STOPPED = 'stopped';

export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) => {
const [initialized, setInitialized] = useState<boolean>(false);
Expand Down Expand Up @@ -55,7 +56,7 @@ export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) =>
if (jobStats !== undefined) {
const progressStats = getDataFrameAnalyticsProgressPhase(jobStats);

if (jobStats.state === FAILED) {
if (jobStats.state === DATA_FRAME_TASK_STATE.FAILED) {
clearInterval(interval);
setFailedJobMessage(
jobStats.failure_reason ||
Expand All @@ -73,7 +74,7 @@ export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) =>
if (
(progressStats.currentPhase === progressStats.totalPhases &&
progressStats.progress === 100) ||
jobStats.state === STOPPED
jobStats.state === DATA_FRAME_TASK_STATE.STOPPED
) {
clearInterval(interval);
}
Expand Down

0 comments on commit 469e59f

Please sign in to comment.