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

View File

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

View File

@ -43,7 +43,6 @@ export class AddEditComponent extends BaseAddEditComponent {
showAttachments = true; showAttachments = true;
openAttachmentsInPopup: boolean; openAttachmentsInPopup: boolean;
showAutoFillOnPageLoadOptions: boolean; showAutoFillOnPageLoadOptions: boolean;
private singleActionKey: string;
private fido2PopoutSessionData$ = fido2PopoutSessionData$(); private fido2PopoutSessionData$ = fido2PopoutSessionData$();
@ -123,9 +122,7 @@ export class AddEditComponent extends BaseAddEditComponent {
if (params.selectedVault) { if (params.selectedVault) {
this.organizationId = params.selectedVault; this.organizationId = params.selectedVault;
} }
if (params.singleActionKey) {
this.singleActionKey = params.singleActionKey;
}
await this.load(); await this.load();
if (!this.editMode || this.cloneMode) { if (!this.editMode || this.cloneMode) {
@ -141,6 +138,10 @@ export class AddEditComponent extends BaseAddEditComponent {
} }
this.openAttachmentsInPopup = BrowserPopupUtils.inPopup(window); this.openAttachmentsInPopup = BrowserPopupUtils.inPopup(window);
if (this.inAddEditPopoutWindow()) {
BrowserApi.messageListener("add-edit-popout", this.handleExtensionMessage.bind(this));
}
}); });
if (!this.editMode) { if (!this.editMode) {
@ -358,10 +359,7 @@ export class AddEditComponent extends BaseAddEditComponent {
} }
private inAddEditPopoutWindow() { private inAddEditPopoutWindow() {
return BrowserPopupUtils.inSingleActionPopout( return BrowserPopupUtils.inSingleActionPopout(window, VaultPopoutType.addEditVaultItem);
window,
this.singleActionKey || VaultPopoutType.addEditVaultItem,
);
} }
async captureTOTPFromTab() { 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 messagingService: MessagingService,
protected eventCollectionService: EventCollectionService, protected eventCollectionService: EventCollectionService,
protected policyService: PolicyService, protected policyService: PolicyService,
private logService: LogService, protected logService: LogService,
protected passwordRepromptService: PasswordRepromptService, protected passwordRepromptService: PasswordRepromptService,
private organizationService: OrganizationService, private organizationService: OrganizationService,
protected sendApiService: SendApiService, protected sendApiService: SendApiService,