diff --git a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts index f56df08b1d..c53dc58370 100644 --- a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts +++ b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts @@ -45,7 +45,7 @@ export class PublicConnectionFormService { this.authenticationService.onLogin.addHandler(async (event, context) => { if (event === 'before') { - const confirmed = await this.close(false); + const confirmed = await this.showUnsavedChangesDialog(); if (!confirmed) { ExecutorInterrupter.interrupt(context); } @@ -164,6 +164,14 @@ export class PublicConnectionFormService { }; private readonly closeHandler: IExecutorHandler = async (data, contexts) => { + const confirmed = await this.showUnsavedChangesDialog(); + + if (!confirmed) { + ExecutorInterrupter.interrupt(contexts); + } + }; + + private async showUnsavedChangesDialog(): Promise { if ( !this.formState || !this.optionsPanelService.isOpen(formGetter) @@ -176,13 +184,13 @@ export class PublicConnectionFormService { )) ) ) { - return; + return true; } const state = await this.formState.checkFormState(); if (!state?.edited) { - return; + return true; } const result = await this.commonDialogService.open(ConfirmationDialog, { @@ -191,10 +199,8 @@ export class PublicConnectionFormService { confirmActionText: 'ui_processing_ok', }); - if (result === DialogueStateResult.Rejected) { - ExecutorInterrupter.interrupt(contexts); - } - }; + return result !== DialogueStateResult.Rejected; + } private async tryReconnect(connectionKey: IConnectionInfoParams) { const result = await this.commonDialogService.open(ConfirmationDialog, {