@@ -20,7 +20,6 @@ import {
20
20
EuiTitle ,
21
21
EuiButtonEmpty ,
22
22
EuiSpacer ,
23
- EuiCallOut ,
24
23
} from '@elastic/eui' ;
25
24
import {
26
25
createDetector ,
@@ -30,7 +29,7 @@ import {
30
29
validateDetector ,
31
30
} from '../../../redux/reducers/ad' ;
32
31
import { Formik , FormikHelpers } from 'formik' ;
33
- import { get } from 'lodash' ;
32
+ import { get , isEmpty } from 'lodash' ;
34
33
import React , { Fragment , useEffect , useState } from 'react' ;
35
34
import { RouteComponentProps } from 'react-router' ;
36
35
import { useDispatch , useSelector } from 'react-redux' ;
@@ -54,7 +53,6 @@ import {
54
53
ValidationSettingResponse ,
55
54
VALIDATION_ISSUE_TYPES ,
56
55
} from '../../../models/interfaces' ;
57
- import { isEmpty } from 'lodash' ;
58
56
59
57
interface ReviewAndCreateProps extends RouteComponentProps {
60
58
setStep ( stepNumber : number ) : void ;
@@ -92,28 +90,49 @@ export function ReviewAndCreate(props: ReviewAndCreateProps) {
92
90
// meaning validation has passed and succesful callout will display or validation has failed
93
91
// and callouts displaying what the issue is will be displayed instead.
94
92
useEffect ( ( ) => {
95
- dispatch ( validateDetector ( formikToDetector ( props . values ) ) )
93
+ dispatch ( validateDetector ( formikToDetector ( props . values ) , 'model' ) )
96
94
. then ( ( resp : any ) => {
97
95
if ( isEmpty ( Object . keys ( resp . response ) ) ) {
98
96
setValidDetectorSettings ( true ) ;
99
97
setValidModelConfigurations ( true ) ;
100
98
} 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
+ ) {
104
108
const validationMessage =
105
- resp . response . detector [ issueType ] . message ;
109
+ resp . response [ validationType ] [ issueType ] . message ;
106
110
const detectorSettingIssue : ValidationSettingResponse = {
107
111
issueType : issueType ,
108
112
message : validationMessage ,
113
+ validationType : validationType ,
109
114
} ;
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
+
110
127
switch ( issueType ) {
128
+ // need to handle model validation issue case seperatly
111
129
case VALIDATION_ISSUE_TYPES . FEATURE_ATTRIBUTES :
112
130
case VALIDATION_ISSUE_TYPES . CATEGORY :
113
131
case VALIDATION_ISSUE_TYPES . SHINGLE_SIZE_FIELD :
114
- const modelResp = resp . response . detector [
132
+ const modelResp = resp . response [ validationType ] [
115
133
issueType
116
134
] as ValidationModelResponse ;
135
+ modelResp . validationType = validationType ;
117
136
setFeatureResponse ( modelResp ) ;
118
137
setValidDetectorSettings ( true ) ;
119
138
setValidModelConfigurations ( false ) ;
@@ -313,7 +332,6 @@ export function ReviewAndCreate(props: ReviewAndCreateProps) {
313
332
iconType = "arrowLeft"
314
333
fill = { false }
315
334
data-test-subj = "reviewAndCreatePreviousButton"
316
- //@ts -ignore
317
335
onClick = { ( ) => {
318
336
props . setStep ( 3 ) ;
319
337
} }
0 commit comments