From ae367c7e97b99885c7cb1feadae22aa1bb6cb729 Mon Sep 17 00:00:00 2001
From: Vincent Petry <pvince81@owncloud.com>
Date: Mon, 8 Feb 2016 17:02:05 +0100
Subject: [PATCH] Fix elementToFile to also return path when defined

Fixes issue when opening the share dialog for a file inside the favorite
list, and the file is from a subfolder
---
 apps/files/js/filelist.js           | 4 ++++
 apps/files/tests/js/filelistSpec.js | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 35999b5d0ee..1a6f38d3d7c 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -815,6 +815,10 @@
 			if (mountType) {
 				data.mountType = mountType;
 			}
+			var path = $el.attr('data-path');
+			if (path) {
+				data.path = path;
+			}
 			return data;
 		},
 
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 1b2dd12213b..0091a9ee6e4 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -2521,6 +2521,12 @@ describe('OCA.Files.FileList tests', function() {
 			expect(fileInfo.size).toEqual(12);
 			expect(fileInfo.mimetype).toEqual('text/plain');
 			expect(fileInfo.type).toEqual('file');
+			expect(fileInfo.path).not.toBeDefined();
+		});
+		it('adds path attribute if available', function() {
+			$tr.attr('data-path', '/subdir');
+			var fileInfo = fileList.elementToFile($tr);
+			expect(fileInfo.path).toEqual('/subdir');
 		});
 	});
 	describe('new file menu', function() {
-- 
GitLab