@@ -10,6 +10,8 @@ import {
10
10
Typography ,
11
11
Chip ,
12
12
Stack ,
13
+ Divider ,
14
+ FormControlLabel ,
13
15
} from "@mui/material" ;
14
16
import SearchIcon from "@mui/icons-material/Search" ;
15
17
import ClearIcon from "@mui/icons-material/Clear" ;
@@ -19,7 +21,7 @@ import ErrorIcon from "@mui/icons-material/Error";
19
21
import WarningIcon from "@mui/icons-material/Warning" ;
20
22
import HelpIcon from "@mui/icons-material/Help" ;
21
23
import MoreVertIcon from "@mui/icons-material/MoreVert" ;
22
- import { Controller , get , useForm } from "react-hook-form" ;
24
+ import { Controller , useForm } from "react-hook-form" ;
23
25
import { ApiGetCall } from "/src/api/ApiCall" ;
24
26
import CippButtonCard from "/src/components/CippCards/CippButtonCard" ;
25
27
import { CippCodeBlock } from "/src/components/CippComponents/CippCodeBlock" ;
@@ -268,6 +270,60 @@ function DomainResultCard({ title, data, isFetching, info, type }) {
268
270
</ >
269
271
) ,
270
272
}
273
+ : type === "HTTPS"
274
+ ? {
275
+ children : (
276
+ < >
277
+ { data ?. Tests ?. map ( ( test , index ) => (
278
+ < >
279
+ < CippPropertyListCard
280
+ key = { index }
281
+ title = { `Certificate info for ${ test . Hostname } ` }
282
+ copyItems = { true }
283
+ showDivider = { false }
284
+ propertyItems = { [
285
+ {
286
+ label : "Issuer" ,
287
+ value :
288
+ test . Certificate . Issuer . match ( / O = ( [ ^ , ] + ) / ) ?. [ 1 ] ||
289
+ test . Certificate . Issuer ,
290
+ } ,
291
+ {
292
+ label : "Subject" ,
293
+ value :
294
+ test . Certificate . Subject . match ( / C N = ( [ ^ , ] + ) / ) ?. [ 1 ] ||
295
+ test . Certificate . Subject ,
296
+ } ,
297
+ {
298
+ label : "Created" ,
299
+ value : getCippFormatting ( test . Certificate . NotBefore , "NotBefore" ) ,
300
+ } ,
301
+ {
302
+ label : "Expires" ,
303
+ value : getCippFormatting ( test . Certificate . NotAfter , "NotAfter" ) ,
304
+ } ,
305
+ { label : "Serial Number" , value : test . Certificate . SerialNumber } ,
306
+ { label : "Thumbprint" , value : test . Certificate . Thumbprint } ,
307
+ {
308
+ label : "DNS Names" ,
309
+ value : getCippFormatting (
310
+ test . Certificate . DnsNameList . map ( ( dns ) => dns . Unicode ) ,
311
+ "DNSName"
312
+ ) ,
313
+ } ,
314
+ ] }
315
+ />
316
+ < ResultList
317
+ passes = { test . ValidationPasses }
318
+ warns = { test . ValidationWarns }
319
+ fails = { test . ValidationFails }
320
+ />
321
+ < Divider />
322
+ </ >
323
+ ) ) }
324
+ </ >
325
+ ) ,
326
+ }
271
327
: { } ;
272
328
273
329
return (
@@ -326,6 +382,9 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
326
382
} ) ;
327
383
const [ optionsVisible , setOptionsVisible ] = useState ( false ) ;
328
384
const [ domain , setDomain ] = useState ( propDomain ) ;
385
+ const [ selector , setSelector ] = useState ( "" ) ;
386
+ const [ spfRecord , setSpfRecord ] = useState ( "" ) ;
387
+ const [ subdomains , setSubdomains ] = useState ( "" ) ;
329
388
const enableHttps = watch ( "enableHttps" ) ;
330
389
331
390
useEffect ( ( ) => {
@@ -337,13 +396,20 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
337
396
338
397
const onSubmit = ( values ) => {
339
398
setDomain ( values . domain ) ;
399
+ setSelector ( values . dkimSelector ) ;
400
+ setSpfRecord ( values . spfRecord ) ;
401
+ setSubdomains ( values . subdomains ) ;
340
402
} ;
341
403
342
404
const handleClear = ( ) => {
343
405
setValue ( "domain" , "" ) ;
344
406
setValue ( "spfRecord" , "" ) ;
345
407
setValue ( "dkimSelector" , "" ) ;
346
408
setValue ( "subdomains" , "" ) ;
409
+ setDomain ( "" ) ;
410
+ setSelector ( "" ) ;
411
+ setSpfRecord ( "" ) ;
412
+ setSubdomains ( "" ) ;
347
413
} ;
348
414
349
415
// API calls with dynamic queryKey using domain
@@ -370,8 +436,8 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
370
436
371
437
const { data : spfData , isFetching : spfLoading } = ApiGetCall ( {
372
438
url : "/api/ListDomainHealth" ,
373
- queryKey : `spf-${ domain } ` ,
374
- data : { Domain : domain , Action : "ReadSPFRecord" } ,
439
+ queryKey : `spf-${ domain } - ${ spfRecord } ` ,
440
+ data : { Domain : domain , Action : "ReadSPFRecord" , Record : spfRecord } ,
375
441
waiting : ! ! domain ,
376
442
} ) ;
377
443
@@ -384,8 +450,8 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
384
450
385
451
const { data : dkimData , isFetching : dkimLoading } = ApiGetCall ( {
386
452
url : "/api/ListDomainHealth" ,
387
- queryKey : `dkim-${ domain } ` ,
388
- data : { Domain : domain , Action : "ReadDkimRecord" } ,
453
+ queryKey : `dkim-${ domain } - ${ selector } ` ,
454
+ data : { Domain : domain , Action : "ReadDkimRecord" , Selector : selector } ,
389
455
waiting : ! ! domain ,
390
456
} ) ;
391
457
@@ -403,6 +469,13 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
403
469
waiting : ! ! domain ,
404
470
} ) ;
405
471
472
+ const { data : httpsData , isFetching : httpsLoading } = ApiGetCall ( {
473
+ url : "/api/ListDomainHealth" ,
474
+ queryKey : `https-${ domain } -${ subdomains } ` ,
475
+ data : { Domain : domain , Action : "TestHttpsCertificate" , Subdomains : subdomains } ,
476
+ waiting : ! ! domain && enableHttps ,
477
+ } ) ;
478
+
406
479
// Adjust grid item size based on fullwidth prop
407
480
const gridItemSize = fullwidth ? 12 : 4 ;
408
481
@@ -438,45 +511,50 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
438
511
</ Grid >
439
512
</ Grid >
440
513
< Collapse in = { optionsVisible } >
441
- < Controller
442
- name = "spfRecord"
443
- control = { control }
444
- render = { ( { field } ) => (
445
- < TextField { ...field } fullWidth label = "SPF Record" className = "mt-2" />
446
- ) }
447
- />
448
- < Controller
449
- name = "dkimSelector"
450
- control = { control }
451
- render = { ( { field } ) => (
452
- < TextField { ...field } fullWidth label = "DKIM Selector" className = "mt-2" />
453
- ) }
454
- />
455
- < Controller
456
- name = "enableHttps"
457
- control = { control }
458
- render = { ( { field } ) => (
459
- < Switch { ...field } checked = { field . value } label = "Enable HTTPS check" />
460
- ) }
461
- />
462
- { enableHttps && (
514
+ < Stack direction = "column" spacing = { 1 } sx = { { mt : 1 } } >
463
515
< Controller
464
- name = "subdomains "
516
+ name = "spfRecord "
465
517
control = { control }
466
518
render = { ( { field } ) => (
467
- < TextField { ...field } fullWidth label = "HTTPS Subdomains " className = "mt-2" />
519
+ < TextField { ...field } fullWidth label = "SPF Record " className = "mt-2" />
468
520
) }
469
521
/>
470
- ) }
471
- < Button
472
- variant = "outlined"
473
- color = "error"
474
- startIcon = { < ClearIcon /> }
475
- onClick = { handleClear }
476
- className = "mt-2"
477
- >
478
- Clear
479
- </ Button >
522
+ < Controller
523
+ name = "dkimSelector"
524
+ control = { control }
525
+ render = { ( { field } ) => (
526
+ < TextField { ...field } fullWidth label = "DKIM Selector" className = "mt-2" />
527
+ ) }
528
+ />
529
+ < Controller
530
+ name = "enableHttps"
531
+ control = { control }
532
+ render = { ( { field } ) => (
533
+ < FormControlLabel
534
+ control = { < Switch { ...field } checked = { field . value } /> }
535
+ label = "Enable HTTPS check"
536
+ />
537
+ ) }
538
+ />
539
+ { enableHttps && (
540
+ < Controller
541
+ name = "subdomains"
542
+ control = { control }
543
+ render = { ( { field } ) => (
544
+ < TextField { ...field } fullWidth label = "HTTPS Subdomains" className = "mt-2" />
545
+ ) }
546
+ />
547
+ ) }
548
+ < Button
549
+ variant = "outlined"
550
+ color = "error"
551
+ startIcon = { < ClearIcon /> }
552
+ onClick = { handleClear }
553
+ className = "mt-2"
554
+ >
555
+ Clear
556
+ </ Button >
557
+ </ Stack >
480
558
</ Collapse >
481
559
</ CippButtonCard >
482
560
</ Grid >
@@ -605,6 +683,25 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
605
683
}
606
684
/>
607
685
</ Grid >
686
+ { enableHttps && (
687
+ < Grid item xs = { 12 } md = { gridItemSize } >
688
+ < DomainResultCard
689
+ title = "HTTPS Certificate"
690
+ type = "HTTPS"
691
+ data = { httpsData }
692
+ isFetching = { httpsLoading }
693
+ info = {
694
+ < div >
695
+ < ResultList
696
+ passes = { httpsData ?. ValidationPasses }
697
+ warns = { httpsData ?. ValidationWarns }
698
+ fails = { httpsData ?. ValidationFails }
699
+ />
700
+ </ div >
701
+ }
702
+ />
703
+ </ Grid >
704
+ ) }
608
705
</ >
609
706
) }
610
707
</ Grid >
0 commit comments