Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/files/js/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
if (this.actions.all) {
actions = $.extend(actions, this.actions.all);
}
if (mime !== 'httpd/unix-directory' && this.actions.files) {
actions = $.extend(actions, this.actions.files);
}
if (type) {//type is 'dir' or 'file'
if (this.actions[type]) {
actions = $.extend(actions, this.actions[type]);
Expand Down Expand Up @@ -311,6 +314,8 @@
name = this.defaults[mimePart];
} else if (type && this.defaults[type]) {
name = this.defaults[type];
} else if (mime !== 'httpd/unix-directory' && this.defaults.files) {
name = this.defaults.files;
} else {
name = this.defaults.all;
}
Expand Down Expand Up @@ -719,7 +724,7 @@
return t('files', 'Edit locally');
}
},
mime: 'all',
mime: 'files',
order: -23,
icon: function(filename, context) {
var locked = context.$file.data('locked');
Expand Down
27 changes: 27 additions & 0 deletions apps/files/tests/js/fileactionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,33 @@ describe('OCA.Files.FileActions tests', function() {
expect($tr.find('.action.action-match').length).toEqual(1);
expect($tr.find('.action.action-nomatch').length).toEqual(0);
});
it('only renders file specific actions for files', function() {
var folderData = {
id: 19,
type: 'folder',
name: 'testfolder',
mimetype: 'httpd/unix-directory',
size: '1234',
etag: 'a01234c',
mtime: '123456',
permissions: OC.PERMISSION_READ | OC.PERMISSION_UPDATE
};

var $folder = fileList.add(folderData);

fileActions.registerAction({
name: 'filesonly',
displayName: 'MatchDisplay',
type: OCA.Files.FileActions.TYPE_INLINE,
mime: 'files',
permissions: OC.PERMISSION_READ
});

fileActions.display($tr.find('td.filename'), true, fileList);
fileActions.display($folder.find('td.filename'), true, fileList);
expect($tr.find('.action.action-filesonly').length).toEqual(1);
expect($folder.find('.action.action-filesonly').length).toEqual(0);
});
it('only renders actions relevant to the permissions', function() {
fileActions.registerAction({
name: 'Match',
Expand Down