Remove copy in file actions when not allowed

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
pull/33713/head
Vincent Petry 2 years ago
parent c1df72fc8b
commit d1317e7540
No known key found for this signature in database
GPG Key ID: E055D6A4D513575C

@ -673,6 +673,9 @@
displayName: function(context) {
var permissions = context.fileInfoModel.attributes.permissions;
if (permissions & OC.PERMISSION_UPDATE) {
if (!context.fileInfoModel.canDownload()) {
return t('files', 'Move');
}
return t('files', 'Move or copy');
}
return t('files', 'Copy');
@ -685,7 +688,11 @@
var permissions = context.fileInfoModel.attributes.permissions;
var actions = OC.dialogs.FILEPICKER_TYPE_COPY;
if (permissions & OC.PERMISSION_UPDATE) {
actions = OC.dialogs.FILEPICKER_TYPE_COPY_MOVE;
if (!context.fileInfoModel.canDownload()) {
actions = OC.dialogs.FILEPICKER_TYPE_MOVE;
} else {
actions = OC.dialogs.FILEPICKER_TYPE_COPY_MOVE;
}
}
var dialogDir = context.dir;
if (typeof context.fileList.dirInfo.dirLastCopiedTo !== 'undefined') {

@ -126,7 +126,18 @@
});
return deferred.promise();
}
},
canDownload: function() {
for (const i in this.attributes.shareAttributes) {
const attr = this.attributes.shareAttributes[i]
if (attr.scope === 'permissions' && attr.key === 'download') {
return attr.enabled
}
}
return true
},
});
if (!OCA.Files) {

@ -94,6 +94,10 @@ import { getCapabilities } from '@nextcloud/capabilities'
}
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))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save