mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
[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
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
"@cloudbeaver/core-di": "workspace:*",
|
||||
"@cloudbeaver/core-dialogs": "workspace:*",
|
||||
"@cloudbeaver/core-events": "workspace:*",
|
||||
"@cloudbeaver/core-executor": "workspace:*",
|
||||
"@cloudbeaver/core-localization": "workspace:*",
|
||||
"@cloudbeaver/core-root": "workspace:*",
|
||||
"@cloudbeaver/core-routing": "workspace:*",
|
||||
|
||||
@@ -31,7 +31,7 @@ export class CoreSessionActionsBootstrap extends Bootstrap {
|
||||
}
|
||||
|
||||
private async handleOpenUrlEvent(event: WsOpenUrlEvent): Promise<void> {
|
||||
const { url, timestamp } = event;
|
||||
const { url, timestamp, actionId } = event;
|
||||
|
||||
try {
|
||||
const { status } = await this.commonDialogService.open(ConfirmationDialog, {
|
||||
@@ -52,8 +52,15 @@ export class CoreSessionActionsBootstrap extends Bootstrap {
|
||||
this.notificationService.logError({
|
||||
title: 'core_session_actions_popup_blocked',
|
||||
});
|
||||
|
||||
this.sessionActionsEventHandler.cancelAuth(actionId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (status === DialogueStateResult.Rejected) {
|
||||
this.sessionActionsEventHandler.cancelAuth(actionId);
|
||||
}
|
||||
} catch (exception: any) {
|
||||
this.notificationService.logException(exception, 'core_session_actions_open_url_error');
|
||||
}
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2025 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
import { type ISessionEvent, type SessionEventId, SessionEventSource, SessionEventTopic, TopicEventHandler } from '@cloudbeaver/core-root';
|
||||
import { CbEventTopic, type WsOpenUrlEvent } from '@cloudbeaver/core-sdk';
|
||||
import {
|
||||
ClientEventId,
|
||||
type ISessionEvent,
|
||||
type SessionEventId,
|
||||
SessionEventSource,
|
||||
SessionEventTopic,
|
||||
TopicEventHandler,
|
||||
} from '@cloudbeaver/core-root';
|
||||
import { CbEventTopic, type CbActionCancelledEvent, type WsOpenUrlEvent } from '@cloudbeaver/core-sdk';
|
||||
|
||||
@injectable(() => [SessionEventSource])
|
||||
export class SessionActionsEventHandler extends TopicEventHandler<WsOpenUrlEvent, ISessionEvent, SessionEventId, SessionEventTopic> {
|
||||
@@ -15,6 +22,14 @@ export class SessionActionsEventHandler extends TopicEventHandler<WsOpenUrlEvent
|
||||
super(CbEventTopic.CbSessionAction, sessionEventSource);
|
||||
}
|
||||
|
||||
cancelAuth(actionId: string): void {
|
||||
this.emit<CbActionCancelledEvent>({
|
||||
id: ClientEventId.CbClientCancelAction,
|
||||
topicId: SessionEventTopic.CbSessionAction,
|
||||
actionId,
|
||||
});
|
||||
}
|
||||
|
||||
map(event: WsOpenUrlEvent): WsOpenUrlEvent {
|
||||
return event;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
{
|
||||
"path": "../core-events"
|
||||
},
|
||||
{
|
||||
"path": "../core-executor"
|
||||
},
|
||||
{
|
||||
"path": "../core-localization"
|
||||
},
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
"@cloudbeaver/core-resource": "workspace:*",
|
||||
"@cloudbeaver/core-root": "workspace:*",
|
||||
"@cloudbeaver/core-sdk": "workspace:*",
|
||||
"@cloudbeaver/core-session-actions": "workspace:*",
|
||||
"@cloudbeaver/core-settings": "workspace:*",
|
||||
"@cloudbeaver/core-ui": "workspace:*",
|
||||
"@cloudbeaver/core-utils": "workspace:*",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2025 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -133,7 +133,7 @@ export function useDatabaseCredentialsAuthDialog(
|
||||
await this.connectionInfoResource.init(this.getConfig());
|
||||
this.onInit?.();
|
||||
} catch (exception: any) {
|
||||
this.authException = exception;
|
||||
this.authException = exception;
|
||||
} finally {
|
||||
this.authenticating = false;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
{
|
||||
"path": "../core-sdk"
|
||||
},
|
||||
{
|
||||
"path": "../core-session-actions"
|
||||
},
|
||||
{
|
||||
"path": "../core-settings"
|
||||
},
|
||||
|
||||
@@ -2037,6 +2037,7 @@ __metadata:
|
||||
"@cloudbeaver/core-di": "workspace:*"
|
||||
"@cloudbeaver/core-dialogs": "workspace:*"
|
||||
"@cloudbeaver/core-events": "workspace:*"
|
||||
"@cloudbeaver/core-executor": "workspace:*"
|
||||
"@cloudbeaver/core-localization": "workspace:*"
|
||||
"@cloudbeaver/core-root": "workspace:*"
|
||||
"@cloudbeaver/core-routing": "workspace:*"
|
||||
@@ -2798,6 +2799,7 @@ __metadata:
|
||||
"@cloudbeaver/core-resource": "workspace:*"
|
||||
"@cloudbeaver/core-root": "workspace:*"
|
||||
"@cloudbeaver/core-sdk": "workspace:*"
|
||||
"@cloudbeaver/core-session-actions": "workspace:*"
|
||||
"@cloudbeaver/core-settings": "workspace:*"
|
||||
"@cloudbeaver/core-ui": "workspace:*"
|
||||
"@cloudbeaver/core-utils": "workspace:*"
|
||||
|
||||
Reference in New Issue
Block a user