1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 14:23:32 +00:00

[PM-12770] Assign to Collections Hint (#14529)

* allow use of common spec in lib/vault tests

* pass readonly collections to the assign collection component

- The assign to collections component filters them out already.
-They're also needed to display copy within the component

* add hint to assign to collections component when there are read only collections assigned to a cipher already

* add readonly hint to desktop

* only show collection hint for collections that are assigned to the provided ciphers

* consider admin/owner edit everything permission when assigning to collections

* fix icon in test
This commit is contained in:
Nick Krantz
2025-05-22 11:09:33 -05:00
committed by GitHub
parent 9417d8a943
commit f52e4e27a0
8 changed files with 165 additions and 8 deletions

View File

@@ -126,6 +126,12 @@ export class AssignCollectionsComponent implements OnInit, OnDestroy, AfterViewI
collections: [<SelectItemView[]>[], [Validators.required]],
});
/**
* Collections that are already assigned to the cipher and are read-only. These cannot be removed.
* @protected
*/
protected readOnlyCollectionNames: string[] = [];
protected totalItemCount: number;
protected editableItemCount: number;
protected readonlyItemCount: number;
@@ -301,6 +307,8 @@ export class AssignCollectionsComponent implements OnInit, OnDestroy, AfterViewI
this.organizationService.organizations$(userId).pipe(getOrganizationById(organizationId)),
);
await this.setReadOnlyCollectionNames();
this.availableCollections = this.params.availableCollections
.filter((collection) => {
return collection.canEditItems(org);
@@ -503,4 +511,25 @@ export class AssignCollectionsComponent implements OnInit, OnDestroy, AfterViewI
await this.cipherService.saveCollectionsWithServer(cipher, userId);
}
}
/**
* Only display collections that are read-only and are assigned to the ciphers.
*/
private async setReadOnlyCollectionNames() {
const { availableCollections, ciphers } = this.params;
const organization = await firstValueFrom(
this.organizations$.pipe(map((orgs) => orgs.find((o) => o.id === this.selectedOrgId))),
);
this.readOnlyCollectionNames = availableCollections
.filter((c) => {
return (
c.readOnly &&
ciphers.some((cipher) => cipher.collectionIds.includes(c.id)) &&
!c.canEditItems(organization)
);
})
.map((c) => c.name);
}
}