diff --git a/src/app/file-browser/components/file-list-item/file-list-item.component.html b/src/app/file-browser/components/file-list-item/file-list-item.component.html index 1e672a98d..425a88995 100644 --- a/src/app/file-browser/components/file-list-item/file-list-item.component.html +++ b/src/app/file-browser/components/file-list-item/file-list-item.component.html @@ -49,7 +49,11 @@ @if (!item.isFolder && !isZip) {
} @@ -82,7 +86,7 @@ > {{ item.displayName }}

- @if (!showAccess && item.ShareVOs?.length) { + @if (!showAccess && item.ShareVOs?.length && !isUnlistedShare) { { expect(TestBed.inject(DataService).registerItem).toHaveBeenCalled(); component.ngOnDestroy(); - - expect(TestBed.inject(DataService).unregisterItem).toHaveBeenCalledWith( - component.item, - ); }); it('should handle drag events', () => { diff --git a/src/app/file-browser/components/file-list-item/file-list-item.component.ts b/src/app/file-browser/components/file-list-item/file-list-item.component.ts index 599aac19a..5719aa345 100644 --- a/src/app/file-browser/components/file-list-item/file-list-item.component.ts +++ b/src/app/file-browser/components/file-list-item/file-list-item.component.ts @@ -339,7 +339,6 @@ export class FileListItemComponent } ngOnDestroy() { - this.dataService.unregisterItem(this.item); unsubscribeAll(this.subscriptions); } @@ -494,10 +493,6 @@ export class FileListItemComponent onItemClick(event: MouseEvent) { if (this.isUnlistedShare) { - //TO DO: make preview for folder --> story PER-10314 - if (this.item.isFolder) { - return; - } this.goToItem(); return; } @@ -561,6 +556,13 @@ export class FileListItemComponent } if (this.item.isFolder) { + if (this.isUnlistedShare) { + this.itemClicked.emit({ + item: this.item, + selectable: false, + }); + return; + } if (this.checkFolderView && this.isFolderViewSet()) { this.router.navigate([ rootUrl, diff --git a/src/app/file-browser/components/file-list/file-list.component.html b/src/app/file-browser/components/file-list/file-list.component.html index 542df6025..06dcd8e53 100644 --- a/src/app/file-browser/components/file-list/file-list.component.html +++ b/src/app/file-browser/components/file-list/file-list.component.html @@ -35,6 +35,8 @@ @if (showSidebar) { } -
- -
+@if (!isUnlistedShare || router.url.includes('record')) { +
+ +
+} diff --git a/src/app/file-browser/components/file-list/file-list.component.spec.ts b/src/app/file-browser/components/file-list/file-list.component.spec.ts index e8f32504d..c86c76583 100644 --- a/src/app/file-browser/components/file-list/file-list.component.spec.ts +++ b/src/app/file-browser/components/file-list/file-list.component.spec.ts @@ -21,6 +21,7 @@ import { ShareLinksService } from '@root/app/share-links/services/share-links.se import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { Component } from '@angular/core'; +import { ApiService } from '@shared/services/api/api.service'; import { FileListComponent } from './file-list.component'; @Component({ template: '' }) @@ -94,6 +95,16 @@ describe('FileListComponent', () => { .and.returnValue(Promise.resolve(false)), }; + const mockApiService = { + folder: { + getWithChildren: jasmine.createSpy().and.returnValue( + of({ + getFolderVO: jasmine.createSpy(), + }), + ), + }, + }; + const mockDragService = { events: () => of({ type: 'start' }), }; @@ -120,6 +131,7 @@ describe('FileListComponent', () => { { provide: ShareLinksService, useValue: mockShareLinksService }, { provide: Location, useValue: { replaceState: jasmine.createSpy() } }, { provide: DOCUMENT, useValue: document }, + { provide: ApiService, useValue: mockApiService }, ], }).compileComponents(); diff --git a/src/app/file-browser/components/file-list/file-list.component.ts b/src/app/file-browser/components/file-list/file-list.component.ts index e626aabaf..e4b7df09d 100644 --- a/src/app/file-browser/components/file-list/file-list.component.ts +++ b/src/app/file-browser/components/file-list/file-list.component.ts @@ -17,6 +17,7 @@ import { NgZone, Renderer2, DOCUMENT, + OnChanges, } from '@angular/core'; import { Location } from '@angular/common'; import { ActivatedRoute, Router, NavigationEnd } from '@angular/router'; @@ -81,6 +82,7 @@ const DRAG_SCROLL_STEP = 20; }) export class FileListComponent implements + OnChanges, OnInit, AfterViewInit, OnDestroy, @@ -90,6 +92,10 @@ export class FileListComponent @ViewChildren(FileListItemComponent) listItemsQuery: QueryList; + /** + * currentFolder represents the shared folder in case of unlisted shares and + * the rendered folder when the component is used in private/public/shared features + */ currentFolder: FolderVO; listItems: FileListItemComponent[] = []; @@ -105,6 +111,12 @@ export class FileListComponent @Input() allowNavigation = true; + /** + * the ephemeralFolder is useful for using the component as is, without needing to change the route + * also this will preserve the currentFolder, where the navigation by click starts from + */ + @Input() ephemeralFolder: FolderVO = null; + @Output() itemClicked = new EventEmitter(); private visibleItemsHandlerDebounced: Function; @@ -113,6 +125,7 @@ export class FileListComponent private reinit = false; private inFileView = false; private inDialog = false; + public isUnlistedShare = false; @ViewChild('scroll') private scrollElement: ElementRef; visibleItems: Set = new Set(); @@ -138,7 +151,7 @@ export class FileListComponent private account: AccountService, private route: ActivatedRoute, private dataService: DataService, - private router: Router, + public router: Router, private elementRef: ElementRef, private folderViewService: FolderViewService, private routeHistory: RouteHistoryService, @@ -151,7 +164,8 @@ export class FileListComponent private event: EventService, private shareLinksService: ShareLinksService, ) { - this.currentFolder = this.route.snapshot.data.currentFolder; + this.currentFolder = + this.ephemeralFolder || this.route.snapshot.data.currentFolder; // this.noFileListPadding = this.route.snapshot.data.noFileListPadding; this.fileListCentered = this.route.snapshot.data.fileListCentered; this.showSidebar = this.route.snapshot.data.showSidebar; @@ -200,6 +214,10 @@ export class FileListComponent } } + async ngOnChanges() { + this.syncStateWithRouteandInput(); + } + registerArchiveChangeHandlers() { // register for archive change events to reload the root section this.subscriptions.push( @@ -315,22 +333,15 @@ export class FileListComponent } } - refreshView() { - this.ngOnInit(); + async refreshView() { + await this.ngOnInit(); setTimeout(() => { this.ngAfterViewInit(); }, 1); } - ngOnInit() { - this.currentFolder = this.route.snapshot.data.currentFolder; - this.showSidebar = this.route.snapshot.data.showSidebar; - this.dataService.setCurrentFolder(this.currentFolder); - this.isRootFolder = this.currentFolder.type.includes('root'); - this.showFolderDescription = this.route.snapshot.data.showFolderDescription; - - this.visibleItems.clear(); - this.reinit = true; + async ngOnInit() { + await this.syncStateWithRouteandInput(); } ngAfterViewInit() { @@ -509,28 +520,30 @@ export class FileListComponent async loadVisibleItems(animate?: boolean) { this.debug('loadVisibleItems %d items', this.visibleItems.size); - if (this.visibleItems.size) { - const visibleListItems = Array.from(this.visibleItems); - this.visibleItems.clear(); - if (animate) { - const targetElems = visibleListItems.map( - (c) => c.element.nativeElement, - ); - gsap.from(targetElems, 0.25, { - duration: 0.25, - opacity: 0, - ease: 'Power4.easeOut', - stagger: { - amount: 0.015, - }, - }); - } + if (this.ephemeralFolder !== null) { + return; + } + if (!this.visibleItems.size) { + return; + } - const itemsToFetch = visibleListItems.map((c) => c.item); + const visibleListItems = Array.from(this.visibleItems); + this.visibleItems.clear(); + if (animate) { + const targetElems = visibleListItems.map((c) => c.element.nativeElement); + gsap.from(targetElems, 0.25, { + duration: 0.25, + opacity: 0, + ease: 'Power4.easeOut', + stagger: { + amount: 0.015, + }, + }); + } - if (itemsToFetch.length) { - await this.dataService.fetchLeanItems(itemsToFetch); - } + const itemsToFetch = visibleListItems.map((c) => c.item); + if (itemsToFetch.length && !this.isUnlistedShare) { + await this.dataService.fetchLeanItems(itemsToFetch); } } @@ -542,4 +555,18 @@ export class FileListComponent this.visibleItems.delete(event.component); } } + + private async syncStateWithRouteandInput() { + this.isUnlistedShare = await this.shareLinksService.isUnlistedShare(); + + this.currentFolder = + this.ephemeralFolder || this.route.snapshot.data.currentFolder; + this.showSidebar = this.route.snapshot.data.showSidebar; + this.dataService.setCurrentFolder(this.currentFolder); + this.isRootFolder = this.currentFolder.type.includes('root'); + this.showFolderDescription = this.route.snapshot.data.showFolderDescription; + + this.visibleItems.clear(); + this.reinit = true; + } } diff --git a/src/app/file-browser/components/file-viewer/file-viewer.component.ts b/src/app/file-browser/components/file-viewer/file-viewer.component.ts index 362fb785a..1868f1f9b 100644 --- a/src/app/file-browser/components/file-viewer/file-viewer.component.ts +++ b/src/app/file-browser/components/file-viewer/file-viewer.component.ts @@ -175,10 +175,11 @@ export class FileViewerComponent implements OnInit, OnDestroy { } private setRecordsToPreview(resolvedRecord: RecordVO) { - this.records = filter( - this.dataService.currentFolder.ChildItemVOs, - 'isRecord', - ) as RecordVO[]; + const currentFolderChildren = + this.dataService?.ephemeralFolder?.ChildItemVOs || + this.dataService.currentFolder.ChildItemVOs; + + this.records = filter(currentFolderChildren, 'isRecord') as RecordVO[]; this.currentIndex = findIndex(this.records, { folder_linkId: resolvedRecord.folder_linkId, }); diff --git a/src/app/share-preview/components/share-preview/share-preview.component.html b/src/app/share-preview/components/share-preview/share-preview.component.html index 91fc25705..4ff4d9f6d 100644 --- a/src/app/share-preview/components/share-preview/share-preview.component.html +++ b/src/app/share-preview/components/share-preview/share-preview.component.html @@ -69,13 +69,22 @@