]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: mgr/dashboard: Hide Authentication section when "Allow All Hosts"... 70245/head
authorpujashahu <pshahu@redhat.com>
Thu, 16 Jul 2026 06:06:58 +0000 (11:36 +0530)
committerpujashahu <pshahu@redhat.com>
Thu, 16 Jul 2026 06:12:07 +0000 (11:42 +0530)
Fixes: https://tracker.ceph.com/issues/78280
Signed-off-by: pujaoshahu <pshahu@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.ts

index ee04e2af07e173cd89efd6691d3106e1b9d3ab8d..adc1d7d35c6b47c35afecafc4483e0ac0f25c8d7 100644 (file)
@@ -83,6 +83,15 @@ describe('NvmeofSubsystemsStepTwoComponent', () => {
     });
   });
 
+  describe('host type change events', () => {
+    it('should emit host type changes for parent step visibility', () => {
+      const emitSpy = spyOn(component.hostTypeChanged, 'emit');
+      form.get('hostType')?.setValue(component.HOST_TYPE.ALL);
+
+      expect(emitSpy).toHaveBeenCalledWith(component.HOST_TYPE.ALL);
+    });
+  });
+
   describe('custom NQN validator', () => {
     it('should mark invalid NQN format', () => {
       form.get('hostname')?.setValue('invalid-nqn');
index 70420ec7d1fba6ed985d62264ecd3b0a9328fbbb..d9029c2071aa926fa7b87a3d1b4cccdcfbede131 100644 (file)
@@ -1,4 +1,13 @@
-import { Component, Input, OnInit, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';
+import {
+  Component,
+  EventEmitter,
+  Input,
+  OnInit,
+  Output,
+  TemplateRef,
+  ViewChild,
+  ViewEncapsulation
+} from '@angular/core';
 import { FormControl, UntypedFormControl } from '@angular/forms';
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 
@@ -21,6 +30,7 @@ export class NvmeofSubsystemsStepTwoComponent implements OnInit, TearsheetStep {
   @Input() group!: string;
   @Input() existingHosts: string[] = [];
   @Input() allowAllHosts = true;
+  @Output() hostTypeChanged = new EventEmitter<string>();
   @ViewChild('rightInfluencer', { static: true })
   rightInfluencer?: TemplateRef<any>;
   formGroup: CdFormGroup;
@@ -50,7 +60,8 @@ export class NvmeofSubsystemsStepTwoComponent implements OnInit, TearsheetStep {
   ngOnInit() {
     this.createForm();
 
-    this.formGroup.get('hostType')?.valueChanges.subscribe(() => {
+    this.formGroup.get('hostType')?.valueChanges.subscribe((hostType: string) => {
+      this.hostTypeChanged.emit(hostType);
       this.formGroup.get('hostname')?.updateValueAndValidity();
     });
 
@@ -58,6 +69,7 @@ export class NvmeofSubsystemsStepTwoComponent implements OnInit, TearsheetStep {
       this.formGroup.get('hostname')?.updateValueAndValidity();
     });
 
+    this.hostTypeChanged.emit(this.formGroup.get('hostType')?.value);
     this.formGroup.get('hostname')?.updateValueAndValidity();
   }
 
index 63d31fb1430f626a86db0fb35df4723b9f07599b..df862e121f5ae850668966698a4180d0b02bf9e1 100644 (file)
@@ -16,6 +16,7 @@
     <cd-nvmeof-subsystem-step-two
       #tearsheetStep
       [group]="group"
+      (hostTypeChanged)="onHostTypeChanged($event)"
     ></cd-nvmeof-subsystem-step-two>
   </cd-tearsheet-step>
   @if (showAuthStep) {
index 4f65eaa1f3eb4ab5e1ac1cc00772b5430e34827b..d739d9d8872f42829ee741f7d9cf80c809396183 100644 (file)
@@ -220,5 +220,20 @@ describe('NvmeofSubsystemsFormComponent', () => {
         gw_group: mockGroupName
       });
     });
+
+    it('should hide authentication step when host type is ALL', () => {
+      component.onHostTypeChanged(HOST_TYPE.ALL);
+
+      expect(component.showAuthStep).toBeFalsy();
+      expect(component.steps.some((step) => step.label === 'Authentication')).toBeFalsy();
+    });
+
+    it('should show authentication step when host type is SPECIFIC', () => {
+      component.onHostTypeChanged(HOST_TYPE.ALL);
+      component.onHostTypeChanged(HOST_TYPE.SPECIFIC);
+
+      expect(component.showAuthStep).toBeTruthy();
+      expect(component.steps.some((step) => step.label === 'Authentication')).toBeTruthy();
+    });
   });
 });
index 88178fb0c8cf15be16e1947ddc6df8f7c08a7a43..1e33b037d526189ad6e53b230185a2b97ca57be6 100644 (file)
@@ -103,12 +103,20 @@ export class NvmeofSubsystemsFormComponent implements OnInit {
     this.rebuildSteps();
   }
 
+  onHostTypeChanged(hostType: string) {
+    this.setAuthStepVisibility(this.shouldShowAuthStep(hostType));
+  }
+
   private setAuthStepVisibility(nextShowAuth: boolean) {
     if (this.showAuthStep === nextShowAuth) return;
     this.showAuthStep = nextShowAuth;
     this.rebuildSteps();
   }
 
+  private shouldShowAuthStep(hostType: string | null | undefined): boolean {
+    return (hostType ?? HOST_TYPE.SPECIFIC) === HOST_TYPE.SPECIFIC;
+  }
+
   populateReviewData() {
     if (!this.tearsheet) return;
 
@@ -126,7 +134,7 @@ export class NvmeofSubsystemsFormComponent implements OnInit {
       this.stepTwoValue = step2;
     }
 
-    const nextShowAuth = (step2?.hostType ?? HOST_TYPE.SPECIFIC) === HOST_TYPE.SPECIFIC;
+    const nextShowAuth = this.shouldShowAuthStep(step2?.hostType);
 
     if (nextShowAuth !== this.showAuthStep) {
       this.setAuthStepVisibility(nextShowAuth);