diff options
author | Tobias Kaminsky <tobiasKaminsky@users.noreply.github.com> | 2017-12-06 16:19:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 16:19:17 +0100 |
commit | 430f60db21bbda895825bdb37632b5d68dff1f6e (patch) | |
tree | cf1fac2ea8bbbfaeeaf17a575657a7bbb7777e5b /core/js | |
parent | c32cb6b4b79baeb86f5702d20db0d4b6ed874d86 (diff) | |
parent | 7bc28f14de8c3d77ec611a4ffd8ad48dc6093cea (diff) | |
download | nextcloud-server-430f60db21bbda895825bdb37632b5d68dff1f6e.tar.gz nextcloud-server-430f60db21bbda895825bdb37632b5d68dff1f6e.zip |
Merge pull request #6670 from nextcloud/handle-encryption-state-in-web-interface
Handle encryption state in web interface
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/files/client.js | 12 | ||||
-rw-r--r-- | core/js/mimetype.js | 2 | ||||
-rw-r--r-- | core/js/mimetypelist.js | 1 | ||||
-rw-r--r-- | core/js/share.js | 6 | ||||
-rw-r--r-- | core/js/tests/specs/files/clientSpec.js | 13 | ||||
-rw-r--r-- | core/js/tests/specs/shareSpec.js | 7 |
6 files changed, 38 insertions, 3 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js index fa3d795d412..dc842a9d3bf 100644 --- a/core/js/files/client.js +++ b/core/js/files/client.js @@ -74,6 +74,7 @@ Client.PROPERTY_PERMISSIONS = '{' + Client.NS_OWNCLOUD + '}permissions'; Client.PROPERTY_SIZE = '{' + Client.NS_OWNCLOUD + '}size'; Client.PROPERTY_GETCONTENTLENGTH = '{' + Client.NS_DAV + '}getcontentlength'; + Client.PROPERTY_ISENCRYPTED = '{' + Client.NS_DAV + '}is-encrypted'; Client.PROTOCOL_HTTP = 'http'; Client.PROTOCOL_HTTPS = 'https'; @@ -120,6 +121,10 @@ * Mount type */ [Client.NS_NEXTCLOUD, 'mount-type'], + /** + * Encryption state + */ + [Client.NS_NEXTCLOUD, 'is-encrypted'], ]; /** @@ -305,6 +310,13 @@ data.hasPreview = true; } + var isEncryptedProp = props['{' + Client.NS_NEXTCLOUD + '}is-encrypted']; + if (!_.isUndefined(isEncryptedProp)) { + data.isEncrypted = isEncryptedProp === '1'; + } else { + data.isEncrypted = false; + } + var contentType = props[Client.PROPERTY_GETCONTENTTYPE]; if (!_.isUndefined(contentType)) { data.mimetype = contentType; diff --git a/core/js/mimetype.js b/core/js/mimetype.js index ed4fedc7f8a..e5a07abc951 100644 --- a/core/js/mimetype.js +++ b/core/js/mimetype.js @@ -44,6 +44,8 @@ OC.MimeType = { // Generate path if (mimeType === 'dir' && $.inArray('folder', files) !== -1) { return 'folder'; + } else if (mimeType === 'dir-encrypted' && $.inArray('folder-encrypted', files) !== -1) { + return 'folder-encrypted'; } else if (mimeType === 'dir-shared' && $.inArray('folder-shared', files) !== -1) { return 'folder-shared'; } else if (mimeType === 'dir-public' && $.inArray('folder-public', files) !== -1) { diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index ea513131d88..13db16c5a21 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -104,6 +104,7 @@ OC.MimeTypeList={ "file", "folder", "folder-drag-accept", + "folder-encrypted", "folder-external", "folder-public", "folder-shared", diff --git a/core/js/share.js b/core/js/share.js index 7662d6cffb9..f301de25415 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -281,10 +281,14 @@ OC.Share = _.extend(OC.Share || {}, { $tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')'); $tr.attr('data-icon', shareFolderIcon); } else if (type === 'dir') { + var isEncrypted = $tr.attr('data-e2eencrypted'); var mountType = $tr.attr('data-mounttype'); // FIXME: duplicate of FileList._createRow logic for external folder, // need to refactor the icon logic into a single code path eventually - if (mountType && mountType.indexOf('external') === 0) { + if (isEncrypted === 'true') { + shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted'); + $tr.attr('data-icon', shareFolderIcon); + } else if (mountType && mountType.indexOf('external') === 0) { shareFolderIcon = OC.MimeType.getIconUrl('dir-external'); $tr.attr('data-icon', shareFolderIcon); } else { diff --git a/core/js/tests/specs/files/clientSpec.js b/core/js/tests/specs/files/clientSpec.js index 6593372144a..ec0a0fbda40 100644 --- a/core/js/tests/specs/files/clientSpec.js +++ b/core/js/tests/specs/files/clientSpec.js @@ -224,6 +224,7 @@ describe('OC.Files.Client tests', function() { expect(props).toContain('{http://owncloud.org/ns}fileid'); expect(props).toContain('{http://owncloud.org/ns}size'); expect(props).toContain('{http://owncloud.org/ns}permissions'); + expect(props).toContain('{http://nextcloud.org/ns}is-encrypted'); }); it('sends PROPFIND to base url when empty path given', function() { client.getFolderContents(''); @@ -262,6 +263,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436535485000); expect(info.mimetype).toEqual('text/plain'); expect(info.etag).toEqual('559fcabd79a38'); + expect(info.isEncrypted).toEqual(false); // sub entry info = response[1]; @@ -274,6 +276,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436536800000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('66cfcabd79abb'); + expect(info.isEncrypted).toEqual(false); }); }); it('returns parent node in result if specified', function() { @@ -303,6 +306,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436522405000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('56cfcabd79abb'); + expect(info.isEncrypted).toEqual(false); // the two other entries follow expect(response[1].id).toEqual(51); @@ -422,6 +426,7 @@ describe('OC.Files.Client tests', function() { expect(props).toContain('{http://owncloud.org/ns}fileid'); expect(props).toContain('{http://owncloud.org/ns}size'); expect(props).toContain('{http://owncloud.org/ns}permissions'); + expect(props).toContain('{http://nextcloud.org/ns}is-encrypted'); }); it('parses the result list into a FileInfo array', function() { var promise = client.getFilteredFiles({ @@ -473,7 +478,7 @@ describe('OC.Files.Client tests', function() { describe('file info', function() { var responseXml = dav.Client.prototype.parseMultiStatus( '<?xml version="1.0" encoding="utf-8"?>' + - '<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">' + + '<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">' + makeResponseBlock( '/owncloud/remote.php/webdav/path/to%20space/%E6%96%87%E4%BB%B6%E5%A4%B9/', { @@ -483,7 +488,8 @@ describe('OC.Files.Client tests', function() { 'oc:id': '00000011oc2d13a6a068', 'oc:fileid': '11', 'oc:permissions': 'GRDNVCK', - 'oc:size': '120' + 'oc:size': '120', + 'nc:is-encrypted': '1' }, [ 'd:getcontenttype', @@ -510,6 +516,7 @@ describe('OC.Files.Client tests', function() { expect(props).toContain('{http://owncloud.org/ns}fileid'); expect(props).toContain('{http://owncloud.org/ns}size'); expect(props).toContain('{http://owncloud.org/ns}permissions'); + expect(props).toContain('{http://nextcloud.org/ns}is-encrypted'); }); it('parses the result into a FileInfo', function() { var promise = client.getFileInfo('path/to space/文件夹'); @@ -535,6 +542,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436522405000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('56cfcabd79abb'); + expect(info.isEncrypted).toEqual(true); }); }); it('properly parses entry inside root', function() { @@ -583,6 +591,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436522405000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('56cfcabd79abb'); + expect(info.isEncrypted).toEqual(false); }); }); it('rejects promise when an error occurred', function() { diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js index 05057692e98..2006f29bc01 100644 --- a/core/js/tests/specs/shareSpec.js +++ b/core/js/tests/specs/shareSpec.js @@ -151,6 +151,13 @@ describe('OC.Share tests', function() { checkIcon('filetypes/folder-external'); }); + it('shows encrypted icon if encrypted folder', function() { + $file.attr('data-type', 'dir'); + $file.attr('data-e2eencrypted', true); + OC.Share.markFileAsShared($file, false, false); + + checkIcon('filetypes/folder-encrypted'); + }); }); describe('displaying the recipients', function() { |