summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-11-02 14:55:58 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-11-02 19:37:00 +0100
commite6b74fac407b62168633be75312074e8ae0e2175 (patch)
treee573846ca7e0df0e7df6bd1b123f88ef6c0bdd65 /apps
parent555d582f35d1704996c3bf72510a8272cc38f833 (diff)
downloadnextcloud-server-e6b74fac407b62168633be75312074e8ae0e2175.tar.gz
nextcloud-server-e6b74fac407b62168633be75312074e8ae0e2175.zip
Add proper handling of files without permissions
Now a file gets its directory permissions only if it contained no permissions (they were undefined or null), but not if its permissions were set to "NONE". Besides that, now file actions that do not require any permission on the file to be performed can be used on files that have no permissions. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/fileactions.js2
-rw-r--r--apps/files/js/filelist.js7
-rw-r--r--apps/files/tests/js/filelistSpec.js9
3 files changed, 16 insertions, 2 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 0f320c8b3c7..6c031ab06d5 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -235,7 +235,7 @@
}
var filteredActions = {};
$.each(actions, function (name, action) {
- if (action.permissions & permissions) {
+ if ((action.permissions === OC.PERMISSION_NONE) || (action.permissions & permissions)) {
filteredActions[name] = action;
}
});
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 4790afcf4d0..c19f517e422 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1159,6 +1159,11 @@
}
}
+ var permissions = fileData.permissions;
+ if (permissions === undefined || permissions === null) {
+ permissions = this.getDirectoryPermissions();
+ }
+
//containing tr
var tr = $('<tr></tr>').attr({
"data-id" : fileData.id,
@@ -1168,7 +1173,7 @@
"data-mime": mime,
"data-mtime": mtime,
"data-etag": fileData.etag,
- "data-permissions": fileData.permissions || this.getDirectoryPermissions(),
+ "data-permissions": permissions,
"data-has-preview": fileData.hasPreview !== false
});
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 8bb188e3602..8a3e8cb9d4b 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -296,6 +296,15 @@ describe('OCA.Files.FileList tests', function() {
expect($tr.find('.filesize').text()).toEqual('Pending');
expect($tr.find('.date').text()).not.toEqual('?');
});
+ it('generates file element with no permissions when permissions are explicitly none', function() {
+ var fileData = {
+ type: 'dir',
+ name: 'testFolder',
+ permissions: OC.PERMISSION_NONE
+ };
+ var $tr = fileList.add(fileData);
+ expect($tr.attr('data-permissions')).toEqual('0');
+ });
it('generates file element with zero size when size is explicitly zero', function() {
var fileData = {
type: 'dir',