Skip to content

Commit 16a256b

Browse files
committed
feat: hide CIRA in profile when disabled on the server
1 parent d0266d3 commit 16a256b

2 files changed

Lines changed: 31 additions & 34 deletions

File tree

src/app/profiles/profile-detail/profile-detail.component.html

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -320,24 +320,23 @@
320320
<mat-error>{{ 'profileDetail.connectionModeRequired.value' | translate }}</mat-error>
321321
</p>
322322
}
323-
<fieldset>
324-
<legend>{{ 'profileDetail.internetModeLegend.value' | translate }}</legend>
325-
<p>{{ 'profileDetail.internetModeDescription.value' | translate }}</p>
326-
<p>
327-
<mat-radio-button
328-
data-cy="radio-cira"
329-
[value]="connectionMode.cira"
330-
[disabled]="!ciraEnabled() || ciraConfigurations().length === 0">
331-
{{ 'profileDetail.ciraCloud.value' | translate }}
332-
@if (!ciraEnabled()) {
323+
@if (ciraEnabled()) {
324+
<fieldset>
325+
<legend>{{ 'profileDetail.internetModeLegend.value' | translate }}</legend>
326+
<p>{{ 'profileDetail.internetModeDescription.value' | translate }}</p>
327+
<p>
328+
<mat-radio-button
329+
data-cy="radio-cira"
330+
[value]="connectionMode.cira"
331+
[disabled]="ciraConfigurations().length === 0">
332+
{{ 'profileDetail.ciraCloud.value' | translate }}
333333
<span>{{ 'profileDetail.ciraDisabledOption.value' | translate }}</span>
334-
} @else if (ciraConfigurations().length === 0) {
335-
<span>{{ 'profileDetail.noCiraConfigs.value' | translate }}</span>
336-
}
337-
</mat-radio-button>
338-
</p>
339-
@if (profileForm.get('connectionMode')?.value === 'CIRA') {
340-
@if (ciraEnabled()) {
334+
@if (ciraConfigurations().length === 0) {
335+
<span>{{ 'profileDetail.noCiraConfigs.value' | translate }}</span>
336+
}
337+
</mat-radio-button>
338+
</p>
339+
@if (profileForm.get('connectionMode')?.value === 'CIRA') {
341340
<mat-form-field class="flex flex-1">
342341
<mat-label>{{ 'profileDetail.ciraConfiguration.value' | translate }}</mat-label>
343342
<mat-select formControlName="ciraConfigName">
@@ -352,20 +351,9 @@
352351
{{ 'profileDetail.ciraConfigHint.value' | translate }}
353352
</mat-hint>
354353
</mat-form-field>
355-
} @else {
356-
<!-- CIRA disabled on this server but the profile still references a CIRA config.
357-
Show it read-only with a warning and let the user switch to TLS/Direct. -->
358-
<p class="error-messages-container">
359-
<mat-icon color="warn">warning</mat-icon>
360-
<span class="error-messages">{{ 'profileDetail.ciraDisabledWarning.value' | translate }}</span>
361-
</p>
362-
<mat-form-field class="flex flex-1">
363-
<mat-label>{{ 'profileDetail.ciraConfiguration.value' | translate }}</mat-label>
364-
<input matInput formControlName="ciraConfigName" readonly />
365-
</mat-form-field>
366354
}
367-
}
368-
</fieldset>
355+
</fieldset>
356+
}
369357
<fieldset>
370358
<legend>{{ 'profileDetail.directConnectLegend.value' | translate }}</legend>
371359
<p>

src/app/profiles/profile-detail/profile-detail.component.spec.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { provideHttpClientTesting } from '@angular/common/http/testing'
2727
import { provideTranslateHttpLoader, TRANSLATE_HTTP_LOADER_CONFIG } from '@ngx-translate/http-loader'
2828

2929
describe('ProfileDetailComponent', () => {
30+
const defaultCloudMode = environment.cloud
3031
let component: ProfileDetailComponent
3132
let fixture: ComponentFixture<ProfileDetailComponent>
3233
let profileSpy: jasmine.Spy
@@ -148,6 +149,7 @@ describe('ProfileDetailComponent', () => {
148149
})
149150

150151
afterEach(() => {
152+
environment.cloud = defaultCloudMode
151153
TestBed.resetTestingModule()
152154
})
153155

@@ -174,6 +176,7 @@ describe('ProfileDetailComponent', () => {
174176
expect(wirelessGetDataSpy).toHaveBeenCalled()
175177
expect(proxyGetDataSpy).toHaveBeenCalled()
176178
})
179+
177180
it('should set connectionMode to TLS when tlsMode is a TLS mode (1-4)', () => {
178181
const profile: Profile = { tlsMode: 4, ciraConfigName: 'config1' } as any
179182
component.setConnectionMode(profile)
@@ -835,9 +838,11 @@ describe('ProfileDetailComponent', () => {
835838
// server-features branch instead of the cloud branch.
836839
const createEnterpriseComponent = (): ProfileDetailComponent => {
837840
environment.cloud = false
838-
const enterpriseFixture = TestBed.createComponent(ProfileDetailComponent)
839-
enterpriseFixture.detectChanges()
840-
return enterpriseFixture.componentInstance
841+
fixture.destroy()
842+
fixture = TestBed.createComponent(ProfileDetailComponent)
843+
component = fixture.componentInstance
844+
fixture.detectChanges()
845+
return component
841846
}
842847

843848
afterEach(() => {
@@ -848,10 +853,12 @@ describe('ProfileDetailComponent', () => {
848853
serverFeaturesGetFeaturesSpy.and.returnValue(of({ ciraEnabled: false }))
849854
ciraGetDataSpy.calls.reset()
850855

851-
createEnterpriseComponent()
856+
const enterpriseComponent = createEnterpriseComponent()
852857

853858
expect(serverFeaturesGetFeaturesSpy).toHaveBeenCalled()
854859
expect(ciraGetDataSpy).not.toHaveBeenCalled()
860+
expect(enterpriseComponent.ciraEnabled()).toBeFalse()
861+
expect(fixture.nativeElement.querySelector('[data-cy="radio-cira"]')).toBeNull()
855862
})
856863

857864
it('should expose ciraEnabled() === false after the features call resolves with CIRA disabled', () => {
@@ -870,6 +877,7 @@ describe('ProfileDetailComponent', () => {
870877

871878
expect(ciraGetDataSpy).toHaveBeenCalled()
872879
expect(enterpriseComponent.ciraEnabled()).toBeTrue()
880+
expect(fixture.nativeElement.querySelector('[data-cy="radio-cira"]')).not.toBeNull()
873881
})
874882

875883
it('should fail open and fetch CIRA configs when the features call errors', () => {
@@ -880,6 +888,7 @@ describe('ProfileDetailComponent', () => {
880888

881889
expect(ciraGetDataSpy).toHaveBeenCalled()
882890
expect(enterpriseComponent.ciraEnabled()).toBeTrue()
891+
expect(fixture.nativeElement.querySelector('[data-cy="radio-cira"]')).not.toBeNull()
883892
})
884893
})
885894

0 commit comments

Comments
 (0)