1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00

[AC-1139] Fixed CanDelete logic

This commit is contained in:
Rui Tome
2023-11-21 10:21:10 +00:00
parent 12a76a1818
commit 572e6e7ee2
3 changed files with 15 additions and 6 deletions

View File

@@ -109,10 +109,7 @@
{{ "cancel" | i18n }} {{ "cancel" | i18n }}
</button> </button>
<button <button
*ngIf=" *ngIf="canDelete$ | async"
editMode &&
((flexibleCollectionsEnabled$ | async) || organization?.canDeleteAssignedCollections)
"
type="button" type="button"
bitIconButton="bwi-trash" bitIconButton="bwi-trash"
buttonType="danger" buttonType="danger"

View File

@@ -316,6 +316,14 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
this.close(CollectionDialogAction.Deleted, this.collection); 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 { ngOnDestroy(): void {
this.destroy$.next(); this.destroy$.next();
this.destroy$.complete(); this.destroy$.complete();

View File

@@ -135,7 +135,9 @@ export class BulkDeleteDialogComponent {
// From org vault // From org vault
if (this.organization) { if (this.organization) {
if ( if (
(flexibleCollectionsEnabled || !this.organization.canDeleteAssignedCollections) && (flexibleCollectionsEnabled
? this.collections.some((c) => !c.canDelete)
: !this.organization.canDeleteAssignedCollections) &&
!this.organization.canDeleteAnyCollection !this.organization.canDeleteAnyCollection
) { ) {
this.platformUtilsService.showToast( this.platformUtilsService.showToast(
@@ -151,7 +153,9 @@ export class BulkDeleteDialogComponent {
const deletePromises: Promise<any>[] = []; const deletePromises: Promise<any>[] = [];
for (const organization of this.organizations) { for (const organization of this.organizations) {
if ( if (
(flexibleCollectionsEnabled || !this.organization.canDeleteAssignedCollections) && (flexibleCollectionsEnabled
? this.collections.some((c) => !c.canDelete)
: !this.organization.canDeleteAssignedCollections) &&
!organization.canDeleteAnyCollection !organization.canDeleteAnyCollection
) { ) {
this.platformUtilsService.showToast( this.platformUtilsService.showToast(