show e2e folder icon on encrypted folders

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
Bjoern Schiessle 2017-09-19 17:24:53 +02:00 committed by Daniel Calviño Sánchez
parent 37d8d3d858
commit 7bc28f14de
7 changed files with 46 additions and 2 deletions

View File

@ -1156,7 +1156,10 @@
if (type === 'dir') {
mime = mime || 'httpd/unix-directory';
if (fileData.mountType && fileData.mountType.indexOf('external') === 0) {
if (fileData.isEncrypted) {
icon = OC.MimeType.getIconUrl('dir-encrypted');
dataIcon = icon;
} else if (fileData.mountType && fileData.mountType.indexOf('external') === 0) {
icon = OC.MimeType.getIconUrl('dir-external');
dataIcon = icon;
}

View File

@ -1455,6 +1455,32 @@ describe('OCA.Files.FileList tests', function() {
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder.svg');
expect(previewLoadStub.notCalled).toEqual(true);
});
it('render encrypted folder icon for encrypted root', function() {
var fileData = {
type: 'dir',
mimetype: 'httpd/unix-directory',
name: 'test dir',
isEncrypted: true
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg');
expect(previewLoadStub.notCalled).toEqual(true);
});
it('render encrypted folder icon for encrypted subdir', function() {
var fileData = {
type: 'dir',
mimetype: 'httpd/unix-directory',
name: 'test dir',
isEncrypted: true
};
var $tr = fileList.add(fileData);
var $td = $tr.find('td.filename');
expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg');
expect(previewLoadStub.notCalled).toEqual(true);
// default icon override
expect($tr.attr('data-icon')).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg');
});
it('render external storage icon for external storage root', function() {
var fileData = {
type: 'dir',

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1"><path fill-rule="evenodd" fill="#0082c9" d="m1.4609 2c-0.25 0-0.4609 0.2109-0.4609 0.4609v11.078c0 0.258 0.2029 0.461 0.4609 0.461h13.078c0.258 0 0.461-0.203 0.461-0.461v-9.0761c0-0.25-0.211-0.4649-0.461-0.4649h-6.539l-2-1.998h-4.5391zm6.5391 3.8008c0.8836 0 1.5996 0.7159 1.5996 1.5996v0.7988h0.4004v2.8008h-4v-2.8008h0.4004v-0.7988c0-0.8837 0.716-1.5996 1.5996-1.5996zm0 0.7988c-0.4419 0-0.8008 0.3589-0.8008 0.8008v0.7988h1.6016v-0.7988c0-0.4419-0.3589-0.8008-0.8008-0.8008z"/></svg>

After

Width:  |  Height:  |  Size: 562 B

View File

@ -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) {

View File

@ -104,6 +104,7 @@ OC.MimeTypeList={
"file",
"folder",
"folder-drag-accept",
"folder-encrypted",
"folder-external",
"folder-public",
"folder-shared",

View File

@ -276,10 +276,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 {

View File

@ -149,6 +149,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() {