diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index 5184a8459..53ea901df 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -296,11 +296,11 @@ - Tasks@if (tasksService.failedFileTasks.length > 0) { - {{tasksService.failedFileTasks.length}} + Tasks@if (tasksService.needsAttentionTasks.length > 0) { + {{tasksService.needsAttentionTasks.length}} } - @if (tasksService.failedFileTasks.length > 0 && slimSidebarEnabled) { - {{tasksService.failedFileTasks.length}} + @if (tasksService.needsAttentionTasks.length > 0 && slimSidebarEnabled) { + {{tasksService.needsAttentionTasks.length}} } diff --git a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts index 1341c6e5a..d6f84276f 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts @@ -36,6 +36,7 @@ import { RemoteVersionService } from 'src/app/services/rest/remote-version.servi import { SavedViewService } from 'src/app/services/rest/saved-view.service' import { SearchService } from 'src/app/services/rest/search.service' import { SettingsService } from 'src/app/services/settings.service' +import { TasksService } from 'src/app/services/tasks.service' import { ToastService } from 'src/app/services/toast.service' import { environment } from 'src/environments/environment' import { ProfileEditDialogComponent } from '../common/profile-edit-dialog/profile-edit-dialog.component' @@ -97,6 +98,7 @@ describe('AppFrameComponent', () => { let savedViewSpy let modalService: NgbModal let maybeRefreshSpy + let tasksService: TasksService beforeEach(async () => { TestBed.configureTestingModule({ @@ -174,6 +176,7 @@ describe('AppFrameComponent', () => { openDocumentsService = TestBed.inject(OpenDocumentsService) modalService = TestBed.inject(NgbModal) router = TestBed.inject(Router) + tasksService = TestBed.inject(TasksService) jest .spyOn(settingsService, 'displayName', 'get') @@ -444,6 +447,16 @@ describe('AppFrameComponent', () => { expect(maybeRefreshSpy).toHaveBeenCalled() }) + it('should show tasks badge for needs-attention tasks', () => { + jest + .spyOn(tasksService, 'needsAttentionTasks', 'get') + .mockReturnValue([{} as any, {} as any]) + + fixture.detectChanges() + + expect(fixture.nativeElement.textContent).toContain('Tasks2') + }) + it('should indicate attributes management availability when any permission is granted', () => { jest .spyOn(permissionsService, 'currentUserCan') diff --git a/src-ui/src/app/services/tasks.service.ts b/src-ui/src/app/services/tasks.service.ts index 672a9f4d9..c598d2b73 100644 --- a/src-ui/src/app/services/tasks.service.ts +++ b/src-ui/src/app/services/tasks.service.ts @@ -56,6 +56,14 @@ export class TasksService { ) } + public get needsAttentionTasks(): PaperlessTask[] { + return this.fileTasks.filter((t) => + [PaperlessTaskStatus.Failure, PaperlessTaskStatus.Revoked].includes( + t.status + ) + ) + } + public reload() { if (this.loading) return this.loading = true