[AC-2523] Fix broken members dialog for Manage Users custom permission (#8968)

* Let Manage Users permission edit collection access

* Remove unused comment
This commit is contained in:
Thomas Rittson 2024-04-30 02:49:10 +10:00 committed by GitHub
parent 6365dcdc43
commit bb0a65f6d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -619,7 +619,7 @@ export class MemberDialogComponent implements OnDestroy {
}
function mapCollectionToAccessItemView(
collection: CollectionView,
collection: CollectionAdminView,
organization: Organization,
flexibleCollectionsV1Enabled: boolean,
accessSelection?: CollectionAccessSelectionView,
@ -631,7 +631,8 @@ function mapCollectionToAccessItemView(
labelName: collection.name,
listName: collection.name,
readonly:
group !== undefined || !collection.canEdit(organization, flexibleCollectionsV1Enabled),
group !== undefined ||
!collection.canEditUserAccess(organization, flexibleCollectionsV1Enabled),
readonlyPermission: accessSelection ? convertToPermission(accessSelection) : undefined,
viaGroupName: group?.name,
};

View File

@ -31,6 +31,9 @@ export class CollectionAdminView extends CollectionView {
this.assigned = response.assigned;
}
/**
* Whether the current user can edit the collection, including user and group access
*/
override canEdit(org: Organization, flexibleCollectionsV1Enabled: boolean): boolean {
return org?.flexibleCollections
? org?.canEditAnyCollection(flexibleCollectionsV1Enabled) || this.manage
@ -43,4 +46,11 @@ export class CollectionAdminView extends CollectionView {
? org?.canDeleteAnyCollection || (!org?.limitCollectionCreationDeletion && this.manage)
: org?.canDeleteAnyCollection || (org?.canDeleteAssignedCollections && this.assigned);
}
/**
* Whether the user can modify user access to this collection
*/
canEditUserAccess(org: Organization, flexibleCollectionsV1Enabled: boolean): boolean {
return this.canEdit(org, flexibleCollectionsV1Enabled) || org.canManageUsers;
}
}