From 74ed49a5f90580c555264757c9596ab6494dd166 Mon Sep 17 00:00:00 2001 From: Nabendu Maiti Date: Thu, 23 Jul 2026 03:30:19 +0000 Subject: [PATCH] fix: add proxy configuration selector Proxy config name can be selected from dropdown Signed-off-by: Nabendu Maiti --- .../profile-detail.component.html | 37 ++++++------------- .../profile-detail.component.spec.ts | 18 +++++++++ .../profile-detail.component.ts | 17 ++++++--- 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/app/profiles/profile-detail/profile-detail.component.html b/src/app/profiles/profile-detail/profile-detail.component.html index 0ca566f15..eb8f251cc 100644 --- a/src/app/profiles/profile-detail/profile-detail.component.html +++ b/src/app/profiles/profile-detail/profile-detail.component.html @@ -259,35 +259,22 @@ } - @if (cloudMode === true) { + @if (showProxyConfigurations()) { {{ 'proxy.label.value' | translate }} - @if (showProxyConfigurations()) { - - {{ 'proxy.configs.label.value' | translate }} - - - @for (proxy of filteredProxyList | async; track proxy) { - - {{ proxy }} - - } - - {{ 'proxy.configs.hint.value' | translate }} - - } - + + {{ 'proxy.configs.label.value' | translate }} + + @for (proxy of ProxyConfigurations(); track proxy) { + + {{ proxy }} + + } + + {{ 'proxy.configs.hint.value' | translate }} + @if (selectedProxyConfigs().length > 0) {
{{ 'proxy.associatedProfiles.label.value' | translate }} diff --git a/src/app/profiles/profile-detail/profile-detail.component.spec.ts b/src/app/profiles/profile-detail/profile-detail.component.spec.ts index e03dde026..bc97ac11f 100644 --- a/src/app/profiles/profile-detail/profile-detail.component.spec.ts +++ b/src/app/profiles/profile-detail/profile-detail.component.spec.ts @@ -872,6 +872,17 @@ describe('ProfileDetailComponent', () => { expect(enterpriseComponent.ciraEnabled()).toBeTrue() }) + it('should show proxy configuration selection in enterprise when configs are available', () => { + proxyGetDataSpy.calls.reset() + + environment.cloud = false + const enterpriseFixture = TestBed.createComponent(ProfileDetailComponent) + enterpriseFixture.detectChanges() + + expect(proxyGetDataSpy).toHaveBeenCalled() + expect(enterpriseFixture.nativeElement.querySelector('[data-cy="proxyConfigSelect"]')).not.toBeNull() + }) + it('should fail open and fetch CIRA configs when the features call errors', () => { serverFeaturesGetFeaturesSpy.and.returnValue(throwError(() => new Error('nope'))) ciraGetDataSpy.calls.reset() @@ -930,6 +941,13 @@ describe('ProfileDetailComponent', () => { expect(component.selectedProxyConfigs().length).toBe(1) }) + it('should mark an associated proxy configuration as selected', () => { + component.selectedProxyConfigs.set([{ priority: 1, name: 'proxy1' }]) + + expect(component.isProxyProfileSelected('proxy1')).toBeTrue() + expect(component.isProxyProfileSelected('proxy2')).toBeFalse() + }) + it('should not select NO_PROXY_CONFIGS option', () => { const event = { option: { value: 'profileDetail.noProxy.value' } diff --git a/src/app/profiles/profile-detail/profile-detail.component.ts b/src/app/profiles/profile-detail/profile-detail.component.ts index c61998aaf..f0be6fd5c 100644 --- a/src/app/profiles/profile-detail/profile-detail.component.ts +++ b/src/app/profiles/profile-detail/profile-detail.component.ts @@ -207,9 +207,9 @@ export class ProfileDetailComponent implements OnInit { private initializeData(): void { this.getIEEE8021xConfigs() this.getWirelessConfigs() + this.getProxyConfigs() if (this.cloudMode) { - // Cloud always has CIRA; proxy configs are cloud-only too. - this.getProxyConfigs() + // Cloud always has CIRA. this.getCiraConfigs() } else { // Enterprise: only fetch CIRA configs when the server reports CIRA enabled, @@ -523,23 +523,28 @@ export class ProfileDetailComponent implements OnInit { this.wirelessAutocomplete.patchValue('') } - selectProxyProfile(event: MatAutocompleteSelectedEvent): void { - if (event.option.value === NO_PROXY_CONFIGS) return + selectProxyProfile(event: MatAutocompleteSelectedEvent | string): void { + const proxyName = typeof event === 'string' ? event : (event.option.value as string) + if (proxyName === NO_PROXY_CONFIGS) return const selectedProfiles = this.selectedProxyConfigs().map((proxy) => proxy.name) - if (selectedProfiles.includes(event.option.value as string)) return + if (selectedProfiles.includes(proxyName)) return this.selectedProxyConfigs.update((configs) => [ ...configs, { priority: configs.length + 1, - name: event.option.value + name: proxyName } ]) this.proxyAutocomplete.patchValue('') } + isProxyProfileSelected(proxyName: string): boolean { + return this.selectedProxyConfigs().some((config) => config.name === proxyName) + } + localWifiSyncChange(isEnabled: boolean): void { if (isEnabled) { this.profileForm.controls.localWifiSyncEnabled.disable()