]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Allow moving to next when Bidirectional mode is chosen 68529/head
authorAfreen Misbah <afreen@ibm.com>
Tue, 21 Apr 2026 21:48:55 +0000 (03:18 +0530)
committerAfreen Misbah <afreen@ibm.com>
Wed, 22 Apr 2026 11:06:44 +0000 (16:36 +0530)
- 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>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-group-form/nvmeof-group-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-group-form/nvmeof-group-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-3/nvmeof-subsystem-step-3.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-3/nvmeof-subsystem-step-3.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-3/nvmeof-subsystem-step-3.component.ts

index 9d8587bebe9ec21593cdaae34303487005045eca..bae90057e0744b04b9741ac85dc216e6998d4540 100644 (file)
             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 -->
index 7fd270e51ec772fff0822e455c5e87083222ac9b..533025735bcac6f0177c626c977a7f3cb69c63a9 100644 (file)
@@ -75,6 +75,16 @@ export class NvmeofGroupFormComponent extends CdForm implements OnInit {
       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 {
@@ -159,8 +169,8 @@ export class NvmeofGroupFormComponent extends CdForm implements OnInit {
       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
index 00f045c2a5017850e47682d568af70f18536868f..9ee61b903f8574b198de6ed5a5d392c526c80ff5 100644 (file)
@@ -91,6 +91,7 @@
           <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>
index 1811c6c44456fad56d6df56be363dbf1d3e7fb97..315d7fca793f34200518a577ac4edba49d2517b3 100644 (file)
@@ -57,6 +57,19 @@ describe('NvmeofSubsystemsStepThreeComponent', () => {
     });
 
     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);
index dc158ac8b087f1df6202d61860a198db0ec9df63..9bfc3c4c0cdf4ccb5cf704c87371928daed96361 100644 (file)
@@ -50,8 +50,6 @@ export class NvmeofSubsystemsStepThreeComponent implements OnInit, TearsheetStep
       hosts.forEach((nqn) => {
         currentList.push(this.createHostDhchapKeyFormGroup(nqn, existing.get(nqn) ?? null));
       });
-    } else {
-      currentList.push(this.createHostDhchapKeyFormGroup('', null));
     }
   }