Merge pull request #45344 from nextcloud/fix/stable27-download-action

[stable27] fix: Keep download action for files and hide only for relevant files
This commit is contained in:
Andy Scherzinger 2024-05-23 11:12:25 +02:00 committed by GitHub
commit b127e020ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 28 additions and 20 deletions

View file

@ -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;
}
});
@ -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;
}
});

View file

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

View file

@ -390,7 +390,8 @@
icon: OC.MimeType.getIconUrl(share.mimetype),
mimetype: share.mimetype,
hasPreview: share.has_preview,
tags: share.tags || []
tags: share.tags || [],
shareAttributes: JSON.parse(share.attributes),
}
if (share.item_type === 'folder') {
file.type = 'dir'

View file

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long