[PM-5697] Capture all form data from page when selecting "New item" within the inline menu even if popout is already open (#7773)

* [PM-5679] Capture all form data from page when selecting "New item" even if popout is already open

* [PM-5679] Capture all form data from page when selecting "New item" even if popout is already open

* [PM-5697] Fixing floating promise within the handleExtensionMessage method
This commit is contained in:
Cesar Gonzalez 2024-02-23 12:27:25 -06:00 committed by GitHub
parent 8ab4eecc8a
commit 38e40a0471
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 9 deletions

View File

@ -615,6 +615,8 @@ describe("OverlayBackground", () => {
});
it("will open the add edit popout window after creating a new cipher", async () => {
jest.spyOn(BrowserApi, "sendMessage");
sendExtensionRuntimeMessage(
{
command: "autofillOverlayAddNewVaultItem",
@ -630,6 +632,9 @@ describe("OverlayBackground", () => {
await flushPromises();
expect(overlayBackground["stateService"].setAddEditCipherInfo).toHaveBeenCalled();
expect(BrowserApi.sendMessage).toHaveBeenCalledWith(
"inlineAutofillMenuRefreshAddEditCipher",
);
expect(overlayBackground["openAddEditVaultItemPopout"]).toHaveBeenCalled();
});
});

View File

@ -670,6 +670,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
collectionIds: cipherView.collectionIds,
});
await BrowserApi.sendMessage("inlineAutofillMenuRefreshAddEditCipher");
await this.openAddEditVaultItemPopout(sender.tab, { cipherId: cipherView.id });
}

View File

@ -43,7 +43,6 @@ export class AddEditComponent extends BaseAddEditComponent {
showAttachments = true;
openAttachmentsInPopup: boolean;
showAutoFillOnPageLoadOptions: boolean;
private singleActionKey: string;
private fido2PopoutSessionData$ = fido2PopoutSessionData$();
@ -123,9 +122,7 @@ export class AddEditComponent extends BaseAddEditComponent {
if (params.selectedVault) {
this.organizationId = params.selectedVault;
}
if (params.singleActionKey) {
this.singleActionKey = params.singleActionKey;
}
await this.load();
if (!this.editMode || this.cloneMode) {
@ -141,6 +138,10 @@ export class AddEditComponent extends BaseAddEditComponent {
}
this.openAttachmentsInPopup = BrowserPopupUtils.inPopup(window);
if (this.inAddEditPopoutWindow()) {
BrowserApi.messageListener("add-edit-popout", this.handleExtensionMessage.bind(this));
}
});
if (!this.editMode) {
@ -358,10 +359,7 @@ export class AddEditComponent extends BaseAddEditComponent {
}
private inAddEditPopoutWindow() {
return BrowserPopupUtils.inSingleActionPopout(
window,
this.singleActionKey || VaultPopoutType.addEditVaultItem,
);
return BrowserPopupUtils.inSingleActionPopout(window, VaultPopoutType.addEditVaultItem);
}
async captureTOTPFromTab() {
@ -385,4 +383,10 @@ export class AddEditComponent extends BaseAddEditComponent {
);
}
}
private handleExtensionMessage(message: { [key: string]: any; command: string }) {
if (message.command === "inlineAutofillMenuRefreshAddEditCipher") {
this.load().catch((error) => this.logService.error(error));
}
}
}

View File

@ -111,7 +111,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
protected messagingService: MessagingService,
protected eventCollectionService: EventCollectionService,
protected policyService: PolicyService,
private logService: LogService,
protected logService: LogService,
protected passwordRepromptService: PasswordRepromptService,
private organizationService: OrganizationService,
protected sendApiService: SendApiService,