From bbe4f0cb06df78349228119f732aa6277ce74aa0 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Fri, 24 Nov 2023 10:42:39 +0100 Subject: [PATCH] [#1210] Added paragraph for failed settings fetch --- webui/src/app/settings-page/settings-page.component.html | 3 ++- webui/src/app/settings-page/settings-page.component.spec.ts | 5 +++-- webui/src/app/settings-page/settings-page.component.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/webui/src/app/settings-page/settings-page.component.html b/webui/src/app/settings-page/settings-page.component.html index f22230474..34683a40f 100644 --- a/webui/src/app/settings-page/settings-page.component.html +++ b/webui/src/app/settings-page/settings-page.component.html @@ -98,7 +98,8 @@ There are issues in the form values. - +
Fetching current settings from the server failed. Click the button to retry.
+
diff --git a/webui/src/app/settings-page/settings-page.component.spec.ts b/webui/src/app/settings-page/settings-page.component.spec.ts index aeb3703d1..bf4d43766 100644 --- a/webui/src/app/settings-page/settings-page.component.spec.ts +++ b/webui/src/app/settings-page/settings-page.component.spec.ts @@ -6,9 +6,7 @@ import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform import { FieldsetModule } from 'primeng/fieldset' import { MessageService } from 'primeng/api' import { HttpClientTestingModule } from '@angular/common/http/testing' - import { MessagesModule } from 'primeng/messages' - import { SettingsPageComponent } from './settings-page.component' import { SettingsService } from '../backend/api/api' import { BreadcrumbsComponent } from '../breadcrumbs/breadcrumbs.component' @@ -130,6 +128,9 @@ describe('SettingsPageComponent', () => { fixture.detectChanges() expect(messageService.add).toHaveBeenCalledTimes(2) + expect(fixture.debugElement.nativeElement.innerText).toContain( + 'Fetching current settings from the server failed.' + ) })) it('should submit the form', fakeAsync(() => { diff --git a/webui/src/app/settings-page/settings-page.component.ts b/webui/src/app/settings-page/settings-page.component.ts index 5f0d110b5..ac9c2e2c8 100644 --- a/webui/src/app/settings-page/settings-page.component.ts +++ b/webui/src/app/settings-page/settings-page.component.ts @@ -217,6 +217,6 @@ export class SettingsPageComponent implements OnInit { * @returns A boolean value indicating if the control has the error. */ hasError(name: string, errType: string): boolean { - return this.settingsForm.get(name)?.hasError(errType) + return !!this.settingsForm.get(name)?.hasError(errType) } }