From dbb558a389ddcb611e93aa2fc59df1d047f27d49 Mon Sep 17 00:00:00 2001 From: Kyrylo Petrov Date: Mon, 2 Jun 2025 18:15:11 +0300 Subject: [PATCH 1/3] chore(files): api # Conflicts: # src/app/features/project/addons/addons.component.spec.ts # src/app/features/project/files/components/file-detail/file-detail.component.html # src/app/features/project/files/components/file-detail/file-detail.component.ts # src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.html # src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.scss # src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.spec.ts # src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.ts # src/app/features/project/files/mappers/file-custom-metadata.mapper.ts # src/app/features/project/files/mappers/project-metadata.mapper.ts # src/app/features/project/files/models/index.ts # src/app/features/project/files/project-files.component.html # src/app/features/project/files/project-files.component.scss # src/app/features/project/files/project-files.component.ts # src/app/features/project/files/services/project-files.service.ts # src/app/features/project/files/store/project-files.actions.ts # src/app/features/project/files/store/project-files.model.ts # src/app/features/project/files/store/project-files.selectors.ts # src/app/shared/components/text-input/text-input.component.spec.ts --- .../project/addons/addons.component.spec.ts | 15 ++++ .../file-detail/file-detail.component.html | 58 +++++++++++++ .../osf-models/file-custom-metafata.model.ts | 7 ++ .../requests/patch-file-metadata.mode.ts | 6 ++ .../shared/utils/format-file-size.helper.ts | 11 +++ src/assets/i18n/en.json | 84 +++++++++++++++++++ src/assets/styles/_base.scss | 6 ++ 7 files changed, 187 insertions(+) create mode 100644 src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts create mode 100644 src/app/features/project/files/models/requests/patch-file-metadata.mode.ts create mode 100644 src/app/shared/utils/format-file-size.helper.ts diff --git a/src/app/features/project/addons/addons.component.spec.ts b/src/app/features/project/addons/addons.component.spec.ts index 4d1a6de4c..165e8abda 100644 --- a/src/app/features/project/addons/addons.component.spec.ts +++ b/src/app/features/project/addons/addons.component.spec.ts @@ -1,5 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +<<<<<<<< HEAD:src/app/features/project/addons/addons.component.spec.ts import { AddonsComponent } from './addons.component'; describe('AddonsComponent', () => { @@ -12,6 +13,20 @@ describe('AddonsComponent', () => { }).compileComponents(); fixture = TestBed.createComponent(AddonsComponent); +======== +import { MoveFileDialogComponent } from './move-file-dialog.component'; + +describe('MoveFileDialogComponent', () => { + let component: MoveFileDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [MoveFileDialogComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(MoveFileDialogComponent); +>>>>>>>> 0317809 (chore(files): api):src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.spec.ts component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/features/project/files/components/file-detail/file-detail.component.html b/src/app/features/project/files/components/file-detail/file-detail.component.html index 609230805..215b3a801 100644 --- a/src/app/features/project/files/components/file-detail/file-detail.component.html +++ b/src/app/features/project/files/components/file-detail/file-detail.component.html @@ -34,3 +34,61 @@ + + +
+
+

{{ 'project.files.detail.fileMetadata.fields.title' | translate }}

+ +
+
+

{{ 'project.files.detail.fileMetadata.fields.description' | translate }}

+ +
+
+

{{ 'project.files.detail.fileMetadata.fields.resourceType' | translate }}

+ +
+
+

{{ 'project.files.detail.fileMetadata.fields.resourceLanguage' | translate }}

+ +
+ +
+ + +
+
+
diff --git a/src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts b/src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts new file mode 100644 index 000000000..aace1c784 --- /dev/null +++ b/src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts @@ -0,0 +1,7 @@ +export interface OsfFileCustomMetadata { + id: string; + language: string; + resourceTypeGeneral: string; + title: string; + description: string; +} diff --git a/src/app/features/project/files/models/requests/patch-file-metadata.mode.ts b/src/app/features/project/files/models/requests/patch-file-metadata.mode.ts new file mode 100644 index 000000000..b2a9869dc --- /dev/null +++ b/src/app/features/project/files/models/requests/patch-file-metadata.mode.ts @@ -0,0 +1,6 @@ +export interface PatchFileMetadata { + description: string | null; + language: string | null; + title: string | null; + resource_type_general: string | null; +} diff --git a/src/app/shared/utils/format-file-size.helper.ts b/src/app/shared/utils/format-file-size.helper.ts new file mode 100644 index 000000000..3a65fcdd5 --- /dev/null +++ b/src/app/shared/utils/format-file-size.helper.ts @@ -0,0 +1,11 @@ +export function formatFileSize(bytes: number): string { + if (bytes < 1024) { + return `${bytes} B`; + } else if (bytes < 1024 ** 2) { + return `${(bytes / 1024).toFixed(1)} kB`; + } else if (bytes < 1024 ** 3) { + return `${(bytes / 1024 ** 2).toFixed(1)} MB`; + } else { + return `${(bytes / 1024 ** 3).toFixed(1)} GB`; + } +} diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 664c7eb8e..076f3b4cb 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -560,6 +560,90 @@ "lastUpdated": "Last Updated:", "description": "Description:", "openResources": "Open Resources" + } + }, + "files": { + "title": "Files", + "storageLocation": "OSF Storage", + "searchPlaceholder": "Search your projects", + "sort": { + "placeholder": "Sort", + "nameAZ": "Name: A-Z", + "nameZA": "Name: Z-A", + "lastModifiedOldest": "Last modified: oldest to newest", + "lastModifiedNewest": "Last modified: newest to oldest" + }, + "actions": { + "downloadAsZip": "Download As Zip", + "createFolder": "Create Folder", + "uploadFile": "Upload File" + }, + "dialogs": { + "uploadFile": { + "title": "Upload file" + }, + "createFolder": { + "title": "Create folder", + "folderName": "New folder name", + "folderNamePlaceholder": "Please enter a folder name", + "buttons": { + "cancel": "Cancel", + "save": "Save" + } + }, + "renameFile": { + "title": "Rename file", + "renameLabel": "Please rename the file", + "buttons": { + "cancel": "Cancel", + "save": "Save" + } + } + }, + "emptyState": "This folder is empty", + "menu": { + "download": "Download", + "copy": "Copy", + "move": "Move", + "rename": "Rename", + "delete": "Delete" + }, + "detail": { + "backToList": "Back to list of files", + "fileMetadata": { + "title": "File Metadata", + "edit": "Edit", + "fields": { + "title": "Title", + "description": "Description", + "resourceType": "Resource Type", + "resourceLanguage": "Resource Language" + } + }, + "projectMetadata": { + "title": "Project Metadata", + "edit": "Edit", + "fields": { + "funder": "Funder", + "awardTitle": "Award title", + "awardNumber": "Award number", + "awardUri": "Award URI", + "title": "Title", + "description": "Description", + "resourceType": "Resource type", + "resourceLanguage": "Resource language", + "dateCreated": "Date created", + "dateModified": "Date modified", + "contributors": "Contributors" + } + }, + "editDialog": { + "title": "Edit File Metadata", + "buttons": { + "cancel": "Cancel", + "save": "Save" + } + } } }, "files": { diff --git a/src/assets/styles/_base.scss b/src/assets/styles/_base.scss index ca84fddc4..c8835472d 100644 --- a/src/assets/styles/_base.scss +++ b/src/assets/styles/_base.scss @@ -49,6 +49,12 @@ list-style: none; } + .inside-list { + li { + list-style: inside; + } + } + a, a:visited { text-decoration: none; From 360379bb2a9f5d2e24afa8064cc8c3fa68309afd Mon Sep 17 00:00:00 2001 From: Kyrylo Petrov Date: Tue, 3 Jun 2025 14:09:40 +0300 Subject: [PATCH 2/3] fix(files-api): general fixes --- .../file-detail/file-detail.component.html | 58 ------------------- .../osf-models/file-custom-metafata.model.ts | 7 --- .../requests/patch-file-metadata.mode.ts | 6 -- .../shared/utils/format-file-size.helper.ts | 11 ---- src/assets/i18n/en.json | 31 ++-------- src/assets/styles/_base.scss | 6 -- 6 files changed, 5 insertions(+), 114 deletions(-) delete mode 100644 src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts delete mode 100644 src/app/features/project/files/models/requests/patch-file-metadata.mode.ts delete mode 100644 src/app/shared/utils/format-file-size.helper.ts diff --git a/src/app/features/project/files/components/file-detail/file-detail.component.html b/src/app/features/project/files/components/file-detail/file-detail.component.html index 215b3a801..609230805 100644 --- a/src/app/features/project/files/components/file-detail/file-detail.component.html +++ b/src/app/features/project/files/components/file-detail/file-detail.component.html @@ -34,61 +34,3 @@ - - -
-
-

{{ 'project.files.detail.fileMetadata.fields.title' | translate }}

- -
-
-

{{ 'project.files.detail.fileMetadata.fields.description' | translate }}

- -
-
-

{{ 'project.files.detail.fileMetadata.fields.resourceType' | translate }}

- -
-
-

{{ 'project.files.detail.fileMetadata.fields.resourceLanguage' | translate }}

- -
- -
- - -
-
-
diff --git a/src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts b/src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts deleted file mode 100644 index aace1c784..000000000 --- a/src/app/features/project/files/models/osf-models/file-custom-metafata.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface OsfFileCustomMetadata { - id: string; - language: string; - resourceTypeGeneral: string; - title: string; - description: string; -} diff --git a/src/app/features/project/files/models/requests/patch-file-metadata.mode.ts b/src/app/features/project/files/models/requests/patch-file-metadata.mode.ts deleted file mode 100644 index b2a9869dc..000000000 --- a/src/app/features/project/files/models/requests/patch-file-metadata.mode.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface PatchFileMetadata { - description: string | null; - language: string | null; - title: string | null; - resource_type_general: string | null; -} diff --git a/src/app/shared/utils/format-file-size.helper.ts b/src/app/shared/utils/format-file-size.helper.ts deleted file mode 100644 index 3a65fcdd5..000000000 --- a/src/app/shared/utils/format-file-size.helper.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function formatFileSize(bytes: number): string { - if (bytes < 1024) { - return `${bytes} B`; - } else if (bytes < 1024 ** 2) { - return `${(bytes / 1024).toFixed(1)} kB`; - } else if (bytes < 1024 ** 3) { - return `${(bytes / 1024 ** 2).toFixed(1)} MB`; - } else { - return `${(bytes / 1024 ** 3).toFixed(1)} GB`; - } -} diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 076f3b4cb..47a729a04 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -560,7 +560,7 @@ "lastUpdated": "Last Updated:", "description": "Description:", "openResources": "Open Resources" - } + } }, "files": { "title": "Files", @@ -585,29 +585,15 @@ "createFolder": { "title": "Create folder", "folderName": "New folder name", - "folderNamePlaceholder": "Please enter a folder name", - "buttons": { - "cancel": "Cancel", - "save": "Save" - } + "folderNamePlaceholder": "Please enter a folder name" }, "renameFile": { "title": "Rename file", - "renameLabel": "Please rename the file", - "buttons": { - "cancel": "Cancel", - "save": "Save" - } - } + "renameLabel": "Please rename the file" + }, + "moveFile": "Cannot move to the same folder" }, "emptyState": "This folder is empty", - "menu": { - "download": "Download", - "copy": "Copy", - "move": "Move", - "rename": "Rename", - "delete": "Delete" - }, "detail": { "backToList": "Back to list of files", "fileMetadata": { @@ -636,13 +622,6 @@ "dateModified": "Date modified", "contributors": "Contributors" } - }, - "editDialog": { - "title": "Edit File Metadata", - "buttons": { - "cancel": "Cancel", - "save": "Save" - } } } }, diff --git a/src/assets/styles/_base.scss b/src/assets/styles/_base.scss index c8835472d..ca84fddc4 100644 --- a/src/assets/styles/_base.scss +++ b/src/assets/styles/_base.scss @@ -49,12 +49,6 @@ list-style: none; } - .inside-list { - li { - list-style: inside; - } - } - a, a:visited { text-decoration: none; From 8be8b672733ecbeb86ce447974bca14b9f1e647f Mon Sep 17 00:00:00 2001 From: Kyrylo Petrov Date: Tue, 3 Jun 2025 15:08:58 +0300 Subject: [PATCH 3/3] fix(files-api): fix moving files --- .../move-file-dialog/move-file-dialog.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.ts b/src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.ts index 5012f1e76..2a54e4123 100644 --- a/src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.ts +++ b/src/app/features/project/files/components/move-file-dialog/move-file-dialog.component.ts @@ -101,7 +101,7 @@ export class MoveFileDialogComponent { path = '/'; } - this.dispatch.setFilesIsLoading(true); + this.isFilesUpdating.set(true); this.projectFilesService .moveFile(this.config.data.file.links.move, path, this.config.data.projectId, this.config.data.action) .pipe( @@ -110,9 +110,11 @@ export class MoveFileDialogComponent { finalize(() => { this.dispatch.setCurrentFolder(this.currentFolder()); this.dispatch.setMoveFileCurrentFolder(undefined); + this.isFilesUpdating.set(false); }) ) .subscribe((file) => { + this.dialogRef.close(); if (file.id) { const filesLink = this.currentFolder()?.relationships.filesLink; if (filesLink) { @@ -122,6 +124,5 @@ export class MoveFileDialogComponent { } } }); - this.dialogRef.close(); } }