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>
This commit is contained in:
parent
555d582f35
commit
e6b74fac40
4 changed files with 17 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -60,6 +60,7 @@ function fileDownloadPath(dir, file) {
|
|||
/** @namespace */
|
||||
var OCP = {},
|
||||
OC = {
|
||||
PERMISSION_NONE:0,
|
||||
PERMISSION_CREATE:4,
|
||||
PERMISSION_READ:1,
|
||||
PERMISSION_UPDATE:2,
|
||||
|
|
Loading…
Reference in a new issue