From ecf95ca2dc740207068b902e53c46765d60badbf Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 14 Nov 2025 13:57:39 +0200 Subject: [PATCH 1/6] add pagination for registration files retrieval --- .../features/registries/store/handlers/files.handlers.ts | 4 ++-- src/app/shared/services/files.service.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/features/registries/store/handlers/files.handlers.ts b/src/app/features/registries/store/handlers/files.handlers.ts index 478dd1e8e..f852f6be4 100644 --- a/src/app/features/registries/store/handlers/files.handlers.ts +++ b/src/app/features/registries/store/handlers/files.handlers.ts @@ -34,7 +34,7 @@ export class FilesHandlers { ); } - getProjectFiles(ctx: StateContext, { filesLink }: GetFiles) { + getProjectFiles(ctx: StateContext, { filesLink, page }: GetFiles) { const state = ctx.getState(); ctx.patchState({ files: { @@ -43,7 +43,7 @@ export class FilesHandlers { }, }); - return this.filesService.getFilesWithoutFiltering(filesLink).pipe( + return this.filesService.getFilesWithoutFiltering(filesLink, page).pipe( tap((response) => { ctx.patchState({ files: { diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 988adbcc1..57640249d 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -85,9 +85,12 @@ export class FilesService { .pipe(map((response) => ({ files: FilesMapper.getFileFolders(response.data), meta: response.meta }))); } - getFilesWithoutFiltering(filesLink: string): Observable { + getFilesWithoutFiltering(filesLink: string, page = 1): Observable { + const params: Record = { + page: page.toString(), + } return this.jsonApiService - .get(filesLink) + .get(filesLink, params) .pipe(map((response) => FilesMapper.getFiles(response.data))); } From 698ad743b6070c5db845c866b0b3e648e25f9b7e Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 14 Nov 2025 14:01:10 +0200 Subject: [PATCH 2/6] trigger scroll action for registration files to call pagination --- .../components/files-control/files-control.component.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/features/registries/components/files-control/files-control.component.html b/src/app/features/registries/components/files-control/files-control.component.html index f2a233060..93fd6d2fa 100644 --- a/src/app/features/registries/components/files-control/files-control.component.html +++ b/src/app/features/registries/components/files-control/files-control.component.html @@ -46,6 +46,7 @@ [storage]="null" [currentFolder]="currentFolder()!" [isLoading]="isFilesLoading()" + [scrollHeight]="'200px'" [viewOnly]="filesViewOnly()" [resourceId]="projectId()" [provider]="provider()" From 7c6933b08e252366b850b247e8a3f96e07617aa8 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 14 Nov 2025 14:38:46 +0200 Subject: [PATCH 3/6] take total files count from metadata --- .../store/preprint-stepper/preprint-stepper.state.ts | 6 +++--- .../features/registries/store/handlers/files.handlers.ts | 4 ++-- src/app/shared/services/files.service.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts index d63e44fad..c960a444b 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts @@ -308,12 +308,12 @@ export class PreprintStepperState { getProjectFilesByLink(ctx: StateContext, action: FetchProjectFilesByLink) { ctx.setState(patch({ projectFiles: patch({ isLoading: true }) })); - return this.fileService.getFilesWithoutFiltering(action.filesLink).pipe( - tap((files: FileModel[]) => { + return this.fileService.getFilesWithoutFiltering(action.filesLink, 1).pipe( + tap((response) => { ctx.setState( patch({ projectFiles: patch({ - data: files, + data: response.files, isLoading: false, }), }) diff --git a/src/app/features/registries/store/handlers/files.handlers.ts b/src/app/features/registries/store/handlers/files.handlers.ts index f852f6be4..0fa48c323 100644 --- a/src/app/features/registries/store/handlers/files.handlers.ts +++ b/src/app/features/registries/store/handlers/files.handlers.ts @@ -47,10 +47,10 @@ export class FilesHandlers { tap((response) => { ctx.patchState({ files: { - data: response, + data: response.files, isLoading: false, error: null, - totalCount: response.length, + totalCount: response.meta?.total ?? 0, }, }); }), diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 57640249d..ca6eba59c 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -85,13 +85,13 @@ export class FilesService { .pipe(map((response) => ({ files: FilesMapper.getFileFolders(response.data), meta: response.meta }))); } - getFilesWithoutFiltering(filesLink: string, page = 1): Observable { + getFilesWithoutFiltering(filesLink: string, page = 1): Observable<{ files: FileModel[]; meta?: MetaJsonApi }> { const params: Record = { page: page.toString(), } return this.jsonApiService .get(filesLink, params) - .pipe(map((response) => FilesMapper.getFiles(response.data))); + .pipe(map((response) => ({ files: FilesMapper.getFiles(response.data), meta: response.meta }))); } uploadFile( From 1ac195e927d01ac3558cacf0a18070e0deb6065c Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 14 Nov 2025 22:39:12 +0200 Subject: [PATCH 4/6] show all available files of project when scrolling on registration creation --- .../components/files-control/files-control.component.html | 2 +- .../features/registries/store/handlers/files.handlers.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/features/registries/components/files-control/files-control.component.html b/src/app/features/registries/components/files-control/files-control.component.html index 93fd6d2fa..bf53c0a2f 100644 --- a/src/app/features/registries/components/files-control/files-control.component.html +++ b/src/app/features/registries/components/files-control/files-control.component.html @@ -46,7 +46,7 @@ [storage]="null" [currentFolder]="currentFolder()!" [isLoading]="isFilesLoading()" - [scrollHeight]="'200px'" + [scrollHeight]="'500px'" [viewOnly]="filesViewOnly()" [resourceId]="projectId()" [provider]="provider()" diff --git a/src/app/features/registries/store/handlers/files.handlers.ts b/src/app/features/registries/store/handlers/files.handlers.ts index 0fa48c323..4e793cd03 100644 --- a/src/app/features/registries/store/handlers/files.handlers.ts +++ b/src/app/features/registries/store/handlers/files.handlers.ts @@ -40,14 +40,18 @@ export class FilesHandlers { files: { ...state.files, isLoading: true, + error: null, + totalCount: 0, }, }); return this.filesService.getFilesWithoutFiltering(filesLink, page).pipe( tap((response) => { + const newData = page === 1 ? response.files : [...(state.files.data ?? []), ...response.files]; + ctx.patchState({ files: { - data: response.files, + data: newData, isLoading: false, error: null, totalCount: response.meta?.total ?? 0, From 75cc1eee3a77e1dbbd1def6a0f2242a98bc1bb1d Mon Sep 17 00:00:00 2001 From: mkovalua Date: Mon, 17 Nov 2025 14:23:04 +0200 Subject: [PATCH 5/6] fix linter issues --- src/app/shared/services/files.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index ca6eba59c..363009762 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -88,7 +88,7 @@ export class FilesService { getFilesWithoutFiltering(filesLink: string, page = 1): Observable<{ files: FileModel[]; meta?: MetaJsonApi }> { const params: Record = { page: page.toString(), - } + }; return this.jsonApiService .get(filesLink, params) .pipe(map((response) => ({ files: FilesMapper.getFiles(response.data), meta: response.meta }))); From 13607f3c36782a4f128d1e439b391ba532ae4d74 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Mon, 17 Nov 2025 16:02:53 +0200 Subject: [PATCH 6/6] resolve CR comments --- .../preprint-stepper/preprint-stepper.state.ts | 2 +- .../registries/store/handlers/files.handlers.ts | 4 ++-- src/app/shared/services/files.service.ts | 13 +++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts index c960a444b..bd43281ba 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts @@ -313,7 +313,7 @@ export class PreprintStepperState { ctx.setState( patch({ projectFiles: patch({ - data: response.files, + data: response.data, isLoading: false, }), }) diff --git a/src/app/features/registries/store/handlers/files.handlers.ts b/src/app/features/registries/store/handlers/files.handlers.ts index 4e793cd03..e6b5d4f38 100644 --- a/src/app/features/registries/store/handlers/files.handlers.ts +++ b/src/app/features/registries/store/handlers/files.handlers.ts @@ -47,14 +47,14 @@ export class FilesHandlers { return this.filesService.getFilesWithoutFiltering(filesLink, page).pipe( tap((response) => { - const newData = page === 1 ? response.files : [...(state.files.data ?? []), ...response.files]; + const newData = page === 1 ? response.data : [...(state.files.data ?? []), ...response.data]; ctx.patchState({ files: { data: newData, isLoading: false, error: null, - totalCount: response.meta?.total ?? 0, + totalCount: response.totalCount, }, }); }), diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 363009762..0fd3306e0 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -16,6 +16,7 @@ import { OsfFileRevision, PatchFileMetadata, } from '@osf/features/files/models'; +import { PaginatedData } from '@osf/shared/models/paginated-data.model'; import { FileKind } from '../enums/file-kind.enum'; import { AddonMapper } from '../mappers/addon.mapper'; @@ -85,13 +86,17 @@ export class FilesService { .pipe(map((response) => ({ files: FilesMapper.getFileFolders(response.data), meta: response.meta }))); } - getFilesWithoutFiltering(filesLink: string, page = 1): Observable<{ files: FileModel[]; meta?: MetaJsonApi }> { + getFilesWithoutFiltering(filesLink: string, page = 1): Observable> { const params: Record = { page: page.toString(), }; - return this.jsonApiService - .get(filesLink, params) - .pipe(map((response) => ({ files: FilesMapper.getFiles(response.data), meta: response.meta }))); + return this.jsonApiService.get(filesLink, params).pipe( + map((response) => ({ + data: FilesMapper.getFiles(response.data), + totalCount: response.meta.total, + pageSize: response.meta.per_page, + })) + ); } uploadFile(