Skip to content

Commit

Permalink
[PM-10483] Fix collection manage check for delete permission (#4313)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintPatrck authored Nov 18, 2024
1 parent 30eb11b commit e90bd13
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ fun String.toCollectionDisplayName(list: List<CollectionView>): String {
*
* Deletion is allowed when the item is in any collection that the user has "manage" permission for.
*/
fun List<CollectionView>?.hasDeletePermissionInAtLeastOneCollection(collectionIds: List<String>?) =
this
?.takeUnless { it.isEmpty() }
?.any {
fun List<CollectionView>?.hasDeletePermissionInAtLeastOneCollection(
collectionIds: List<String>?,
): Boolean {
if (this.isNullOrEmpty() || collectionIds.isNullOrEmpty()) return true
return this
.any { collectionView ->
collectionIds
?.contains(it.id)
?.let { isInCollection -> !isInCollection || it.manage }
?: true
.contains(collectionView.id)
.let { isInCollection -> isInCollection && collectionView.manage }
}
?: true
}

/**
* Checks if the user has permission to assign an item to a collection.
Expand Down

0 comments on commit e90bd13

Please sign in to comment.