[PM-9959] Add support for name and username to be passed in as query params for initial form values
This commit is contained in:
parent
7090e3fa96
commit
9a0188048c
|
@ -46,6 +46,8 @@ class QueryParams {
|
|||
this.organizationId = params.organizationId;
|
||||
this.collectionId = params.collectionId;
|
||||
this.uri = params.uri;
|
||||
this.username = params.username;
|
||||
this.name = params.name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,6 +84,16 @@ class QueryParams {
|
|||
* Optional URI to pre-fill for login ciphers.
|
||||
*/
|
||||
uri?: string;
|
||||
|
||||
/**
|
||||
* Optional username to pre-fill for login/identity ciphers.
|
||||
*/
|
||||
username?: string;
|
||||
|
||||
/**
|
||||
* Optional name to pre-fill for the cipher.
|
||||
*/
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export type AddEditQueryParams = Partial<Record<keyof QueryParams, string>>;
|
||||
|
@ -261,6 +273,12 @@ export class AddEditV2Component implements OnInit {
|
|||
if (params.uri) {
|
||||
config.initialValues.loginUri = params.uri;
|
||||
}
|
||||
if (params.username) {
|
||||
config.initialValues.username = params.username;
|
||||
}
|
||||
if (params.name) {
|
||||
config.initialValues.name = params.name;
|
||||
}
|
||||
}
|
||||
|
||||
setHeader(mode: CipherFormMode, type: CipherType) {
|
||||
|
|
|
@ -22,6 +22,8 @@ export type OptionalInitialValues = {
|
|||
organizationId?: OrganizationId;
|
||||
collectionIds?: CollectionId[];
|
||||
loginUri?: string;
|
||||
username?: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -113,6 +113,10 @@ export class IdentitySectionComponent implements OnInit {
|
|||
|
||||
if (this.originalCipherView && this.originalCipherView.id) {
|
||||
this.populateFormData();
|
||||
} else {
|
||||
this.identityForm.patchValue({
|
||||
username: this.cipherFormContainer.config.initialValues?.username || "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ export class ItemDetailsSectionComponent implements OnInit {
|
|||
await this.initFromExistingCipher();
|
||||
} else {
|
||||
this.itemDetailsForm.setValue({
|
||||
name: "",
|
||||
name: this.initialValues?.name || "",
|
||||
organizationId: this.initialValues?.organizationId || this.defaultOwner,
|
||||
folderId: this.initialValues?.folderId || null,
|
||||
collectionIds: [],
|
||||
|
|
|
@ -144,9 +144,10 @@ export class LoginDetailsSectionComponent implements OnInit {
|
|||
}
|
||||
|
||||
private async initNewCipher() {
|
||||
this.loginDetailsForm.controls.password.patchValue(
|
||||
await this.generationService.generateInitialPassword(),
|
||||
);
|
||||
this.loginDetailsForm.patchValue({
|
||||
username: this.cipherFormContainer.config.initialValues?.username || "",
|
||||
password: await this.generationService.generateInitialPassword(),
|
||||
});
|
||||
}
|
||||
|
||||
captureTotp = async () => {
|
||||
|
|
Loading…
Reference in New Issue