From 8a079ab6f44de8e544925a752c9c5ade624fb135 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 14:38:25 +0100 Subject: [PATCH 1/3] Reset the handle table page when a search starts A search loads page 1, but the URL kept the old page, so the paginator showed a wrong range. The URL is replaced and only the latest load writes the rows. Co-Authored-By: Claude Opus 5.5 --- .../handle-table.component.spec.ts | 50 +++++++++++++++++-- .../handle-table/handle-table.component.ts | 19 ++++++- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/app/handle-page/handle-table/handle-table.component.spec.ts b/src/app/handle-page/handle-table/handle-table.component.spec.ts index ef6844d3ead..e80077e35f7 100644 --- a/src/app/handle-page/handle-table/handle-table.component.spec.ts +++ b/src/app/handle-page/handle-table/handle-table.component.spec.ts @@ -6,16 +6,26 @@ import { import { ReactiveFormsModule } from '@angular/forms'; import { Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { of } from 'rxjs'; +import { + of, + Subject, +} from 'rxjs'; import { HandleDataService } from '../../core/data/handle-data.service'; -import { buildPaginatedList } from '../../core/data/paginated-list.model'; +import { + buildPaginatedList, + PaginatedList, +} from '../../core/data/paginated-list.model'; +import { RemoteData } from '../../core/data/remote-data'; import { RequestService } from '../../core/data/request.service'; import { Handle } from '../../core/handle/handle.model'; import { PaginationService } from '../../core/pagination/pagination.service'; import { PageInfo } from '../../core/shared/page-info.model'; import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { + createSuccessfulRemoteDataObject, + createSuccessfulRemoteDataObject$, +} from '../../shared/remote-data.utils'; import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub'; import { RouterStub } from '../../shared/testing/router.stub'; @@ -24,7 +34,10 @@ import { HANDLE_TABLE_EDIT_HANDLE_PATH, } from '../handle-page-routing-paths'; import { HandleTableComponent } from './handle-table.component'; -import { defaultPagination } from './handle-table-pagination'; +import { + defaultPagination, + paginationID, +} from './handle-table-pagination'; const selectedHandleId = 1; const otherHandleId = 47; @@ -75,9 +88,11 @@ describe('HandleTableComponent', () => { let handleDataService: HandleDataService; let requestService: RequestService; let notificationService: NotificationsServiceStub; + let paginationService: PaginationServiceStub; beforeEach(async () => { notificationService = new NotificationsServiceStub(); + paginationService = new PaginationServiceStub(); handleDataService = jasmine.createSpyObj('handleDataService', { findAll: mockHandleRD$, getLinkPath: of(''), @@ -99,7 +114,7 @@ describe('HandleTableComponent', () => { { provide: RequestService, useValue: requestService }, { provide: HandleDataService, useValue: handleDataService }, { provide: Router, useValue: new RouterStub() }, - { provide: PaginationService, useValue: new PaginationServiceStub() }, + { provide: PaginationService, useValue: paginationService }, { provide: NotificationsService, useValue: notificationService }, ], }) @@ -142,6 +157,31 @@ describe('HandleTableComponent', () => { expect((component as HandleTableComponent).handlesRD$).not.toBeNull(); }); + it('should move the paginator back to page 1 without a new history entry when a search starts', () => { + (component as HandleTableComponent).ngOnInit(); + (component as HandleTableComponent).searchOption = (component as HandleTableComponent).handleOption; + (component as HandleTableComponent).searchQuery = mockHandle.handle; + (component as HandleTableComponent).searchHandles(); + + expect(paginationService.updateRoute).toHaveBeenCalledWith(paginationID, { page: 1 }, {}, false, { replaceUrl: true }); + expect((component as any).handleDataService.findAll).toHaveBeenCalledWith( + jasmine.objectContaining({ currentPage: 1 }), false); + }); + + it('should not let a load that is still running overwrite the rows of a newer search', () => { + const firstLoad$ = new Subject>>(); + const searchResult = createSuccessfulRemoteDataObject(buildPaginatedList(new PageInfo(), [otherMockHandle])); + (handleDataService.findAll as jasmine.Spy).and.returnValues(firstLoad$, of(searchResult)); + + (component as HandleTableComponent).ngOnInit(); + (component as HandleTableComponent).searchOption = (component as HandleTableComponent).handleOption; + (component as HandleTableComponent).searchQuery = otherMockHandle.handle; + (component as HandleTableComponent).searchHandles(); + firstLoad$.next(createSuccessfulRemoteDataObject(buildPaginatedList(new PageInfo(), [mockHandle]))); + + expect((component as HandleTableComponent).handlesRD$.value.payload.page).toEqual([otherMockHandle]); + }); + it('should not allow to have two or more selected handles', () => { const firstId = 1; const secondId = 2; diff --git a/src/app/handle-page/handle-table/handle-table.component.ts b/src/app/handle-page/handle-table/handle-table.component.ts index 0953019e489..3a466ea4c25 100644 --- a/src/app/handle-page/handle-table/handle-table.component.ts +++ b/src/app/handle-page/handle-table/handle-table.component.ts @@ -2,6 +2,7 @@ import { CommonModule } from '@angular/common'; import { ChangeDetectorRef, Component, + OnDestroy, OnInit, } from '@angular/core'; import { FormsModule } from '@angular/forms'; @@ -14,6 +15,7 @@ import { import { BehaviorSubject, combineLatest, + Subscription, } from 'rxjs'; import { scan, @@ -88,7 +90,7 @@ export const RESOURCE_TYPE_SEARCH_OPTION = 'resourceTypeId'; templateUrl: './handle-table.component.html', styleUrls: ['./handle-table.component.scss'], }) -export class HandleTableComponent implements OnInit { +export class HandleTableComponent implements OnInit, OnDestroy { constructor(private handleDataService: HandleDataService, private paginationService: PaginationService, @@ -170,6 +172,11 @@ export class HandleTableComponent implements OnInit { */ selectedHandle = null; + /** + * The running load of the table rows. A new load cancels it, so an older response cannot overwrite newer rows. + */ + private handlesSub: Subscription; + ngOnInit(): void { this.handleRoute = getHandleTableModulePath(); this.initializePaginationOptions(); @@ -181,6 +188,10 @@ export class HandleTableComponent implements OnInit { this.resourceTypeOption = this.translateService.instant('handle-table.table.resource-type'); } + ngOnDestroy(): void { + this.handlesSub?.unsubscribe(); + } + /** * Load all handles based on the pagination and sorting options. */ @@ -193,7 +204,8 @@ export class HandleTableComponent implements OnInit { const currentSort$ = this.getCurrentSort(); const searchTerm$ = new BehaviorSubject(this.searchQuery); - combineLatest([currentPagination$, currentSort$, searchTerm$]).pipe( + this.handlesSub?.unsubscribe(); + this.handlesSub = combineLatest([currentPagination$, currentSort$, searchTerm$]).pipe( scan((prevState, [currentPagination, currentSort, searchTerm]) => { // If search term has changed, reset to page 1; otherwise, keep current page const currentPage = prevState.searchTerm !== searchTerm ? 1 : currentPagination.currentPage; @@ -474,6 +486,9 @@ export class HandleTableComponent implements OnInit { } this.sortConfiguration.field = parsedSearchOption + ':' + parsedSearchQuery; + // The results start on page 1. Replace the URL instead of adding a history entry, + // because Back cannot restore the search filter, which is not in the URL. + this.paginationService.updateRoute(this.options.id, { page: 1 }, {}, false, { replaceUrl: true }); this.getAllHandles(); } From dae411a382f61c108f1aea44b2e0ac60de4cb467 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Thu, 26 Nov 2026 14:38:26 +0100 Subject: [PATCH 2/3] Show the Curate button on claimed tasks only to site administrators The button opens the admin curation page, which only site administrators may open, so other reviewers got a 403 page. Co-Authored-By: Claude Opus 5.5 --- .../claimed-task-actions.component.html | 10 +++++---- .../claimed-task-actions.component.spec.ts | 21 ++++++++++++++++++- .../claimed-task-actions.component.ts | 10 +++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.html b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.html index 5f4ec50b40c..72f07728657 100644 --- a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.html +++ b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.html @@ -10,10 +10,12 @@ } - + @if (canCurate$ | async) { + + } @if (showViewButton) {