@@ -14,12 +14,14 @@ interface SelectOption extends OptionBase {
14
14
}
15
15
interface DomainNamesFieldProps {
16
16
maxDomains ?: number ;
17
- isWildcardSupported ?: boolean ;
17
+ isWildcardPermitted ?: boolean ;
18
+ dnsProviderWildcardSupported ?: boolean ;
18
19
onChange ?: ( i : string [ ] ) => any ;
19
20
}
20
21
function DomainNamesField ( {
21
22
maxDomains,
22
- isWildcardSupported,
23
+ isWildcardPermitted,
24
+ dnsProviderWildcardSupported,
23
25
onChange,
24
26
} : DomainNamesFieldProps ) {
25
27
const { values, setFieldValue } = useFormikContext ( ) ;
@@ -45,7 +47,10 @@ function DomainNamesField({
45
47
}
46
48
47
49
// Prevent wildcards
48
- if ( ! isWildcardSupported && dom . indexOf ( "*" ) !== - 1 ) {
50
+ if (
51
+ ( ! isWildcardPermitted || ! dnsProviderWildcardSupported ) &&
52
+ dom . indexOf ( "*" ) !== - 1
53
+ ) {
49
54
return false ;
50
55
}
51
56
@@ -71,6 +76,18 @@ function DomainNamesField({
71
76
setFieldValue ( "domainNames" , doms ) ;
72
77
} ;
73
78
79
+ let helperTexts : string [ ] = [ ] ;
80
+ if ( maxDomains ) {
81
+ helperTexts . push (
82
+ intl . formatMessage ( { id : "domain_names.max" } , { count : maxDomains } ) ,
83
+ ) ;
84
+ }
85
+ if ( ! isWildcardPermitted ) {
86
+ helperTexts . push ( intl . formatMessage ( { id : "wildcards-not-permitted" } ) ) ;
87
+ } else if ( ! dnsProviderWildcardSupported ) {
88
+ helperTexts . push ( intl . formatMessage ( { id : "wildcards-not-supported" } ) ) ;
89
+ }
90
+
74
91
return (
75
92
< Field name = "domainNames" >
76
93
{ ( { field, form } : any ) => (
@@ -91,14 +108,11 @@ function DomainNamesField({
91
108
isMulti
92
109
placeholder = "example.com"
93
110
/>
94
- { maxDomains ? (
95
- < FormHelperText >
96
- { intl . formatMessage (
97
- { id : "domain_names.max" } ,
98
- { count : maxDomains } ,
99
- ) }
100
- </ FormHelperText >
101
- ) : null }
111
+ { helperTexts . length
112
+ ? helperTexts . map ( ( i ) => {
113
+ return < FormHelperText > { i } </ FormHelperText > ;
114
+ } )
115
+ : null }
102
116
< FormErrorMessage > { form . errors . domainNames } </ FormErrorMessage >
103
117
</ FormControl >
104
118
) }
0 commit comments