@@ -2,7 +2,6 @@ import { createDispatchMap, select } from '@ngxs/store';
22
33import { TranslatePipe , TranslateService } from '@ngx-translate/core' ;
44
5- import { TreeDragDropService } from 'primeng/api' ;
65import { Button } from 'primeng/button' ;
76import { Select } from 'primeng/select' ;
87import { TableModule } from 'primeng/table' ;
@@ -51,7 +50,7 @@ import { FILE_SIZE_LIMIT } from '@osf/shared/constants/files-limits.const';
5150import { ALL_SORT_OPTIONS } from '@osf/shared/constants/sort-options.const' ;
5251import { SupportedFeature } from '@osf/shared/enums/addon-supported-features.enum' ;
5352import { FileMenuType } from '@osf/shared/enums/file-menu-type.enum' ;
54- import { ResourceType } from '@osf/shared/enums/resource-type.enum' ;
53+ import { CurrentResourceType , ResourceType } from '@osf/shared/enums/resource-type.enum' ;
5554import { FilePageLinkModel } from '@osf/shared/models/files/file-page-link.model' ;
5655import { RenamedFileLinkModel } from '@osf/shared/models/files/renamed-file-link.model' ;
5756import { CustomConfirmationService } from '@osf/shared/services/custom-confirmation.service' ;
@@ -112,7 +111,6 @@ import {
112111 templateUrl : './files.component.html' ,
113112 styleUrl : './files.component.scss' ,
114113 changeDetection : ChangeDetectionStrategy . OnPush ,
115- providers : [ TreeDragDropService ] ,
116114} )
117115export class FilesComponent {
118116 googleFilePickerComponent = viewChild ( GoogleFilePickerComponent ) ;
@@ -162,6 +160,9 @@ export class FilesComponent {
162160 readonly supportedFeatures = select ( FilesSelectors . getStorageSupportedFeatures ) ;
163161 readonly hasWriteAccess = select ( CurrentResourceSelectors . hasResourceWriteAccess ) ;
164162 readonly hasAdminAccess = select ( CurrentResourceSelectors . hasResourceAdminAccess ) ;
163+ readonly currentResourceType = computed < CurrentResourceType > (
164+ ( ) => ( this . resourceMetadata ( ) ?. type as CurrentResourceType ) ?? CurrentResourceType . Projects
165+ ) ;
165166
166167 readonly isGoogleDrive = signal < boolean > ( false ) ;
167168 readonly accountId = signal < string > ( '' ) ;
@@ -428,8 +429,11 @@ export class FilesComponent {
428429 }
429430
430431 onFileTreeSelected ( file : FileModel ) : void {
431- this . filesSelection . push ( file ) ;
432- this . filesSelection = [ ...new Set ( this . filesSelection ) ] ;
432+ if ( this . filesSelection . some ( ( selectedFile ) => selectedFile . id === file . id ) ) {
433+ return ;
434+ }
435+
436+ this . filesSelection = [ ...this . filesSelection , file ] ;
433437 }
434438
435439 onFileTreeUnselected ( file : FileModel ) : void {
@@ -610,13 +614,24 @@ export class FilesComponent {
610614 }
611615
612616 navigateToFile ( file : FileModel ) {
617+ if ( file . guid ) {
618+ this . openFile ( file . guid ) ;
619+ return ;
620+ }
621+
622+ this . filesService . getFileGuid ( file . id ) . subscribe ( ( file ) => {
623+ if ( file . guid ) {
624+ this . openFile ( file . guid ) ;
625+ }
626+ } ) ;
627+ }
628+
629+ private openFile ( guid : string ) : void {
613630 const extras = this . hasViewOnly ( )
614631 ? { queryParams : { view_only : this . viewOnlyService . getViewOnlyParamFromUrl ( this . router . url ) } }
615632 : undefined ;
616633
617- const url = this . router . serializeUrl ( this . router . createUrlTree ( [ '/' , file . guid ] , extras ) ) ;
618-
619- window . open ( url , '_blank' ) ;
634+ window . open ( this . router . serializeUrl ( this . router . createUrlTree ( [ '/' , guid ] , extras ) ) , '_blank' ) ;
620635 }
621636
622637 getAddonName ( addons : ConfiguredAddonModel [ ] , provider : string ) : string {
@@ -632,9 +647,7 @@ export class FilesComponent {
632647 const googleDrive = addons ?. find ( ( addon ) => addon . externalServiceName === FileProvider . GoogleDrive ) ;
633648 if ( googleDrive ) {
634649 this . accountId . set ( googleDrive . baseAccountId ) ;
635- this . selectedRootFolder . set ( {
636- itemId : googleDrive . selectedStorageItemId ,
637- } ) ;
650+ this . selectedRootFolder . set ( { itemId : googleDrive . selectedStorageItemId } ) ;
638651 }
639652 }
640653
@@ -643,10 +656,6 @@ export class FilesComponent {
643656 this . updateFilesList ( ) ;
644657 }
645658
646- onUpdateFoldersStack ( newStack : FileFolderModel [ ] ) : void {
647- this . foldersStack = [ ...newStack ] ;
648- }
649-
650659 handleRootFolderChange ( selectedFolder : FileLabelModel ) {
651660 const provider = selectedFolder . folder ?. provider ;
652661 const resourceId = this . resourceId ( ) ;
0 commit comments