1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-10 09:59:48 +01:00

added logic around bulk access menu assign to collections. extra logic for the Edit and Delete as well for sub collections and items

This commit is contained in:
jng 2024-09-19 20:51:37 -04:00
parent fcac2315a6
commit f1b4783ab8
No known key found for this signature in database
GPG Key ID: AF822623CAD19C85
2 changed files with 38 additions and 9 deletions

View File

@ -52,7 +52,9 @@
</button>
<button
*ngIf="
(showAdminActions || showAssignToCollections()) && bulkAssignToCollectionsAllowed
canAssignSelected &&
(showAdminActions || showAssignToCollections()) &&
bulkAssignToCollectionsAllowed
"
type="button"
bitMenuItem

View File

@ -74,13 +74,18 @@ export class VaultItemsComponent {
protected selection = new SelectionModel<VaultItem>(true, [], true);
// Only show Edit Access from Bulk Menu if all selected collections can be managed
// And no items selected
// Or Custom User with Edit All permissions
get canEditSelected() {
const filteredSelectedItems = this.selection.selected.filter((item) => {
if (item.collection) {
const organization = this.allOrganizations.find(
(o) => o.id === item.collection.organizationId,
);
return !item.collection.canEdit(organization);
} else if (item.cipher) {
return true;
}
});
if (filteredSelectedItems.length > 0) {
return false;
@ -92,10 +97,32 @@ export class VaultItemsComponent {
// Or Custom User with Delete All permissions
get canDeleteSelected() {
const filteredSelectedItems = this.selection.selected.filter((item) => {
if (item.collection) {
const organization = this.allOrganizations.find(
(o) => o.id === item.collection.organizationId,
);
return item.collection.canEdit(organization) && !item.collection.canDelete(organization);
return item.collection?.canEdit(organization) && !item.collection?.canDelete(organization);
} else if (item.cipher) {
return !item.cipher.edit;
}
});
if (filteredSelectedItems.length > 0) {
return false;
}
return true;
}
// Only show Assign To Collections from Bulk Menu if all selected items can be managed
// And no collections selected
// Or Custom User with Delete All permissions
get canAssignSelected() {
const filteredSelectedItems = this.selection.selected.filter((item) => {
if (item.collection) {
return true;
} else if (item.cipher) {
return !item.cipher.edit;
}
});
if (filteredSelectedItems.length > 0) {