@@ -33,6 +33,18 @@ const CreateMonitor = () => {
33
33
{ _id : 5 , name : "5 minutes" } ,
34
34
] ;
35
35
36
+ const matchMethodOptions = [
37
+ { _id : "equal" , name : "Equal" } ,
38
+ { _id : "include" , name : "Include" } ,
39
+ { _id : "regex" , name : "Regex" } ,
40
+ ] ;
41
+
42
+ const expectedValuePlaceholders = {
43
+ regex :
"^[\w.-][email protected] $" ,
44
+
45
+ include : "@gmail.com"
46
+ } ;
47
+
36
48
const monitorTypeMaps = {
37
49
http : {
38
50
label : "URL to monitor" ,
@@ -92,6 +104,12 @@ const CreateMonitor = () => {
92
104
interval : monitor . interval * MS_PER_MINUTE ,
93
105
} ;
94
106
107
+ if ( monitor . type === "http" ) {
108
+ form . expectedValue = monitor . expectedValue ;
109
+ form . jsonPath = monitor . jsonPath ;
110
+ form . matchMethod = monitor . matchMethod ;
111
+ }
112
+
95
113
const { error } = monitorValidation . validate ( form , {
96
114
abortEarly : false ,
97
115
} ) ;
@@ -398,6 +416,61 @@ const CreateMonitor = () => {
398
416
onChange = { ( event ) => handleChange ( event , "interval" ) }
399
417
items = { SELECT_VALUES }
400
418
/>
419
+ {
420
+ monitor . type === "http" && < >
421
+ < Select
422
+ id = "match-method"
423
+ label = "Match Method"
424
+ value = { monitor . matchMethod || "equal" }
425
+ onChange = { ( event ) => handleChange ( event , "matchMethod" ) }
426
+ items = { matchMethodOptions }
427
+ />
428
+ < Stack >
429
+ < TextInput
430
+ type = "text"
431
+ id = "expected-value"
432
+ label = "Expected value"
433
+ isOptional = { true }
434
+ placeholder = { expectedValuePlaceholders [ monitor . matchMethod || "equal" ] }
435
+ value = { monitor . expectedValue }
436
+ onChange = { ( event ) => handleChange ( event , "expectedValue" ) }
437
+ error = { errors [ "expectedValue" ] ? true : false }
438
+ helperText = { errors [ "expectedValue" ] }
439
+ />
440
+ < Typography
441
+ component = "span"
442
+ color = { theme . palette . primary . contrastTextTertiary }
443
+ opacity = { 0.8 }
444
+ >
445
+ The expected value is used to match against response result, and the match determines the status.
446
+ </ Typography >
447
+ </ Stack >
448
+ < Stack >
449
+ < TextInput
450
+ type = "text"
451
+ id = "json-path"
452
+ label = "JSON Path"
453
+ isOptional = { true }
454
+ placeholder = "data.email"
455
+ value = { monitor . jsonPath }
456
+ onChange = { ( event ) => handleChange ( event , "jsonPath" ) }
457
+ error = { errors [ "jsonPath" ] ? true : false }
458
+ helperText = { errors [ "jsonPath" ] }
459
+ />
460
+ < Typography
461
+ component = "span"
462
+ color = { theme . palette . primary . contrastTextTertiary }
463
+ opacity = { 0.8 }
464
+ >
465
+ This expression will be evaluated against the reponse JSON data and the result will be used to match against the expected value. See
466
+ < Typography component = "a" href = "https://jmespath.org/" target = "_blank" color = "info" >
467
+ jmespath.org
468
+ </ Typography >
469
+ for query language documentation.
470
+ </ Typography >
471
+ </ Stack >
472
+ </ >
473
+ }
401
474
</ Stack >
402
475
</ ConfigBox >
403
476
< Stack
0 commit comments