From: pujashahu Date: Thu, 16 Jul 2026 06:06:58 +0000 (+0530) Subject: mgr/dashboard: mgr/dashboard: Hide Authentication section when "Allow All Hosts"... X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2bf1b6e79431f4b22e3a5f21fc69a5fe63a85558;p=ceph.git mgr/dashboard: mgr/dashboard: Hide Authentication section when "Allow All Hosts" is enabled Fixes: https://tracker.ceph.com/issues/78280 Signed-off-by: pujaoshahu --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.spec.ts index ee04e2af07e..adc1d7d35c6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.spec.ts @@ -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'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.ts index 70420ec7d1f..d9029c2071a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystem-step-2/nvmeof-subsystem-step-2.component.ts @@ -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(); @ViewChild('rightInfluencer', { static: true }) rightInfluencer?: TemplateRef; 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(); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.html index 63d31fb1430..df862e121f5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.html @@ -16,6 +16,7 @@ @if (showAuthStep) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.spec.ts index 4f65eaa1f3e..d739d9d8872 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.spec.ts @@ -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(); + }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.ts index 88178fb0c8c..1e33b037d52 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-subsystems-form/nvmeof-subsystems-form.component.ts @@ -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);