@@ -22,7 +22,10 @@ import {
22
22
ViewChild ,
23
23
} from '@angular/core' ;
24
24
import { FormBuilder , NG_VALIDATORS , NG_VALUE_ACCESSOR , Validators } from '@angular/forms' ;
25
- import { OpenstackCredentialsTypeService } from '@app/wizard/step/provider-settings/provider/extended/openstack/service' ;
25
+ import {
26
+ CredentialsType ,
27
+ OpenstackCredentialsTypeService ,
28
+ } from '@app/wizard/step/provider-settings/provider/extended/openstack/service' ;
26
29
import { ClusterSpecService } from '@core/services/cluster-spec' ;
27
30
import { DatacenterService } from '@core/services/datacenter' ;
28
31
import { PresetsService } from '@core/services/wizard/presets' ;
@@ -91,7 +94,7 @@ export class OpenstackProviderBasicComponent extends BaseFormValidator implement
91
94
92
95
ngOnInit ( ) : void {
93
96
this . form = this . _builder . group ( {
94
- [ Controls . Domain ] : this . _builder . control ( '' , Validators . required ) ,
97
+ [ Controls . Domain ] : this . _builder . control ( '' ) ,
95
98
[ Controls . Credentials ] : this . _builder . control ( '' ) ,
96
99
[ Controls . FloatingIPPool ] : this . _builder . control ( '' , Validators . required ) ,
97
100
} ) ;
@@ -139,6 +142,15 @@ export class OpenstackProviderBasicComponent extends BaseFormValidator implement
139
142
. pipe ( filter ( _ => this . _clusterSpecService . provider === NodeProvider . OPENSTACK ) )
140
143
. pipe ( switchMap ( _ => this . _datacenterService . getDatacenter ( this . _clusterSpecService . datacenter ) . pipe ( take ( 1 ) ) ) )
141
144
. pipe ( tap ( dc => ( this . _isFloatingPoolIPEnforced = dc ?. spec . openstack . enforceFloatingIP ) ) )
145
+ . pipe (
146
+ tap ( _ => {
147
+ if ( this . _credentialsTypeService . credentialsType === CredentialsType . Default ) {
148
+ this . form . get ( Controls . Domain ) . setValidators ( Validators . required ) ;
149
+ } else {
150
+ this . form . get ( Controls . Domain ) . clearValidators ( ) ;
151
+ }
152
+ } )
153
+ )
142
154
. pipe ( takeUntil ( this . _unsubscribe ) )
143
155
. subscribe ( _ => this . form . reset ( ) ) ;
144
156
}
@@ -150,6 +162,8 @@ export class OpenstackProviderBasicComponent extends BaseFormValidator implement
150
162
151
163
isRequired ( control : Controls ) : boolean {
152
164
switch ( control ) {
165
+ case Controls . Domain :
166
+ return this . form . get ( Controls . Domain ) . hasValidator ( Validators . required ) ;
153
167
case Controls . FloatingIPPool :
154
168
return this . _isFloatingPoolIPEnforced ;
155
169
default :
0 commit comments