Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: Keep download action for files and hide only for relevant files
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and Pytal committed May 22, 2024
commit c8003e480b2320c998d7c088eeeaac1a72fe2af2
14 changes: 14 additions & 0 deletions apps/files/js/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,13 @@
context.fileList.showFileBusyState(filename, true);
OCA.Files.Files.handleDownload(url, disableLoadingState);
}
},
shouldRender: function(context) {
var fileData = context.fileInfoModel
if (_.isFunction(fileData.canDownload) && !fileData.canDownload()) {
return false;
}
return true;
}
});

Expand Down Expand Up @@ -707,6 +714,13 @@
}
context.fileList.dirInfo.dirLastCopiedTo = targetPath;
}, false, "httpd/unix-directory", true, actions, dialogDir);
},
shouldRender: function(context) {
var fileData = context.fileInfoModel
if (_.isFunction(fileData.canDownload) && !fileData.canDownload()) {
return false;
}
return true;
}
});

Expand Down
6 changes: 6 additions & 0 deletions apps/files/js/fileactionsmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
var defaultAction = fileActions.getCurrentDefaultFileAction();

var items = _.filter(actions, function(actionSpec) {
if (actionSpec.shouldRender) {
if (!actionSpec.shouldRender(self._context)) {
return false;
}
}

return !defaultAction || actionSpec.name !== defaultAction.name;
});
items = _.map(items, function(item) {
Expand Down
13 changes: 0 additions & 13 deletions apps/files_sharing/src/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@ import { getCapabilities } from '@nextcloud/capabilities'
var tr = oldCreateRow.apply(this, arguments)
var sharePermissions = OCA.Sharing.Util.getSharePermissions(fileData)

if (fileData.permissions === 0) {
// no permission, disabling sidebar
delete fileActions.actions.all.Comment
delete fileActions.actions.all.Details
delete fileActions.actions.all.Goto
Comment on lines -91 to -93
Copy link
Member Author

@juliusknorr juliusknorr May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems already done with the permissions checks on the individual actions

}
if (_.isFunction(fileData.canDownload) && !fileData.canDownload()) {
delete fileActions.actions.all.Download
if ((fileData.permissions & OC.PERMISSION_UPDATE) === 0) {
// neither move nor copy is allowed, remove the action completely
delete fileActions.actions.all.MoveCopy
}
}
tr.attr('data-share-permissions', sharePermissions)
tr.attr('data-share-attributes', JSON.stringify(fileData.shareAttributes))
if (fileData.shareOwner) {
Expand Down