@@ -20,7 +20,6 @@ import {
2020 EuiTitle ,
2121 EuiButtonEmpty ,
2222 EuiSpacer ,
23- EuiCallOut ,
2423} from '@elastic/eui' ;
2524import {
2625 createDetector ,
@@ -30,7 +29,7 @@ import {
3029 validateDetector ,
3130} from '../../../redux/reducers/ad' ;
3231import { Formik , FormikHelpers } from 'formik' ;
33- import { get } from 'lodash' ;
32+ import { get , isEmpty } from 'lodash' ;
3433import React , { Fragment , useEffect , useState } from 'react' ;
3534import { RouteComponentProps } from 'react-router' ;
3635import { useDispatch , useSelector } from 'react-redux' ;
@@ -54,7 +53,6 @@ import {
5453 ValidationSettingResponse ,
5554 VALIDATION_ISSUE_TYPES ,
5655} from '../../../models/interfaces' ;
57- import { isEmpty } from 'lodash' ;
5856
5957interface ReviewAndCreateProps extends RouteComponentProps {
6058 setStep ( stepNumber : number ) : void ;
@@ -92,28 +90,49 @@ export function ReviewAndCreate(props: ReviewAndCreateProps) {
9290 // meaning validation has passed and succesful callout will display or validation has failed
9391 // and callouts displaying what the issue is will be displayed instead.
9492 useEffect ( ( ) => {
95- dispatch ( validateDetector ( formikToDetector ( props . values ) ) )
93+ dispatch ( validateDetector ( formikToDetector ( props . values ) , 'model' ) )
9694 . then ( ( resp : any ) => {
9795 if ( isEmpty ( Object . keys ( resp . response ) ) ) {
9896 setValidDetectorSettings ( true ) ;
9997 setValidModelConfigurations ( true ) ;
10098 } else {
101- if ( resp . response . hasOwnProperty ( 'detector' ) ) {
102- const issueType = Object . keys ( resp . response . detector ) [ 0 ] ;
103- if ( resp . response . detector [ issueType ] . hasOwnProperty ( 'message' ) ) {
99+ if (
100+ resp . response . hasOwnProperty ( 'detector' ) ||
101+ resp . response . hasOwnProperty ( 'model' )
102+ ) {
103+ const validationType = Object . keys ( resp . response ) [ 0 ] ;
104+ const issueType = Object . keys ( resp . response [ validationType ] ) [ 0 ] ;
105+ if (
106+ resp . response [ validationType ] [ issueType ] . hasOwnProperty ( 'message' )
107+ ) {
104108 const validationMessage =
105- resp . response . detector [ issueType ] . message ;
109+ resp . response [ validationType ] [ issueType ] . message ;
106110 const detectorSettingIssue : ValidationSettingResponse = {
107111 issueType : issueType ,
108112 message : validationMessage ,
113+ validationType : validationType ,
109114 } ;
115+
116+ // These issue types only come up during non-blocker validation after blocker validation has passed
117+ // This means that the configurations don't have any blocking issues but request either timed out during
118+ // non blocking validation or due to an issue in core. This means we aren't able to provide any recommendation
119+ // and user has no way of re-trying except re-rendering page which isn't straightforward. At the moment we will
120+ // hide these failures instead of explaining both levels of validation being done in the backend.
121+ if ( issueType == 'aggregation' || issueType == 'timeout' ) {
122+ setValidDetectorSettings ( true ) ;
123+ setValidModelConfigurations ( true ) ;
124+ return ;
125+ }
126+
110127 switch ( issueType ) {
128+ // need to handle model validation issue case seperatly
111129 case VALIDATION_ISSUE_TYPES . FEATURE_ATTRIBUTES :
112130 case VALIDATION_ISSUE_TYPES . CATEGORY :
113131 case VALIDATION_ISSUE_TYPES . SHINGLE_SIZE_FIELD :
114- const modelResp = resp . response . detector [
132+ const modelResp = resp . response [ validationType ] [
115133 issueType
116134 ] as ValidationModelResponse ;
135+ modelResp . validationType = validationType ;
117136 setFeatureResponse ( modelResp ) ;
118137 setValidDetectorSettings ( true ) ;
119138 setValidModelConfigurations ( false ) ;
@@ -313,7 +332,6 @@ export function ReviewAndCreate(props: ReviewAndCreateProps) {
313332 iconType = "arrowLeft"
314333 fill = { false }
315334 data-test-subj = "reviewAndCreatePreviousButton"
316- //@ts -ignore
317335 onClick = { ( ) => {
318336 props . setStep ( 3 ) ;
319337 } }
0 commit comments