diff --git a/libs/vault/src/cipher-form/components/item-details/item-details-section.component.spec.ts b/libs/vault/src/cipher-form/components/item-details/item-details-section.component.spec.ts index 93229bda6c3..32c1e7417e4 100644 --- a/libs/vault/src/cipher-form/components/item-details/item-details-section.component.spec.ts +++ b/libs/vault/src/cipher-form/components/item-details/item-details-section.component.spec.ts @@ -91,7 +91,8 @@ describe("ItemDetailsSectionComponent", () => { id: "col1", name: "Collection 1", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, ]; component.originalCipherView = { @@ -125,13 +126,15 @@ describe("ItemDetailsSectionComponent", () => { id: "col1", name: "Collection 1", organizationId: "org1", - canEditItems: (_org) => false, + assigned: true, + readOnly: true, } as CollectionView, { id: "col2", name: "Collection 2", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, ]; component.originalCipherView = { @@ -386,19 +389,22 @@ describe("ItemDetailsSectionComponent", () => { id: "col1", name: "Collection 1", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, { id: "col2", name: "Collection 2", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, { id: "col3", name: "Collection 3", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, ]; @@ -421,7 +427,8 @@ describe("ItemDetailsSectionComponent", () => { id: "col1", name: "Collection 1", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, ]; @@ -453,20 +460,22 @@ describe("ItemDetailsSectionComponent", () => { id: "col1", name: "Collection 1", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, { id: "col2", name: "Collection 2", organizationId: "org1", - canEditItems: (_org) => true, + assigned: true, + readOnly: false, } as CollectionView, { id: "col3", name: "Collection 3", organizationId: "org1", readOnly: true, - canEditItems: (_org) => true, + assigned: true, } as CollectionView, ]; @@ -490,21 +499,21 @@ describe("ItemDetailsSectionComponent", () => { name: "Collection 1", organizationId: "org1", readOnly: true, - canEditItems: (_org) => false, + assigned: false, } as CollectionView, { id: "col2", name: "Collection 2", organizationId: "org1", readOnly: true, - canEditItems: (_org) => false, + assigned: false, } as CollectionView, { id: "col3", name: "Collection 3", organizationId: "org1", readOnly: false, - canEditItems: (_org) => false, + assigned: true, } as CollectionView, ]; @@ -527,20 +536,20 @@ describe("ItemDetailsSectionComponent", () => { name: "Collection 1", organizationId: "org1", readOnly: true, - canEditItems: (_org) => false, + assigned: false, } as CollectionView, { id: "col2", name: "Collection 2", organizationId: "org1", - canEditItems: (_org) => false, + assigned: false, } as CollectionView, { id: "col3", name: "Collection 3", organizationId: "org1", readOnly: true, - canEditItems: (_org) => false, + assigned: false, } as CollectionView, ]; component.originalCipherView = { diff --git a/libs/vault/src/cipher-form/components/item-details/item-details-section.component.ts b/libs/vault/src/cipher-form/components/item-details/item-details-section.component.ts index b068b85c93d..f7fd228232e 100644 --- a/libs/vault/src/cipher-form/components/item-details/item-details-section.component.ts +++ b/libs/vault/src/cipher-form/components/item-details/item-details-section.component.ts @@ -273,19 +273,25 @@ export class ItemDetailsSectionComponent implements OnInit { this.showCollectionsControl = true; } - const organization = this.organizations.find((o) => o.id === orgId); - this.collectionOptions = this.collections .filter((c) => { - // Filter criteria: - // - The collection belongs to the organization - // - When in partial edit mode, show all org collections because the control is disabled. - // - The user can edit items within the collection - // - When viewing as an admin, all collections should be shown, even readonly. When non-admin, filter out readonly collections - return ( - c.organizationId === orgId && - (this.partialEdit || c.canEditItems(organization) || this.config.admin) - ); + // The collection belongs to the organization + if (c.organizationId !== orgId) { + return false; + } + + // When in partial edit mode, show all org collections because the control is disabled. + if (this.partialEdit) { + return true; + } + + // When viewing as an admin, all collections should be shown, even readonly. (AC Only) + if (this.config.admin) { + return true; + } + + // Non-admins can only select assigned collections that are not read only. (Non-AC) + return c.assigned && !c.readOnly; }) .map((c) => ({ id: c.id,