1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-18 15:47:57 +01:00

account for adding a new cipher in the admin console (#11469)

- When adding a new cipher, the `editCipher` method is called but without a given cipher
This commit is contained in:
Nick Krantz 2024-10-08 16:41:28 -05:00 committed by GitHub
parent a5c1a5a42f
commit c6169432bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -788,8 +788,8 @@ export class VaultComponent implements OnInit, OnDestroy {
} }
/** /**
* Edit the given cipher * Edit the given cipher or add a new cipher
* @param cipherView - The cipher to be edited * @param cipherView - When set, the cipher to be edited
* @param cloneCipher - `true` when the cipher should be cloned. * @param cloneCipher - `true` when the cipher should be cloned.
* Used in place of the `additionalComponentParameters`, as * Used in place of the `additionalComponentParameters`, as
* the `editCipherIdV2` method has a differing implementation. * the `editCipherIdV2` method has a differing implementation.
@ -797,7 +797,7 @@ export class VaultComponent implements OnInit, OnDestroy {
* the `AddEditComponent` to edit methods directly. * the `AddEditComponent` to edit methods directly.
*/ */
async editCipher( async editCipher(
cipher: CipherView, cipher: CipherView | null,
cloneCipher: boolean, cloneCipher: boolean,
additionalComponentParameters?: (comp: AddEditComponent) => void, additionalComponentParameters?: (comp: AddEditComponent) => void,
) { ) {
@ -805,7 +805,7 @@ export class VaultComponent implements OnInit, OnDestroy {
} }
async editCipherId( async editCipherId(
cipher: CipherView, cipher: CipherView | null,
cloneCipher: boolean, cloneCipher: boolean,
additionalComponentParameters?: (comp: AddEditComponent) => void, additionalComponentParameters?: (comp: AddEditComponent) => void,
) { ) {
@ -827,7 +827,7 @@ export class VaultComponent implements OnInit, OnDestroy {
const defaultComponentParameters = (comp: AddEditComponent) => { const defaultComponentParameters = (comp: AddEditComponent) => {
comp.organization = this.organization; comp.organization = this.organization;
comp.organizationId = this.organization.id; comp.organizationId = this.organization.id;
comp.cipherId = cipher.id; comp.cipherId = cipher?.id;
comp.onSavedCipher.pipe(takeUntil(this.destroy$)).subscribe(() => { comp.onSavedCipher.pipe(takeUntil(this.destroy$)).subscribe(() => {
modal.close(); modal.close();
this.refresh(); this.refresh();
@ -866,10 +866,10 @@ export class VaultComponent implements OnInit, OnDestroy {
* Edit a cipher using the new AddEditCipherDialogV2 component. * Edit a cipher using the new AddEditCipherDialogV2 component.
* Only to be used behind the ExtensionRefresh feature flag. * Only to be used behind the ExtensionRefresh feature flag.
*/ */
private async editCipherIdV2(cipher: CipherView, cloneCipher: boolean) { private async editCipherIdV2(cipher: CipherView | null, cloneCipher: boolean) {
const cipherFormConfig = await this.cipherFormConfigService.buildConfig( const cipherFormConfig = await this.cipherFormConfigService.buildConfig(
cloneCipher ? "clone" : "edit", cloneCipher ? "clone" : "edit",
cipher.id as CipherId, cipher?.id as CipherId | null,
); );
await this.openVaultItemDialog("form", cipherFormConfig, cipher); await this.openVaultItemDialog("form", cipherFormConfig, cipher);