mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-28 03:41:48 +08:00
CB-5205 fix: connection view switching (#2984)
* CB-5205 fix: connection view switching * CB-5205 fix: tabs synchronization * CB-5205 fix: connection sync --------- Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com> Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgenia Bezborodova
mr-anton-t
parent
7427543b7f
commit
67c54d29eb
@@ -24,6 +24,7 @@ import {
|
||||
type IConnectionInfoParams,
|
||||
objectCatalogProvider,
|
||||
objectCatalogSetter,
|
||||
objectLoaderProvider,
|
||||
objectSchemaProvider,
|
||||
objectSchemaSetter,
|
||||
} from '@cloudbeaver/core-connections';
|
||||
@@ -33,7 +34,7 @@ import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { Executor, ExecutorInterrupter, type IExecutionContextProvider } from '@cloudbeaver/core-executor';
|
||||
import { NavNodeInfoResource, NodeManagerUtils, objectNavNodeProvider } from '@cloudbeaver/core-navigation-tree';
|
||||
import { projectProvider, projectSetter, projectSetterState } from '@cloudbeaver/core-projects';
|
||||
import { resourceKeyList, type ResourceKeySimple, ResourceKeyUtils } from '@cloudbeaver/core-resource';
|
||||
import { getCachedMapResourceLoaderState, resourceKeyList, type ResourceKeySimple, ResourceKeyUtils } from '@cloudbeaver/core-resource';
|
||||
import type { NavNodeInfoFragment } from '@cloudbeaver/core-sdk';
|
||||
import { isArraysEqual } from '@cloudbeaver/core-utils';
|
||||
import { type ITab, type ITabOptions, NavigationTabsService, TabHandler } from '@cloudbeaver/plugin-navigation-tabs';
|
||||
@@ -95,6 +96,7 @@ export class SqlEditorTabService extends Bootstrap {
|
||||
projectProvider(this.getProjectId.bind(this)),
|
||||
connectionProvider(this.getConnectionId.bind(this)),
|
||||
objectCatalogProvider(this.getObjectCatalogId.bind(this)),
|
||||
objectLoaderProvider(this.getObjectLoader.bind(this)),
|
||||
objectSchemaProvider(this.getObjectSchemaId.bind(this)),
|
||||
executionContextProvider(this.getExecutionContext.bind(this)),
|
||||
projectSetter(this.setProjectId.bind(this)),
|
||||
@@ -182,9 +184,7 @@ export class SqlEditorTabService extends Bootstrap {
|
||||
const { projectId, connectionId, defaultCatalog, defaultSchema } = executionContext;
|
||||
const connectionKey = createConnectionParam(projectId, connectionId);
|
||||
|
||||
const connection = this.connectionInfoResource.get(connectionKey);
|
||||
|
||||
if (!connection?.connected) {
|
||||
if (!this.connectionInfoResource.isConnected(connectionKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,8 +209,6 @@ export class SqlEditorTabService extends Bootstrap {
|
||||
|
||||
const parents = this.navNodeInfoResource.getParents(nodeId);
|
||||
|
||||
untracked(() => this.navNodeInfoResource.load(nodeId!));
|
||||
|
||||
return {
|
||||
nodeId,
|
||||
path: parents,
|
||||
@@ -327,6 +325,34 @@ export class SqlEditorTabService extends Bootstrap {
|
||||
return createConnectionParam(context.projectId, context.connectionId);
|
||||
}
|
||||
|
||||
private getObjectLoader(tab: ITab<ISqlEditorTabState>) {
|
||||
const executionContextComputed = computed(() => this.sqlDataSourceService.get(tab.handlerState.editorId)?.executionContext);
|
||||
|
||||
const connectionKeyComputed = computed(() => {
|
||||
const executionContext = executionContextComputed.get();
|
||||
|
||||
if (!executionContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return createConnectionParam(executionContext.projectId, executionContext.connectionId);
|
||||
});
|
||||
|
||||
return [
|
||||
getCachedMapResourceLoaderState(this.connectionInfoResource, () => connectionKeyComputed.get()),
|
||||
getCachedMapResourceLoaderState(this.connectionExecutionContextResource, () => executionContextComputed.get()?.id || null),
|
||||
getCachedMapResourceLoaderState(this.containerResource, () => connectionKeyComputed.get()),
|
||||
// TODO: maybe we need it for this.getNavNode to work properly, but it's seems working without it
|
||||
// getCachedMapResourceLoaderState(this.navNodeInfoResource, () => {
|
||||
// if (this.containerResource.isLoadable(connectionKey)) {
|
||||
// return null;
|
||||
// }
|
||||
// console.log('node:', this.getNavNode(tab)?.nodeId || null);
|
||||
// return this.getNavNode(tab)?.nodeId || null;
|
||||
// }),
|
||||
];
|
||||
}
|
||||
|
||||
private getObjectCatalogId(tab: ITab<ISqlEditorTabState>) {
|
||||
const dataSource = this.sqlDataSourceService.get(tab.handlerState.editorId);
|
||||
const context = this.connectionExecutionContextResource.get(dataSource?.executionContext?.id ?? '');
|
||||
|
||||
Reference in New Issue
Block a user