From 6ba1cc96e1a52eefa2995c9034798c4428d3224e Mon Sep 17 00:00:00 2001 From: SmithThe4th Date: Tue, 23 Jan 2024 15:13:40 -0500 Subject: [PATCH] [AC-2003] Delete collection button is missing for users with Can Manage in individual vault (#7569) * Injected collection service to get manage permission of the current logged in user * resolved comment from Shane * fixed lint issue * lint fix --- .../collection-dialog.component.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.ts b/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.ts index 1224b322ff..5667884446 100644 --- a/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.ts +++ b/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.ts @@ -21,6 +21,7 @@ import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstraction import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; +import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service"; import { CollectionResponse } from "@bitwarden/common/vault/models/response/collection.response"; import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view"; import { BitValidators, DialogService } from "@bitwarden/components"; @@ -105,7 +106,8 @@ export class CollectionDialogComponent implements OnInit, OnDestroy { private dialogRef: DialogRef, private organizationService: OrganizationService, private groupService: GroupService, - private collectionService: CollectionAdminService, + private collectionAdminService: CollectionAdminService, + private collectionService: CollectionService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private organizationUserService: OrganizationUserService, @@ -154,12 +156,15 @@ export class CollectionDialogComponent implements OnInit, OnDestroy { ); combineLatest({ organization: organization$, - collections: this.collectionService.getAll(orgId), + collections: this.collectionAdminService.getAll(orgId), collectionDetails: this.params.collectionId - ? from(this.collectionService.get(orgId, this.params.collectionId)) + ? from(this.collectionAdminService.get(orgId, this.params.collectionId)) : of(null), groups: groups$, users: this.organizationUserService.getAllUsers(orgId), + collection: this.params.collectionId + ? this.collectionService.get(this.params.collectionId) + : of(null), flexibleCollections: this.flexibleCollectionsEnabled$, flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$, }) @@ -171,6 +176,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy { collectionDetails, groups, users, + collection, flexibleCollections, flexibleCollectionsV1, }) => { @@ -208,7 +214,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy { access: accessSelections, }); - this.showDeleteButton = this.collection.canDelete(organization); + this.showDeleteButton = this.collection.canDelete(organization) || collection?.manage; } else { this.nestOptions = collections; const parent = collections.find((c) => c.id === this.params.parentCollectionId); @@ -296,7 +302,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy { collectionView.name = this.formGroup.controls.name.value; } - const savedCollection = await this.collectionService.save(collectionView); + const savedCollection = await this.collectionAdminService.save(collectionView); this.platformUtilsService.showToast( "success", @@ -321,7 +327,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy { return false; } - await this.collectionService.delete(this.params.organizationId, this.params.collectionId); + await this.collectionAdminService.delete(this.params.organizationId, this.params.collectionId); this.platformUtilsService.showToast( "success",