fix(ui): use signals in OIDC test connection (#2417)
This commit is contained in:
+11
-11
@@ -250,14 +250,14 @@
|
|||||||
|
|
||||||
<div class="provider-actions-row">
|
<div class="provider-actions-row">
|
||||||
<div class="test-results-inline">
|
<div class="test-results-inline">
|
||||||
@if (testConnectionResult) {
|
@if (testConnectionResult()) {
|
||||||
<div class="test-results-toggle"
|
<div class="test-results-toggle"
|
||||||
[style.border-radius]="showTestDetails ? '6px 6px 0 0' : '6px'"
|
[style.border-radius]="showTestDetails() ? '6px 6px 0 0' : '6px'"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
(click)="showTestDetails = !showTestDetails"
|
(click)="toggleTestDetails()"
|
||||||
(keydown.enter)="showTestDetails = !showTestDetails">
|
(keydown.enter)="toggleTestDetails()">
|
||||||
@if (testConnectionResult.success) {
|
@if (testConnectionResult()?.success) {
|
||||||
<i class="pi pi-check-circle text-emerald-700 dark:text-emerald-300"></i>
|
<i class="pi pi-check-circle text-emerald-700 dark:text-emerald-300"></i>
|
||||||
<span>{{ t('testConnection.passed') }}</span>
|
<span>{{ t('testConnection.passed') }}</span>
|
||||||
} @else {
|
} @else {
|
||||||
@@ -265,9 +265,9 @@
|
|||||||
<span>{{ t('testConnection.failed') }}</span>
|
<span>{{ t('testConnection.failed') }}</span>
|
||||||
}
|
}
|
||||||
<span style="color: var(--p-text-muted-color); font-size: 0.75rem;">
|
<span style="color: var(--p-text-muted-color); font-size: 0.75rem;">
|
||||||
({{ testConnectionResult.checks.length }} {{ t('testConnection.checks') }})
|
({{ testConnectionResult()?.checks?.length ?? 0 }} {{ t('testConnection.checks') }})
|
||||||
</span>
|
</span>
|
||||||
<i class="pi pi-chevron-right toggle-chevron" [class.expanded]="showTestDetails"></i>
|
<i class="pi pi-chevron-right toggle-chevron" [class.expanded]="showTestDetails()"></i>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -275,11 +275,11 @@
|
|||||||
<p-button
|
<p-button
|
||||||
[outlined]="true"
|
[outlined]="true"
|
||||||
[label]="t('testConnection.button')"
|
[label]="t('testConnection.button')"
|
||||||
[icon]="isTestingConnection ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
|
[icon]="isTestingConnection() ? 'pi pi-spin pi-spinner' : 'pi pi-bolt'"
|
||||||
severity="info"
|
severity="info"
|
||||||
size="small"
|
size="small"
|
||||||
(click)="testConnection()"
|
(click)="testConnection()"
|
||||||
[disabled]="!oidcProvider.issuerUri || isTestingConnection">
|
[disabled]="!oidcProvider.issuerUri || isTestingConnection()">
|
||||||
</p-button>
|
</p-button>
|
||||||
<p-button
|
<p-button
|
||||||
[outlined]="true"
|
[outlined]="true"
|
||||||
@@ -292,9 +292,9 @@
|
|||||||
</p-button>
|
</p-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if (testConnectionResult && showTestDetails) {
|
@if (testConnectionResult() && showTestDetails()) {
|
||||||
<div class="test-results-details">
|
<div class="test-results-details">
|
||||||
@for (check of testConnectionResult.checks; track check.name) {
|
@for (check of testConnectionResult()?.checks; track check.name) {
|
||||||
<div class="test-check-row">
|
<div class="test-check-row">
|
||||||
@switch (check.status) {
|
@switch (check.status) {
|
||||||
@case ('PASS') {
|
@case ('PASS') {
|
||||||
|
|||||||
+4
-4
@@ -495,12 +495,12 @@ describe('AuthenticationSettingsComponent', () => {
|
|||||||
|
|
||||||
component.testConnection();
|
component.testConnection();
|
||||||
|
|
||||||
expect(component.isTestingConnection).toBe(false);
|
expect(component.isTestingConnection()).toBe(false);
|
||||||
expect(component.testConnectionResult).toEqual({
|
expect(component.testConnectionResult()).toEqual({
|
||||||
success: true,
|
success: true,
|
||||||
checks: [{name: 'issuer', status: 'PASS', message: 'ok'}],
|
checks: [{name: 'issuer', status: 'PASS', message: 'ok'}],
|
||||||
});
|
});
|
||||||
expect(component.showTestDetails).toBe(true);
|
expect(component.showTestDetails()).toBe(true);
|
||||||
|
|
||||||
appSettingsService.testOidcConnection.mockReturnValueOnce(
|
appSettingsService.testOidcConnection.mockReturnValueOnce(
|
||||||
throwError(() => new HttpErrorResponse({status: 500}))
|
throwError(() => new HttpErrorResponse({status: 500}))
|
||||||
@@ -508,7 +508,7 @@ describe('AuthenticationSettingsComponent', () => {
|
|||||||
|
|
||||||
component.testConnection();
|
component.testConnection();
|
||||||
|
|
||||||
expect(component.isTestingConnection).toBe(false);
|
expect(component.isTestingConnection()).toBe(false);
|
||||||
expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({
|
expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
detail: 'settingsAuth.testConnection.error',
|
detail: 'settingsAuth.testConnection.error',
|
||||||
|
|||||||
+14
-10
@@ -1,5 +1,5 @@
|
|||||||
import {HttpErrorResponse} from '@angular/common/http';
|
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 {FormsModule} from '@angular/forms';
|
||||||
import {InputText} from '@openng/optimus-ui/inputtext';
|
import {InputText} from '@openng/optimus-ui/inputtext';
|
||||||
import {Button} from '@openng/optimus-ui/button';
|
import {Button} from '@openng/optimus-ui/button';
|
||||||
@@ -99,9 +99,9 @@ export class AuthenticationSettingsComponent {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Test connection
|
// Test connection
|
||||||
isTestingConnection = false;
|
readonly isTestingConnection = signal(false);
|
||||||
testConnectionResult: OidcTestResult | null = null;
|
readonly testConnectionResult: WritableSignal<OidcTestResult | null> = signal(null);
|
||||||
showTestDetails = false;
|
readonly showTestDetails = signal(false);
|
||||||
|
|
||||||
// Group mapping
|
// Group mapping
|
||||||
readonly groupSyncMode = signal('DISABLED');
|
readonly groupSyncMode = signal('DISABLED');
|
||||||
@@ -450,14 +450,18 @@ export class AuthenticationSettingsComponent {
|
|||||||
return this.allLibraries.find(l => l.id === id)?.name ?? `#${id}`;
|
return this.allLibraries.find(l => l.id === id)?.name ?? `#${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleTestDetails(): void {
|
||||||
|
this.showTestDetails.update(s => !s)
|
||||||
|
}
|
||||||
|
|
||||||
testConnection(): void {
|
testConnection(): void {
|
||||||
this.isTestingConnection = true;
|
this.isTestingConnection.set(true);
|
||||||
this.testConnectionResult = null;
|
this.testConnectionResult.set(null);
|
||||||
this.appSettingsService.testOidcConnection(this.oidcProvider).subscribe({
|
this.appSettingsService.testOidcConnection(this.oidcProvider).subscribe({
|
||||||
next: (result) => {
|
next: (result) => {
|
||||||
this.testConnectionResult = result;
|
this.testConnectionResult.set(result);
|
||||||
this.showTestDetails = true;
|
this.showTestDetails.set(true);
|
||||||
this.isTestingConnection = false;
|
this.isTestingConnection.set(false);
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
@@ -465,7 +469,7 @@ export class AuthenticationSettingsComponent {
|
|||||||
summary: this.t.translate('common.error'),
|
summary: this.t.translate('common.error'),
|
||||||
detail: this.t.translate('settingsAuth.testConnection.error')
|
detail: this.t.translate('settingsAuth.testConnection.error')
|
||||||
});
|
});
|
||||||
this.isTestingConnection = false;
|
this.isTestingConnection.set(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user