@@ -23,6 +23,7 @@ import {
23
23
getPlugins ,
24
24
successNotificationToast ,
25
25
} from '../../../../utils/helpers' ;
26
+ import { DetectorCreationStep } from '../../../CreateDetector/models/types' ;
26
27
27
28
export interface UpdateAlertConditionsProps
28
29
extends RouteComponentProps < any , any , { detectorHit : DetectorHit } > {
@@ -39,6 +40,7 @@ export interface UpdateAlertConditionsState {
39
40
rulesOptions : RuleOptions [ ] ;
40
41
submitting : boolean ;
41
42
plugins : string [ ] ;
43
+ isTriggerNameValid : boolean ;
42
44
}
43
45
44
46
export default class UpdateAlertConditions extends Component <
@@ -53,6 +55,7 @@ export default class UpdateAlertConditions extends Component<
53
55
rulesOptions : [ ] ,
54
56
submitting : false ,
55
57
plugins : [ ] ,
58
+ isTriggerNameValid : true ,
56
59
} ;
57
60
}
58
61
@@ -189,8 +192,15 @@ export default class UpdateAlertConditions extends Component<
189
192
} ) ;
190
193
} ;
191
194
195
+ updateDataValidState = ( step : DetectorCreationStep , isValid : boolean ) : void => {
196
+ this . setState ( {
197
+ isTriggerNameValid : isValid ,
198
+ } ) ;
199
+ } ;
200
+
192
201
render ( ) {
193
- const { detector, rulesOptions, submitting } = this . state ;
202
+ const { detector, rulesOptions, submitting, isTriggerNameValid } = this . state ;
203
+ const isSaveDisabled = submitting || ! isTriggerNameValid ;
194
204
return (
195
205
< div >
196
206
< ConfigureAlerts
@@ -199,7 +209,7 @@ export default class UpdateAlertConditions extends Component<
199
209
detector = { detector }
200
210
rulesOptions = { rulesOptions }
201
211
changeDetector = { this . changeDetector }
202
- updateDataValidState = { ( ) => { } }
212
+ updateDataValidState = { this . updateDataValidState }
203
213
hasNotificationPlugin = { this . state . plugins . includes ( OS_NOTIFICATION_PLUGIN ) }
204
214
/>
205
215
@@ -211,7 +221,7 @@ export default class UpdateAlertConditions extends Component<
211
221
</ EuiFlexItem >
212
222
< EuiFlexItem grow = { false } >
213
223
< EuiButton
214
- disabled = { submitting }
224
+ disabled = { isSaveDisabled }
215
225
fill = { true }
216
226
isLoading = { submitting }
217
227
onClick = { this . onSave }
0 commit comments