mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
[AC-1139] Fixed CanDelete logic
This commit is contained in:
@@ -109,10 +109,7 @@
|
||||
{{ "cancel" | i18n }}
|
||||
</button>
|
||||
<button
|
||||
*ngIf="
|
||||
editMode &&
|
||||
((flexibleCollectionsEnabled$ | async) || organization?.canDeleteAssignedCollections)
|
||||
"
|
||||
*ngIf="canDelete$ | async"
|
||||
type="button"
|
||||
bitIconButton="bwi-trash"
|
||||
buttonType="danger"
|
||||
|
||||
@@ -316,6 +316,14 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
this.close(CollectionDialogAction.Deleted, this.collection);
|
||||
};
|
||||
|
||||
protected canDelete$ = this.flexibleCollectionsEnabled$.pipe(
|
||||
switchMap(async (flexibleCollectionsEnabled) => {
|
||||
return (
|
||||
this.editMode && this.collection?.canDelete(this.organization!, flexibleCollectionsEnabled)
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
|
||||
@@ -135,7 +135,9 @@ export class BulkDeleteDialogComponent {
|
||||
// From org vault
|
||||
if (this.organization) {
|
||||
if (
|
||||
(flexibleCollectionsEnabled || !this.organization.canDeleteAssignedCollections) &&
|
||||
(flexibleCollectionsEnabled
|
||||
? this.collections.some((c) => !c.canDelete)
|
||||
: !this.organization.canDeleteAssignedCollections) &&
|
||||
!this.organization.canDeleteAnyCollection
|
||||
) {
|
||||
this.platformUtilsService.showToast(
|
||||
@@ -151,7 +153,9 @@ export class BulkDeleteDialogComponent {
|
||||
const deletePromises: Promise<any>[] = [];
|
||||
for (const organization of this.organizations) {
|
||||
if (
|
||||
(flexibleCollectionsEnabled || !this.organization.canDeleteAssignedCollections) &&
|
||||
(flexibleCollectionsEnabled
|
||||
? this.collections.some((c) => !c.canDelete)
|
||||
: !this.organization.canDeleteAssignedCollections) &&
|
||||
!organization.canDeleteAnyCollection
|
||||
) {
|
||||
this.platformUtilsService.showToast(
|
||||
|
||||
Reference in New Issue
Block a user