diff --git a/src/app/app-routing-paths.ts b/src/app/app-routing-paths.ts index 3fa56698f7..db6b22a023 100644 --- a/src/app/app-routing-paths.ts +++ b/src/app/app-routing-paths.ts @@ -22,9 +22,14 @@ export function getBitstreamModuleRoute() { export function getBitstreamDownloadRoute(bitstream): string { return new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString(); } -export function getBitstreamRequestACopyRoute(item, bitstream): string { +export function getBitstreamRequestACopyRoute(item, bitstream): { routerLink: string, queryParams: any } { const url = new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString(); - return `${url}?bitstream=${bitstream.uuid}`; + return { + routerLink: url, + queryParams: { + bitstream: bitstream.uuid + } + }; } export const ADMIN_MODULE_PATH = 'admin'; diff --git a/src/app/shared/file-download-link/file-download-link.component.html b/src/app/shared/file-download-link/file-download-link.component.html index 0135f74745..0155c40b0a 100644 --- a/src/app/shared/file-download-link/file-download-link.component.html +++ b/src/app/shared/file-download-link/file-download-link.component.html @@ -1,4 +1,4 @@ - + diff --git a/src/app/shared/file-download-link/file-download-link.component.spec.ts b/src/app/shared/file-download-link/file-download-link.component.spec.ts index 8b39b93dc6..bf80dfcdd9 100644 --- a/src/app/shared/file-download-link/file-download-link.component.spec.ts +++ b/src/app/shared/file-download-link/file-download-link.component.spec.ts @@ -11,7 +11,7 @@ import { Item } from '../../core/shared/item.model'; import { getItemModuleRoute } from '../../item-page/item-page-routing-paths'; import { RouterLinkDirectiveStub } from '../testing/router-link-directive.stub'; -describe('FileDownloadLinkComponent', () => { +fdescribe('FileDownloadLinkComponent', () => { let component: FileDownloadLinkComponent; let fixture: ComponentFixture; @@ -66,7 +66,7 @@ describe('FileDownloadLinkComponent', () => { fixture.detectChanges(); }); it('should return the bitstreamPath based on the input bitstream', () => { - expect(component.bitstreamPath$).toBeObservable(cold('-a', {a: new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString()})); + expect(component.bitstreamPath$).toBeObservable(cold('-a', {a: { routerLink: new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString(), queryParams: {} }})); expect(component.canDownload$).toBeObservable(cold('--a', {a: true})); }); @@ -99,7 +99,7 @@ describe('FileDownloadLinkComponent', () => { fixture.detectChanges(); }); it('should return the bitstreamPath based on the input bitstream', () => { - expect(component.bitstreamPath$).toBeObservable(cold('-a', {a: `${new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString()}?bitstream=${bitstream.uuid}`})); + expect(component.bitstreamPath$).toBeObservable(cold('-a', {a: { routerLink: new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString(), queryParams: { bitstream: bitstream.uuid } }})); expect(component.canDownload$).toBeObservable(cold('--a', {a: false})); }); @@ -107,7 +107,7 @@ describe('FileDownloadLinkComponent', () => { scheduler.flush(); fixture.detectChanges(); const link = fixture.debugElement.query(By.css('a')); - expect(link.injector.get(RouterLinkDirectiveStub).routerLink).toContain(`${new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString()}?bitstream=${bitstream.uuid}`); + expect(link.injector.get(RouterLinkDirectiveStub).routerLink).toContain(new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString()); const lock = fixture.debugElement.query(By.css('.fa-lock')).nativeElement; expect(lock).toBeTruthy(); }); @@ -127,7 +127,7 @@ describe('FileDownloadLinkComponent', () => { fixture.detectChanges(); }); it('should return the bitstreamPath based on the input bitstream', () => { - expect(component.bitstreamPath$).toBeObservable(cold('-a', {a: new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString()})); + expect(component.bitstreamPath$).toBeObservable(cold('-a', {a: { routerLink: new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString(), queryParams: {} }})); expect(component.canDownload$).toBeObservable(cold('--a', {a: false})); }); diff --git a/src/app/shared/file-download-link/file-download-link.component.ts b/src/app/shared/file-download-link/file-download-link.component.ts index 40d871109a..a79a71b634 100644 --- a/src/app/shared/file-download-link/file-download-link.component.ts +++ b/src/app/shared/file-download-link/file-download-link.component.ts @@ -39,7 +39,10 @@ export class FileDownloadLinkComponent implements OnInit { @Input() enableRequestACopy = true; - bitstreamPath$: Observable; + bitstreamPath$: Observable<{ + routerLink: string, + queryParams: any, + }>; canDownload$: Observable; @@ -56,7 +59,7 @@ export class FileDownloadLinkComponent implements OnInit { map(([canDownload, canRequestACopy]) => this.getBitstreamPath(canDownload, canRequestACopy)) ); } else { - this.bitstreamPath$ = observableOf(getBitstreamDownloadRoute(this.bitstream)); + this.bitstreamPath$ = observableOf(this.getBitstreamDownloadPath()); this.canDownload$ = observableOf(true); } } @@ -65,6 +68,13 @@ export class FileDownloadLinkComponent implements OnInit { if (!canDownload && canRequestACopy && hasValue(this.item)) { return getBitstreamRequestACopyRoute(this.item, this.bitstream); } - return getBitstreamDownloadRoute(this.bitstream); + return this.getBitstreamDownloadPath(); + } + + getBitstreamDownloadPath() { + return { + routerLink: getBitstreamDownloadRoute(this.bitstream), + queryParams: {} + }; } }