- there is an issue with bi-auth , where the validation is getting empty due to some state refresh
- fixed by removing re-setting of form state
Fixes https://tracker.ceph.com/issues/76194
Signed-off-by: Afreen Misbah <afreen@ibm.com>
i18n-helperText>Encryption configuration
<textarea cdsTextArea
id="cdsInput"
+ cdValidate
+ #encryptionConfig="cdValidate"
+ [invalid]="encryptionConfig.invalid"
+ [invalidText]="encryptionConfigError"
formControlName="encryptionConfig"
cols="100"
rows="4">
</cds-textarea-label>
</div>
</div>
+ <ng-template #encryptionConfigError>
+ <span *ngIf="groupForm.controls.encryptionConfig.hasError('required')"
+ class="invalid-feedback"
+ i18n>This field is required.</span>
+ </ng-template>
}
<!-- Target Nodes Selection -->
enableEncryption: new UntypedFormControl(false),
encryptionConfig: new UntypedFormControl(null)
});
+
+ this.groupForm.get('enableEncryption')?.valueChanges.subscribe((enabled) => {
+ const encryptionControl = this.groupForm.get('encryptionConfig');
+ if (enabled) {
+ encryptionControl?.setValidators([Validators.required]);
+ } else {
+ encryptionControl?.clearValidators();
+ }
+ encryptionControl?.updateValueAndValidity();
+ });
}
onHostsLoaded(count: number): void {
unmanaged: formValues.unmanaged
};
- if (formValues.enableCds && formValues.cdsInput) {
- serviceSpec['encryption_key'] = formValues.cdsInput;
+ if (formValues.enableEncryption && formValues.encryptionConfig) {
+ serviceSpec['encryption_key'] = formValues.encryptionConfig;
}
this.taskWrapperService
<p class="cds--type-label-01 text-helper"
i18n>{{formGroup.get('authType').value === AUTHENTICATION.Bidirectional ? 'All fields are required.' : 'Optional fields.'}}</p>
</div>
+ @if (hostDchapKeyList.controls.length) {
@for (hostDchapKeyItem of hostDchapKeyList.controls; track $index; let i = $index) {
<div [formGroupName]="i">
<cds-text-label
</cds-text-label>
</div>
}
+ } @else {
+ <p
+ class="cds--type-label-01 text-helper"
+ i18ns>No hosts selected.</p>
+ }
</div>
</div>
</div>
});
describe('form initialization', () => {
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NvmeofSubsystemsStepThreeComponent);
+ component = fixture.componentInstance;
+
+ component.stepTwoValue = {
+ hostType: 'specific',
+ addedHosts: ['nqn.2001-07.com.ceph:1776805137618']
+ } as any;
+
+ fixture.detectChanges();
+ form = component.formGroup;
+ });
+
it('should initialize form with default values', () => {
expect(form).toBeTruthy();
expect(form.get('authType')?.value).toBe(AUTHENTICATION.Unidirectional);
hosts.forEach((nqn) => {
currentList.push(this.createHostDhchapKeyFormGroup(nqn, existing.get(nqn) ?? null));
});
- } else {
- currentList.push(this.createHostDhchapKeyFormGroup('', null));
}
}