Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions src/app/profiles/profile-detail/profile-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,35 +259,22 @@
</mat-list-item>
}
</mat-list>
@if (cloudMode === true) {
@if (showProxyConfigurations()) {
<mat-label class="flex flex-1" style="margin-top: 15px">
{{ 'proxy.label.value' | translate }}
</mat-label>

@if (showProxyConfigurations()) {
<mat-form-field class="flex flex-1" style="margin-top: 20px">
<mat-label>{{ 'proxy.configs.label.value' | translate }}</mat-label>
<input
matInput
type="text"
data-cy="proxyAutocomplete"
[placeholder]="'proxy.configs.placeholder.value' | translate"
[formControl]="proxyAutocomplete"
[matAutocomplete]="proxyAuto" />
<mat-autocomplete
autoActiveFirstOption
#proxyAuto="matAutocomplete"
(optionSelected)="selectProxyProfile($event)">
@for (proxy of filteredProxyList | async; track proxy) {
<mat-option [value]="proxy" [ngClass]="isProxySelectable(proxy)">
{{ proxy }}
</mat-option>
}
</mat-autocomplete>
<mat-hint>{{ 'proxy.configs.hint.value' | translate }}</mat-hint>
</mat-form-field>
}

<mat-form-field class="flex flex-1" style="margin-top: 20px">
<mat-label>{{ 'proxy.configs.label.value' | translate }}</mat-label>
<mat-select data-cy="proxyConfigSelect" (selectionChange)="selectProxyProfile($event.value)">
@for (proxy of ProxyConfigurations(); track proxy) {
<mat-option [value]="proxy" [disabled]="isProxyProfileSelected(proxy)">
{{ proxy }}
</mat-option>
}
</mat-select>
<mat-hint>{{ 'proxy.configs.hint.value' | translate }}</mat-hint>
</mat-form-field>
@if (selectedProxyConfigs().length > 0) {
<div>
<mat-label class="mat-body-1">{{ 'proxy.associatedProfiles.label.value' | translate }}</mat-label>
Expand Down
18 changes: 18 additions & 0 deletions src/app/profiles/profile-detail/profile-detail.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
})
Comment on lines +944 to +949

it('should not select NO_PROXY_CONFIGS option', () => {
const event = {
option: { value: 'profileDetail.noProxy.value' }
Expand Down
17 changes: 11 additions & 6 deletions src/app/profiles/profile-detail/profile-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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('')
}

Comment on lines 540 to 543
isProxyProfileSelected(proxyName: string): boolean {
return this.selectedProxyConfigs().some((config) => config.name === proxyName)
}

localWifiSyncChange(isEnabled: boolean): void {
if (isEnabled) {
this.profileForm.controls.localWifiSyncEnabled.disable()
Expand Down
Loading