From 3bc419e12852527bf82047010d4bf7280712140c Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Wed, 25 Apr 2018 13:01:00 +0300 Subject: [PATCH] download shared nodes (#3229) --- .../node-download.directive.spec.ts | 22 +++++++++++++++++++ .../directives/node-download.directive.ts | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/content-services/directives/node-download.directive.spec.ts b/lib/content-services/directives/node-download.directive.spec.ts index 99c9c856f2..2fe26f68b7 100644 --- a/lib/content-services/directives/node-download.directive.spec.ts +++ b/lib/content-services/directives/node-download.directive.spec.ts @@ -95,6 +95,17 @@ describe('NodeDownloadDirective', () => { expect(contentService.getContentUrl).toHaveBeenCalledWith(node.entry.id, true); }); + it('should download selected shared node as file', () => { + spyOn(contentService, 'getContentUrl'); + const node = { entry: { nodeId: 'shared-node-id', isFile: true } }; + component.selection = [node]; + + fixture.detectChanges(); + element.triggerEventHandler('click', null); + + expect(contentService.getContentUrl).toHaveBeenCalledWith(node.entry.nodeId, true); + }); + it('should download selected files nodes as zip', () => { const node1 = { entry: { id: 'node-1' } }; const node2 = { entry: { id: 'node-2' } }; @@ -106,6 +117,17 @@ describe('NodeDownloadDirective', () => { expect(dialogSpy.calls.argsFor(0)[1].data).toEqual({ nodeIds: [ 'node-1', 'node-2' ] }); }); + it('should download selected shared files nodes as zip', () => { + const node1 = { entry: { nodeId: 'shared-node-1' } }; + const node2 = { entry: { nodeId: 'shared-node-2' } }; + component.selection = [node1, node2]; + + fixture.detectChanges(); + element.triggerEventHandler('click', null); + + expect(dialogSpy.calls.argsFor(0)[1].data).toEqual({ nodeIds: [ 'shared-node-1', 'shared-node-2' ] }); + }); + it('should download selected folder node as zip', () => { const node = { entry: { isFolder: true, id: 'node-id' } }; component.selection = [node]; diff --git a/lib/content-services/directives/node-download.directive.ts b/lib/content-services/directives/node-download.directive.ts index e4ac2dea7f..a5e38c1ec9 100644 --- a/lib/content-services/directives/node-download.directive.ts +++ b/lib/content-services/directives/node-download.directive.ts @@ -86,8 +86,10 @@ export class NodeDownloadDirective { private downloadFile(node: MinimalNodeEntity) { if (node && node.entry) { const contentApi = this.apiService.getInstance().content; + // nodeId for Shared node + const id = ( node.entry).nodeId || node.entry.id; - const url = contentApi.getContentUrl(node.entry.id, true); + const url = contentApi.getContentUrl(id, true); const fileName = node.entry.name; this.download(url, fileName);