mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-28 03:41:48 +08:00
refactor: CB-608 CB-1293 resources lazy loading
This commit is contained in:
@@ -7,10 +7,11 @@
|
||||
*/
|
||||
|
||||
import { NavigationTabsService } from '@cloudbeaver/core-app';
|
||||
import { ConnectionsManagerService } from '@cloudbeaver/core-connections';
|
||||
import { ConnectionInfoResource } from '@cloudbeaver/core-connections';
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { IExecutor, Executor, IExecutionContextProvider } from '@cloudbeaver/core-executor';
|
||||
import { ResourceKey, ResourceKeyUtils } from '@cloudbeaver/core-sdk';
|
||||
import { NavigationService } from '@cloudbeaver/core-ui';
|
||||
|
||||
import type { ISqlEditorTabState } from './ISqlEditorTabState';
|
||||
@@ -48,9 +49,9 @@ export class SqlEditorNavigatorService {
|
||||
|
||||
constructor(
|
||||
private navigationTabsService: NavigationTabsService,
|
||||
private connectionsManagerService: ConnectionsManagerService,
|
||||
private notificationService: NotificationService,
|
||||
private sqlEditorTabService: SqlEditorTabService,
|
||||
private connectionInfoResource: ConnectionInfoResource,
|
||||
private readonly sqlResultTabsService: SqlResultTabsService,
|
||||
navigationService: NavigationService
|
||||
) {
|
||||
@@ -60,7 +61,9 @@ export class SqlEditorNavigatorService {
|
||||
)
|
||||
.before(navigationService.navigationTask)
|
||||
.addHandler(this.navigateHandler.bind(this));
|
||||
this.connectionsManagerService.onCloseConnection.subscribe(this.handleConnectionClose.bind(this));
|
||||
|
||||
this.connectionInfoResource.onItemDelete.addHandler(this.handleConnectionClose.bind(this));
|
||||
this.connectionInfoResource.onConnectionClose.addHandler(connection => this.handleConnectionClose(connection.id));
|
||||
}
|
||||
|
||||
openNewEditor(connectionId?: string, catalogId?: string, schemaId?: string) {
|
||||
@@ -88,10 +91,10 @@ export class SqlEditorNavigatorService {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleConnectionClose(connectionId: string) {
|
||||
private async handleConnectionClose(key: ResourceKey<string>) {
|
||||
try {
|
||||
for (const tab of this.navigationTabsService.findTabs<ISqlEditorTabState>(
|
||||
isSQLEditorTab(tab => !!tab.handlerState.executionContext?.connectionId.includes(connectionId))
|
||||
isSQLEditorTab(tab => ResourceKeyUtils.includes(key, tab.handlerState.executionContext?.connectionId))
|
||||
)) {
|
||||
this.sqlEditorTabService.resetConnectionInfo(tab.handlerState);
|
||||
}
|
||||
|
||||
@@ -19,12 +19,14 @@ import {
|
||||
import {
|
||||
ConnectionExecutionContextResource,
|
||||
ConnectionExecutionContextService,
|
||||
ConnectionInfoResource,
|
||||
connectionProvider,
|
||||
connectionSetter,
|
||||
IConnectionExecutionContextInfo,
|
||||
} from '@cloudbeaver/core-connections';
|
||||
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { CachedMapAllKey } from '@cloudbeaver/core-sdk';
|
||||
|
||||
import type { ISqlEditorTabState } from './ISqlEditorTabState';
|
||||
import { SqlEditorPanel } from './SqlEditorPanel';
|
||||
@@ -42,8 +44,9 @@ export class SqlEditorTabService extends Bootstrap {
|
||||
private notificationService: NotificationService,
|
||||
private sqlEditorService: SqlEditorService,
|
||||
private readonly sqlResultTabsService: SqlResultTabsService,
|
||||
private connectionExecutionContextService: ConnectionExecutionContextService,
|
||||
private connectionExecutionContextResource: ConnectionExecutionContextResource
|
||||
private readonly connectionExecutionContextService: ConnectionExecutionContextService,
|
||||
private readonly connectionExecutionContextResource: ConnectionExecutionContextResource,
|
||||
private readonly connectionInfo: ConnectionInfoResource,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -147,6 +150,8 @@ export class SqlEditorTabService extends Bootstrap {
|
||||
}
|
||||
|
||||
if (tab.handlerState.executionContext) {
|
||||
await this.connectionInfo.load(CachedMapAllKey);
|
||||
await this.connectionExecutionContextResource.loadAll();
|
||||
const executionContext = this.connectionExecutionContextService.get(tab.handlerState.executionContext.baseId);
|
||||
|
||||
if (!executionContext) {
|
||||
|
||||
Reference in New Issue
Block a user