From 38c1cdfb6295f28cc4692beaa1ff6399c1c91387 Mon Sep 17 00:00:00 2001 From: Jordan Aasen <166539328+jaasen-livefront@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:36:38 -0800 Subject: [PATCH] [PM-14289] - vault cipher form - set default owner as organization from collection when possible (#12682) * set default org by referencing collecction * get organizationId from collection * always get organizationId from collection when possible --- .../vault/individual-vault/vault.component.ts | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 5b68b3fbc2..8c1d08b269 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -779,16 +779,26 @@ export class VaultComponent implements OnInit, OnDestroy { null, cipherType, ); + const collectionId = + this.activeFilter.collectionId !== "AllCollections" && this.activeFilter.collectionId != null + ? this.activeFilter.collectionId + : null; + let organizationId = + this.activeFilter.organizationId !== "MyVault" && this.activeFilter.organizationId != null + ? this.activeFilter.organizationId + : null; + // Attempt to get the organization ID from the collection if present + if (collectionId) { + const organizationIdFromCollection = ( + await firstValueFrom(this.vaultFilterService.filteredCollections$) + ).find((c) => c.id === this.activeFilter.collectionId)?.organizationId; + if (organizationIdFromCollection) { + organizationId = organizationIdFromCollection; + } + } cipherFormConfig.initialValues = { - organizationId: - this.activeFilter.organizationId !== "MyVault" && this.activeFilter.organizationId != null - ? (this.activeFilter.organizationId as OrganizationId) - : null, - collectionIds: - this.activeFilter.collectionId !== "AllCollections" && - this.activeFilter.collectionId != null - ? [this.activeFilter.collectionId as CollectionId] - : [], + organizationId: organizationId as OrganizationId, + collectionIds: [collectionId as CollectionId], folderId: this.activeFilter.folderId, };