mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-10 09:59:48 +01:00
bulk access menu options based on permissions for delete
This commit is contained in:
parent
394ccbd730
commit
fcac2315a6
@ -105,6 +105,8 @@ export class VaultCollectionRowComponent {
|
||||
}
|
||||
|
||||
protected get showCheckbox() {
|
||||
// if Admin/Owner only show checkbox for collections they have Can Manage
|
||||
// if Custom user with Delete all permissions, show checkbox for all collections
|
||||
return (
|
||||
this.collection?.id !== Unassigned &&
|
||||
(this.collection?.canEdit(this.organization) || this.collection?.canDelete(this.organization))
|
||||
|
@ -27,13 +27,14 @@
|
||||
</th>
|
||||
<th bitCell class="tw-w-12 tw-text-right">
|
||||
<button
|
||||
[disabled]="disabled || isEmpty || disableMenu"
|
||||
[disabled]="disabled || isEmpty || disableMenu || selection.selected.length < 1"
|
||||
[bitMenuTriggerFor]="headerMenu"
|
||||
[attr.title]="disableMenu ? ('missingPermissions' | i18n) : ''"
|
||||
bitIconButton="bwi-ellipsis-v"
|
||||
size="small"
|
||||
type="button"
|
||||
appA11yTitle="{{ 'options' | i18n }}"
|
||||
appA11yTitle="{{
|
||||
(selection.selected.length < 1 ? 'nothingSelected' : 'options') | i18n
|
||||
}}"
|
||||
></button>
|
||||
<bit-menu #headerMenu>
|
||||
<button *ngIf="bulkMoveAllowed" type="button" bitMenuItem (click)="bulkMoveToFolder()">
|
||||
@ -41,7 +42,7 @@
|
||||
{{ (vaultBulkManagementActionEnabled ? "addToFolder" : "moveSelected") | i18n }}
|
||||
</button>
|
||||
<button
|
||||
*ngIf="showAdminActions && showBulkEditCollectionAccess && canEditSelected"
|
||||
*ngIf="canEditSelected && showAdminActions && showBulkEditCollectionAccess"
|
||||
type="button"
|
||||
bitMenuItem
|
||||
(click)="bulkEditCollectionAccess()"
|
||||
@ -74,7 +75,7 @@
|
||||
{{ "restoreSelected" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
*ngIf="deleteAllowed || showBulkTrashOptions"
|
||||
*ngIf="(canDeleteSelected && deleteAllowed) || showBulkTrashOptions"
|
||||
type="button"
|
||||
bitMenuItem
|
||||
(click)="bulkDelete()"
|
||||
|
@ -73,11 +73,32 @@ export class VaultItemsComponent {
|
||||
protected dataSource = new TableDataSource<VaultItem>();
|
||||
protected selection = new SelectionModel<VaultItem>(true, [], true);
|
||||
|
||||
// Only show Edit Access from Bulk Menu if all selected collections can be managed
|
||||
// Or Custom User with Edit All permissions
|
||||
get canEditSelected() {
|
||||
const selectedItemsNoManagePerm = this.selection.selected.filter(
|
||||
(item) => !item.collection.manage,
|
||||
);
|
||||
if (selectedItemsNoManagePerm.length > 0) {
|
||||
const filteredSelectedItems = this.selection.selected.filter((item) => {
|
||||
const organization = this.allOrganizations.find(
|
||||
(o) => o.id === item.collection.organizationId,
|
||||
);
|
||||
return !item.collection.canEdit(organization);
|
||||
});
|
||||
if (filteredSelectedItems.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only show Delete from Bulk Menu if all selected collections can be managed
|
||||
// Or Custom User with Delete All permissions
|
||||
get canDeleteSelected() {
|
||||
const filteredSelectedItems = this.selection.selected.filter((item) => {
|
||||
const organization = this.allOrganizations.find(
|
||||
(o) => o.id === item.collection.organizationId,
|
||||
);
|
||||
return item.collection.canEdit(organization) && !item.collection.canDelete(organization);
|
||||
});
|
||||
|
||||
if (filteredSelectedItems.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user