mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
pass entire cipher into edit logic to match view logic
This commit is contained in:
@@ -502,7 +502,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
if (action === "view") {
|
if (action === "view") {
|
||||||
await this.viewCipherById(cipher);
|
await this.viewCipherById(cipher);
|
||||||
} else {
|
} else {
|
||||||
await this.editCipherId(cipherId, false);
|
await this.editCipherId(cipher, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.toastService.showToast({
|
this.toastService.showToast({
|
||||||
@@ -801,17 +801,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
cloneCipher: boolean,
|
cloneCipher: boolean,
|
||||||
additionalComponentParameters?: (comp: AddEditComponent) => void,
|
additionalComponentParameters?: (comp: AddEditComponent) => void,
|
||||||
) {
|
) {
|
||||||
return this.editCipherId(cipher?.id, cloneCipher, additionalComponentParameters);
|
return this.editCipherId(cipher, cloneCipher, additionalComponentParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editCipherId(
|
async editCipherId(
|
||||||
cipherId: string,
|
cipher: CipherView,
|
||||||
cloneCipher: boolean,
|
cloneCipher: boolean,
|
||||||
additionalComponentParameters?: (comp: AddEditComponent) => void,
|
additionalComponentParameters?: (comp: AddEditComponent) => void,
|
||||||
) {
|
) {
|
||||||
const cipher = await this.cipherService.get(cipherId);
|
|
||||||
// if cipher exists (cipher is null when new) and MP reprompt
|
|
||||||
// is on for this cipher, then show password reprompt
|
|
||||||
if (
|
if (
|
||||||
cipher &&
|
cipher &&
|
||||||
cipher.reprompt !== 0 &&
|
cipher.reprompt !== 0 &&
|
||||||
@@ -823,14 +820,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.extensionRefreshEnabled) {
|
if (this.extensionRefreshEnabled) {
|
||||||
await this.editCipherIdV2(cipherId as CipherId, cloneCipher);
|
await this.editCipherIdV2(cipher, cloneCipher);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = cipherId;
|
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();
|
||||||
@@ -869,13 +866,13 @@ 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(cipherId: CipherId, cloneCipher: boolean) {
|
private async editCipherIdV2(cipher: CipherView, cloneCipher: boolean) {
|
||||||
const cipherFormConfig = await this.cipherFormConfigService.buildConfig(
|
const cipherFormConfig = await this.cipherFormConfigService.buildConfig(
|
||||||
cloneCipher ? "clone" : "edit",
|
cloneCipher ? "clone" : "edit",
|
||||||
cipherId,
|
cipher.id as CipherId,
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.openVaultItemDialog("form", cipherFormConfig);
|
await this.openVaultItemDialog("form", cipherFormConfig, cipher);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Opens the view dialog for the given cipher unless password reprompt fails */
|
/** Opens the view dialog for the given cipher unless password reprompt fails */
|
||||||
@@ -908,8 +905,10 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
cipher?: CipherView,
|
cipher?: CipherView,
|
||||||
) {
|
) {
|
||||||
const disableForm = cipher ? !cipher.edit && !this.organization.canEditAllCiphers : false;
|
const disableForm = cipher ? !cipher.edit && !this.organization.canEditAllCiphers : false;
|
||||||
|
// If the form is disabled, force the mode into `view`
|
||||||
|
const dialogMode = disableForm ? "view" : mode;
|
||||||
this.vaultItemDialogRef = VaultItemDialogComponent.open(this.dialogService, {
|
this.vaultItemDialogRef = VaultItemDialogComponent.open(this.dialogService, {
|
||||||
mode,
|
mode: dialogMode,
|
||||||
formConfig,
|
formConfig,
|
||||||
disableForm,
|
disableForm,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user