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

[AC-2161] update cipher collections org vault modal (#8027)

* collections component shows disable readOnly collections in the org vault edit collections modal, and will check if org allows Owners up manage all collections in ciphers
This commit is contained in:
Jason Ng
2024-03-21 11:54:31 -04:00
committed by GitHub
parent cd5dc09d25
commit 8fd76eaf9c
9 changed files with 123 additions and 14 deletions

View File

@@ -68,6 +68,7 @@ describe("Collection", () => {
organizationId: "orgId",
readOnly: false,
manage: true,
assigned: true,
});
});
});

View File

@@ -17,6 +17,7 @@ export class CollectionView implements View, ITreeNodeObject {
readOnly: boolean = null;
hidePasswords: boolean = null;
manage: boolean = null;
assigned: boolean = null;
constructor(c?: Collection | CollectionAccessDetailsResponse) {
if (!c) {
@@ -30,7 +31,29 @@ export class CollectionView implements View, ITreeNodeObject {
this.readOnly = c.readOnly;
this.hidePasswords = c.hidePasswords;
this.manage = c.manage;
this.assigned = true;
}
if (c instanceof CollectionAccessDetailsResponse) {
this.assigned = c.assigned;
}
}
canEditItems(org: Organization, v1FlexibleCollections: boolean): boolean {
if (org != null && org.id !== this.organizationId) {
throw new Error(
"Id of the organization provided does not match the org id of the collection.",
);
}
if (org?.flexibleCollections) {
return (
org?.canEditAllCiphers(v1FlexibleCollections) ||
this.manage ||
(this.assigned && !this.readOnly)
);
}
return org?.canEditAnyCollection || (org?.canEditAssignedCollections && this.assigned);
}
// For editing collection details, not the items within it.