1
0
mirror of https://github.com/bitwarden/browser synced 2025-01-26 11:15:03 +01:00

[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
This commit is contained in:
Jordan Aasen 2025-01-08 10:36:38 -08:00 committed by GitHub
parent 4d576f0533
commit 38c1cdfb62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,
};