Skip to content

Commit f3eaed9

Browse files
[CB] Add ability to interrupt connection establishment (front-end) (#4321)
* dbeaver/pro#8810 adds cancel action for auth via link * lint fix + handles edge case when no popup appeared * reverts eslint fix * adds synchronization to connection init with oauth cancelling to remove stuck loading state * reverts abort logic * removes onAuthCancelled
1 parent 339f19f commit f3eaed9

8 files changed

Lines changed: 38 additions & 6 deletions

File tree

webapp/packages/core-session-actions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@cloudbeaver/core-di": "workspace:*",
2828
"@cloudbeaver/core-dialogs": "workspace:*",
2929
"@cloudbeaver/core-events": "workspace:*",
30+
"@cloudbeaver/core-executor": "workspace:*",
3031
"@cloudbeaver/core-localization": "workspace:*",
3132
"@cloudbeaver/core-root": "workspace:*",
3233
"@cloudbeaver/core-routing": "workspace:*",

webapp/packages/core-session-actions/src/CoreSessionActionsBootstrap.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class CoreSessionActionsBootstrap extends Bootstrap {
3131
}
3232

3333
private async handleOpenUrlEvent(event: WsOpenUrlEvent): Promise<void> {
34-
const { url, timestamp } = event;
34+
const { url, timestamp, actionId } = event;
3535

3636
try {
3737
const { status } = await this.commonDialogService.open(ConfirmationDialog, {
@@ -52,8 +52,15 @@ export class CoreSessionActionsBootstrap extends Bootstrap {
5252
this.notificationService.logError({
5353
title: 'core_session_actions_popup_blocked',
5454
});
55+
56+
this.sessionActionsEventHandler.cancelAuth(actionId);
57+
return;
5558
}
5659
}
60+
61+
if (status === DialogueStateResult.Rejected) {
62+
this.sessionActionsEventHandler.cancelAuth(actionId);
63+
}
5764
} catch (exception: any) {
5865
this.notificationService.logException(exception, 'core_session_actions_open_url_error');
5966
}

webapp/packages/core-session-actions/src/SessionActionsEventHandler.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
/*
22
* CloudBeaver - Cloud Database Manager
3-
* Copyright (C) 2020-2025 DBeaver Corp and others
3+
* Copyright (C) 2020-2026 DBeaver Corp and others
44
*
55
* Licensed under the Apache License, Version 2.0.
66
* you may not use this file except in compliance with the License.
77
*/
88
import { injectable } from '@cloudbeaver/core-di';
9-
import { type ISessionEvent, type SessionEventId, SessionEventSource, SessionEventTopic, TopicEventHandler } from '@cloudbeaver/core-root';
10-
import { CbEventTopic, type WsOpenUrlEvent } from '@cloudbeaver/core-sdk';
9+
import {
10+
ClientEventId,
11+
type ISessionEvent,
12+
type SessionEventId,
13+
SessionEventSource,
14+
SessionEventTopic,
15+
TopicEventHandler,
16+
} from '@cloudbeaver/core-root';
17+
import { CbEventTopic, type CbActionCancelledEvent, type WsOpenUrlEvent } from '@cloudbeaver/core-sdk';
1118

1219
@injectable(() => [SessionEventSource])
1320
export class SessionActionsEventHandler extends TopicEventHandler<WsOpenUrlEvent, ISessionEvent, SessionEventId, SessionEventTopic> {
1421
constructor(sessionEventSource: SessionEventSource) {
1522
super(CbEventTopic.CbSessionAction, sessionEventSource);
1623
}
1724

25+
cancelAuth(actionId: string): void {
26+
this.emit<CbActionCancelledEvent>({
27+
id: ClientEventId.CbClientCancelAction,
28+
topicId: SessionEventTopic.CbSessionAction,
29+
actionId,
30+
});
31+
}
32+
1833
map(event: WsOpenUrlEvent): WsOpenUrlEvent {
1934
return event;
2035
}

webapp/packages/core-session-actions/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
{
2929
"path": "../core-events"
3030
},
31+
{
32+
"path": "../core-executor"
33+
},
3134
{
3235
"path": "../core-localization"
3336
},

webapp/packages/plugin-connections/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@cloudbeaver/core-resource": "workspace:*",
3838
"@cloudbeaver/core-root": "workspace:*",
3939
"@cloudbeaver/core-sdk": "workspace:*",
40+
"@cloudbeaver/core-session-actions": "workspace:*",
4041
"@cloudbeaver/core-settings": "workspace:*",
4142
"@cloudbeaver/core-ui": "workspace:*",
4243
"@cloudbeaver/core-utils": "workspace:*",

webapp/packages/plugin-connections/src/DatabaseAuthDialog/DatabaseCredentialsAuthDialog/useDatabaseCredentialsAuthDialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* CloudBeaver - Cloud Database Manager
3-
* Copyright (C) 2020-2025 DBeaver Corp and others
3+
* Copyright (C) 2020-2026 DBeaver Corp and others
44
*
55
* Licensed under the Apache License, Version 2.0.
66
* you may not use this file except in compliance with the License.
@@ -133,7 +133,7 @@ export function useDatabaseCredentialsAuthDialog(
133133
await this.connectionInfoResource.init(this.getConfig());
134134
this.onInit?.();
135135
} catch (exception: any) {
136-
this.authException = exception;
136+
this.authException = exception;
137137
} finally {
138138
this.authenticating = false;
139139
}

webapp/packages/plugin-connections/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
{
6262
"path": "../core-sdk"
6363
},
64+
{
65+
"path": "../core-session-actions"
66+
},
6467
{
6568
"path": "../core-settings"
6669
},

webapp/yarn.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,7 @@ __metadata:
20372037
"@cloudbeaver/core-di": "workspace:*"
20382038
"@cloudbeaver/core-dialogs": "workspace:*"
20392039
"@cloudbeaver/core-events": "workspace:*"
2040+
"@cloudbeaver/core-executor": "workspace:*"
20402041
"@cloudbeaver/core-localization": "workspace:*"
20412042
"@cloudbeaver/core-root": "workspace:*"
20422043
"@cloudbeaver/core-routing": "workspace:*"
@@ -2798,6 +2799,7 @@ __metadata:
27982799
"@cloudbeaver/core-resource": "workspace:*"
27992800
"@cloudbeaver/core-root": "workspace:*"
28002801
"@cloudbeaver/core-sdk": "workspace:*"
2802+
"@cloudbeaver/core-session-actions": "workspace:*"
28012803
"@cloudbeaver/core-settings": "workspace:*"
28022804
"@cloudbeaver/core-ui": "workspace:*"
28032805
"@cloudbeaver/core-utils": "workspace:*"

0 commit comments

Comments
 (0)