Skip to content

Commit

Permalink
Early return in batch action checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Jul 2, 2021
1 parent 353c86a commit 484c2d2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Batch action for deleting adhering permissions

We fixed that the batch actions for deleting files and folders was showing for shares that only have viewer permissions.

https://github.com/owncloud/web/pull/5441
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ export default {
return false
}
const insufficientPermissions = this.selectedFiles.some(resource => {
const moveDisabled = this.selectedFiles.some(resource => {
return canBeMoved(resource, this.currentFolder.path) === false
})
return insufficientPermissions === false
return !moveDisabled
},
canCopy() {
Expand All @@ -144,32 +143,32 @@ export default {
return this.currentFolder.canBeDeleted()
}
return true
const deleteDisabled = this.selectedFiles.some(resource => {
return !resource.canBeDeleted()
})
return !deleteDisabled
},
canAccept() {
if (!this.isSharedWithMeRoute) {
return false
}
let canAccept = true
this.selectedFiles.forEach(file => {
if (file.status === shareStatus.accepted) {
canAccept = false
}
})
return canAccept
const acceptDisabled = this.selectedFiles.some(resource => {
return resource.status === shareStatus.accepted
})
return !acceptDisabled
},
canDecline() {
if (!this.isSharedWithMeRoute) {
return false
}
let canDecline = true
this.selectedFiles.forEach(file => {
if (file.status === shareStatus.declined) canDecline = false
const declineDisabled = this.selectedFiles.some(resource => {
return resource.status === shareStatus.declined
})
return canDecline
return !declineDisabled
},
displayBulkActions() {
Expand All @@ -184,7 +183,7 @@ export default {
methods: {
...mapActions('Files', ['removeFilesFromTrashbin', 'resetFileSelection', 'setHighlightedFile']),
...mapActions(['showMessage']),
...mapMutations('Files', ['SELECT_RESOURCES', 'UPDATE_RESOURCE']),
...mapMutations('Files', ['UPDATE_RESOURCE']),
restoreFiles(resources = this.selectedFiles) {
for (const resource of resources) {
Expand Down Expand Up @@ -281,7 +280,7 @@ export default {
await Promise.all(triggerPromises)
if (errors.length === 0) {
this.SELECT_RESOURCES([])
this.resetFileSelection()
return
}
Expand Down
8 changes: 6 additions & 2 deletions packages/web-app-files/src/helpers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ export function buildSharedResource(share, incomingShares = false, allowSharePer
resource.extension = isFolder ? '' : _getFileExtension(resource.name)
// FIXME: add actual permission parsing
resource.canUpload = () => true
resource.canBeDeleted = () => true
resource.canRename = () => true
resource.canBeDeleted = () => {
return checkPermission(share.permissions, 'delete')
}
resource.canRename = () => {
return checkPermission(share.permissions, 'update')
}
resource.canShare = () => {
return checkPermission(share.permissions, 'share')
}
Expand Down

0 comments on commit 484c2d2

Please sign in to comment.