Skip to content

Commit

Permalink
[ML] Always enable next button in advanced job validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 30, 2020
1 parent 855a33c commit f5af7b5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { JobCreatorContext } from '../job_creator_context';
import { ml } from '../../../../../services/ml_api_service';
import { ValidateJob } from '../../../../../components/validate_job';
import { JOB_TYPE } from '../../../../../../../common/constants/new_job';
import { ValidationWarningCallout } from './validation_warning_callout';

const idFilterList = [
'job_id_valid',
Expand Down Expand Up @@ -56,7 +57,7 @@ export const ValidationStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep })
// caught in previous basic checks
function setIsValid(valid: boolean) {
jobValidator.advancedValid = valid;
setNextActive(valid);
setNextActive(jobCreator.type === JOB_TYPE.ADVANCED || valid);
}

return (
Expand All @@ -71,6 +72,7 @@ export const ValidationStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep })
setIsValid={setIsValid}
idFilterList={idFilterList}
/>
{jobCreator.type === JOB_TYPE.ADVANCED && <ValidationWarningCallout />}
<WizardNav
previous={() => setCurrentStep(WIZARD_STEPS.JOB_DETAILS)}
next={() => setCurrentStep(WIZARD_STEPS.SUMMARY)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.
*/

import React, { FC, useContext, useEffect, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCallOut } from '@elastic/eui';
import { JobCreatorContext } from '../job_creator_context';
import { JOB_TYPE } from '../../../../../../../common/constants/new_job';

export const ValidationWarningCallout: FC = () => {
const { jobCreator, jobValidator, jobValidatorUpdated } = useContext(JobCreatorContext);
const [valid, setValid] = useState(false);

useEffect(() => {
setValid(jobValidator.validationSummary.advanced);
}, [jobValidatorUpdated]);

return jobCreator.type === JOB_TYPE.ADVANCED && valid === false ? (
<EuiCallOut
title={
<FormattedMessage
id="xpack.ml.newJob.wizard.validationStep.validationWarning.title"
defaultMessage="Validation failed"
/>
}
color="warning"
iconType="alert"
>
<FormattedMessage
id="xpack.ml.newJob.wizard.validationStep.validationWarning.message"
defaultMessage="Job validation has failed, however for the advanced wizard it is still possible to continue to create the job.
Please be aware the this job may encounter problems when running."
/>
</EuiCallOut>
) : null;
};

0 comments on commit f5af7b5

Please sign in to comment.