mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-21 21:11:35 +01:00
[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
This commit is contained in:
parent
609296ad2b
commit
6ba1cc96e1
@ -21,6 +21,7 @@ import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstraction
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
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 { CollectionResponse } from "@bitwarden/common/vault/models/response/collection.response";
|
||||||
import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view";
|
import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view";
|
||||||
import { BitValidators, DialogService } from "@bitwarden/components";
|
import { BitValidators, DialogService } from "@bitwarden/components";
|
||||||
@ -105,7 +106,8 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
private dialogRef: DialogRef<CollectionDialogResult>,
|
private dialogRef: DialogRef<CollectionDialogResult>,
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private groupService: GroupService,
|
private groupService: GroupService,
|
||||||
private collectionService: CollectionAdminService,
|
private collectionAdminService: CollectionAdminService,
|
||||||
|
private collectionService: CollectionService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private organizationUserService: OrganizationUserService,
|
private organizationUserService: OrganizationUserService,
|
||||||
@ -154,12 +156,15 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
combineLatest({
|
combineLatest({
|
||||||
organization: organization$,
|
organization: organization$,
|
||||||
collections: this.collectionService.getAll(orgId),
|
collections: this.collectionAdminService.getAll(orgId),
|
||||||
collectionDetails: this.params.collectionId
|
collectionDetails: this.params.collectionId
|
||||||
? from(this.collectionService.get(orgId, this.params.collectionId))
|
? from(this.collectionAdminService.get(orgId, this.params.collectionId))
|
||||||
: of(null),
|
: of(null),
|
||||||
groups: groups$,
|
groups: groups$,
|
||||||
users: this.organizationUserService.getAllUsers(orgId),
|
users: this.organizationUserService.getAllUsers(orgId),
|
||||||
|
collection: this.params.collectionId
|
||||||
|
? this.collectionService.get(this.params.collectionId)
|
||||||
|
: of(null),
|
||||||
flexibleCollections: this.flexibleCollectionsEnabled$,
|
flexibleCollections: this.flexibleCollectionsEnabled$,
|
||||||
flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$,
|
flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$,
|
||||||
})
|
})
|
||||||
@ -171,6 +176,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
collectionDetails,
|
collectionDetails,
|
||||||
groups,
|
groups,
|
||||||
users,
|
users,
|
||||||
|
collection,
|
||||||
flexibleCollections,
|
flexibleCollections,
|
||||||
flexibleCollectionsV1,
|
flexibleCollectionsV1,
|
||||||
}) => {
|
}) => {
|
||||||
@ -208,7 +214,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
access: accessSelections,
|
access: accessSelections,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.showDeleteButton = this.collection.canDelete(organization);
|
this.showDeleteButton = this.collection.canDelete(organization) || collection?.manage;
|
||||||
} else {
|
} else {
|
||||||
this.nestOptions = collections;
|
this.nestOptions = collections;
|
||||||
const parent = collections.find((c) => c.id === this.params.parentCollectionId);
|
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;
|
collectionView.name = this.formGroup.controls.name.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const savedCollection = await this.collectionService.save(collectionView);
|
const savedCollection = await this.collectionAdminService.save(collectionView);
|
||||||
|
|
||||||
this.platformUtilsService.showToast(
|
this.platformUtilsService.showToast(
|
||||||
"success",
|
"success",
|
||||||
@ -321,7 +327,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
return false;
|
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(
|
this.platformUtilsService.showToast(
|
||||||
"success",
|
"success",
|
||||||
|
Loading…
Reference in New Issue
Block a user