mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-21 03:11:27 +02: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:
parent
fcac2315a6
commit
f1b4783ab8
@ -52,7 +52,9 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
*ngIf="
|
*ngIf="
|
||||||
(showAdminActions || showAssignToCollections()) && bulkAssignToCollectionsAllowed
|
canAssignSelected &&
|
||||||
|
(showAdminActions || showAssignToCollections()) &&
|
||||||
|
bulkAssignToCollectionsAllowed
|
||||||
"
|
"
|
||||||
type="button"
|
type="button"
|
||||||
bitMenuItem
|
bitMenuItem
|
||||||
|
@ -74,13 +74,18 @@ export class VaultItemsComponent {
|
|||||||
protected selection = new SelectionModel<VaultItem>(true, [], true);
|
protected selection = new SelectionModel<VaultItem>(true, [], true);
|
||||||
|
|
||||||
// Only show Edit Access from Bulk Menu if all selected collections can be managed
|
// 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
|
// Or Custom User with Edit All permissions
|
||||||
get canEditSelected() {
|
get canEditSelected() {
|
||||||
const filteredSelectedItems = this.selection.selected.filter((item) => {
|
const filteredSelectedItems = this.selection.selected.filter((item) => {
|
||||||
const organization = this.allOrganizations.find(
|
if (item.collection) {
|
||||||
(o) => o.id === item.collection.organizationId,
|
const organization = this.allOrganizations.find(
|
||||||
);
|
(o) => o.id === item.collection.organizationId,
|
||||||
return !item.collection.canEdit(organization);
|
);
|
||||||
|
return !item.collection.canEdit(organization);
|
||||||
|
} else if (item.cipher) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (filteredSelectedItems.length > 0) {
|
if (filteredSelectedItems.length > 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -92,10 +97,32 @@ export class VaultItemsComponent {
|
|||||||
// Or Custom User with Delete All permissions
|
// Or Custom User with Delete All permissions
|
||||||
get canDeleteSelected() {
|
get canDeleteSelected() {
|
||||||
const filteredSelectedItems = this.selection.selected.filter((item) => {
|
const filteredSelectedItems = this.selection.selected.filter((item) => {
|
||||||
const organization = this.allOrganizations.find(
|
if (item.collection) {
|
||||||
(o) => o.id === item.collection.organizationId,
|
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) {
|
if (filteredSelectedItems.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user