1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

fix model creation (#16257)

This commit is contained in:
Brandon Treston
2025-09-02 10:36:39 -04:00
committed by GitHub
parent 45d0e90607
commit 1ae5a7798d

View File

@@ -400,20 +400,29 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
} }
if ( if (
this.editMode && this.editMode &&
!this.collection.canEditName(this.organization) && !this.collection?.canEditName(this.organization) &&
this.formGroup.controls.name.dirty this.formGroup.controls.name.dirty
) { ) {
throw new Error("Cannot change readonly field: Name"); throw new Error("Cannot change readonly field: Name");
} }
const parent = this.formGroup.controls.parent?.value; const parent = this.formGroup.controls.parent?.value;
const collectionView = new CollectionAdminView({
id: this.params.collectionId as CollectionId, // Clone the current collection
organizationId: this.formGroup.controls.selectedOrg.value, const collectionView = Object.assign(
name: parent new CollectionAdminView({
? `${parent}/${this.formGroup.controls.name.value}` id: "" as CollectionId,
: this.formGroup.controls.name.value, organizationId: "" as OrganizationId,
}); name: "",
}),
this.collection,
);
collectionView.name = parent
? `${parent}/${this.formGroup.controls.name.value}`
: this.formGroup.controls.name.value;
collectionView.id = this.params.collectionId as CollectionId;
collectionView.organizationId = this.formGroup.controls.selectedOrg.value;
collectionView.externalId = this.formGroup.controls.externalId.value; collectionView.externalId = this.formGroup.controls.externalId.value;
collectionView.groups = this.formGroup.controls.access.value collectionView.groups = this.formGroup.controls.access.value
.filter((v) => v.type === AccessItemType.Group) .filter((v) => v.type === AccessItemType.Group)
@@ -421,7 +430,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
collectionView.users = this.formGroup.controls.access.value collectionView.users = this.formGroup.controls.access.value
.filter((v) => v.type === AccessItemType.Member) .filter((v) => v.type === AccessItemType.Member)
.map(convertToSelectionView); .map(convertToSelectionView);
collectionView.defaultUserCollectionEmail = this.collection?.defaultUserCollectionEmail;
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));