From 4ae1d0bb438bdd0cbd1312e1f38805d2d7ad6511 Mon Sep 17 00:00:00 2001 From: James Ward Date: Thu, 20 Aug 2026 18:23:15 -0400 Subject: [PATCH] fix(ui): use signals in OIDC test connection (#2417) --- .../authentication-settings.component.html | 22 ++++++++--------- .../authentication-settings.component.spec.ts | 8 +++---- .../authentication-settings.component.ts | 24 +++++++++++-------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.html b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.html index e31cf5f6c..df77a622c 100644 --- a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.html +++ b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.html @@ -250,14 +250,14 @@
- @if (testConnectionResult) { + @if (testConnectionResult()) {
- @if (testConnectionResult.success) { + (click)="toggleTestDetails()" + (keydown.enter)="toggleTestDetails()"> + @if (testConnectionResult()?.success) { {{ t('testConnection.passed') }} } @else { @@ -265,9 +265,9 @@ {{ t('testConnection.failed') }} } - ({{ testConnectionResult.checks.length }} {{ t('testConnection.checks') }}) + ({{ testConnectionResult()?.checks?.length ?? 0 }} {{ t('testConnection.checks') }}) - +
}
@@ -275,11 +275,11 @@ + [disabled]="!oidcProvider.issuerUri || isTestingConnection()">
- @if (testConnectionResult && showTestDetails) { + @if (testConnectionResult() && showTestDetails()) {
- @for (check of testConnectionResult.checks; track check.name) { + @for (check of testConnectionResult()?.checks; track check.name) {
@switch (check.status) { @case ('PASS') { diff --git a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts index 302958aac..43dfde3c7 100644 --- a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts +++ b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts @@ -495,12 +495,12 @@ describe('AuthenticationSettingsComponent', () => { component.testConnection(); - expect(component.isTestingConnection).toBe(false); - expect(component.testConnectionResult).toEqual({ + expect(component.isTestingConnection()).toBe(false); + expect(component.testConnectionResult()).toEqual({ success: true, checks: [{name: 'issuer', status: 'PASS', message: 'ok'}], }); - expect(component.showTestDetails).toBe(true); + expect(component.showTestDetails()).toBe(true); appSettingsService.testOidcConnection.mockReturnValueOnce( throwError(() => new HttpErrorResponse({status: 500})) @@ -508,7 +508,7 @@ describe('AuthenticationSettingsComponent', () => { component.testConnection(); - expect(component.isTestingConnection).toBe(false); + expect(component.isTestingConnection()).toBe(false); expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({ severity: 'error', detail: 'settingsAuth.testConnection.error', diff --git a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts index a306f559e..abc5e4022 100644 --- a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts +++ b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts @@ -1,5 +1,5 @@ import {HttpErrorResponse} from '@angular/common/http'; -import {Component, effect, inject, signal} from '@angular/core'; +import {Component, effect, inject, signal, WritableSignal} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {InputText} from '@openng/optimus-ui/inputtext'; import {Button} from '@openng/optimus-ui/button'; @@ -99,9 +99,9 @@ export class AuthenticationSettingsComponent { ]; // Test connection - isTestingConnection = false; - testConnectionResult: OidcTestResult | null = null; - showTestDetails = false; + readonly isTestingConnection = signal(false); + readonly testConnectionResult: WritableSignal = signal(null); + readonly showTestDetails = signal(false); // Group mapping readonly groupSyncMode = signal('DISABLED'); @@ -450,14 +450,18 @@ export class AuthenticationSettingsComponent { return this.allLibraries.find(l => l.id === id)?.name ?? `#${id}`; } + toggleTestDetails(): void { + this.showTestDetails.update(s => !s) + } + testConnection(): void { - this.isTestingConnection = true; - this.testConnectionResult = null; + this.isTestingConnection.set(true); + this.testConnectionResult.set(null); this.appSettingsService.testOidcConnection(this.oidcProvider).subscribe({ next: (result) => { - this.testConnectionResult = result; - this.showTestDetails = true; - this.isTestingConnection = false; + this.testConnectionResult.set(result); + this.showTestDetails.set(true); + this.isTestingConnection.set(false); }, error: () => { this.messageService.add({ @@ -465,7 +469,7 @@ export class AuthenticationSettingsComponent { summary: this.t.translate('common.error'), detail: this.t.translate('settingsAuth.testConnection.error') }); - this.isTestingConnection = false; + this.isTestingConnection.set(false); } }); }