mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-object-viewer): disconnect behavior
This commit is contained in:
@@ -23,9 +23,10 @@ export class ConnectionInfoResource extends CachedMapResource<string, Connection
|
||||
}
|
||||
|
||||
async init(id: string, credentials?: any): Promise<Connection> {
|
||||
await this.performUpdate(id, async () => {
|
||||
const connection = await this.performUpdate(id, async () => {
|
||||
const connection = await this.setActivePromise(id, this.initConnection(id, credentials));
|
||||
this.set(id, connection);
|
||||
return connection;
|
||||
});
|
||||
|
||||
return this.get(id)!;
|
||||
|
||||
+15
-2
@@ -11,7 +11,7 @@ import { Subject } from 'rxjs';
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
import { NotificationService } from '@cloudbeaver/core-events';
|
||||
import { SessionResource } from '@cloudbeaver/core-root';
|
||||
import { DataSourceInfo } from '@cloudbeaver/core-sdk';
|
||||
import { DataSourceInfo, isResourceKeyList } from '@cloudbeaver/core-sdk';
|
||||
|
||||
import { ROOT_NODE_PATH } from '../NodesManager/NavNodeInfoResource';
|
||||
import { NavNodeManagerService } from '../NodesManager/NavNodeManagerService';
|
||||
@@ -35,13 +35,26 @@ export class ConnectionsManagerService {
|
||||
private notificationService: NotificationService
|
||||
) {
|
||||
this.sessionResource.onDataUpdate.subscribe(this.restoreConnections.bind(this));
|
||||
this.connectionInfo.onItemAdd.subscribe(async (key) => {
|
||||
if (isResourceKeyList(key)) {
|
||||
for (const id of key.list) {
|
||||
const nodeId = NodeManagerUtils.connectionIdToConnectionNodeId(id);
|
||||
this.navNodeManagerService
|
||||
.markTreeOutdated(nodeId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const nodeId = NodeManagerUtils.connectionIdToConnectionNodeId(key);
|
||||
this.navNodeManagerService
|
||||
.markTreeOutdated(nodeId);
|
||||
});
|
||||
}
|
||||
|
||||
async addOpenedConnection(connection: Connection) {
|
||||
this.addConnection(connection);
|
||||
|
||||
const nodeId = NodeManagerUtils.connectionIdToConnectionNodeId(connection.id);
|
||||
await this.navNodeManagerService.loadNode({ nodeId, parentId: ROOT_NODE_PATH });
|
||||
await this.navNodeManagerService.refreshNode(nodeId);
|
||||
|
||||
this.navNodeManagerService.navTree.unshiftToNode(ROOT_NODE_PATH, [nodeId]);
|
||||
}
|
||||
|
||||
@@ -121,10 +121,15 @@ export class NavNodeManagerService {
|
||||
await this.graphQLService.gql.navRefreshNode({
|
||||
nodePath: navNodeId,
|
||||
});
|
||||
this.navTree.markOutdated(resourceKeyList(this.navTree.getNestedChildren(navNodeId)));
|
||||
this.markTreeOutdated(navNodeId);
|
||||
await this.navTree.refresh(navNodeId);
|
||||
}
|
||||
|
||||
markTreeOutdated(navNodeId: string) {
|
||||
const nodes = [navNodeId, ...this.navTree.getNestedChildren(navNodeId)];
|
||||
this.navTree.markOutdated(resourceKeyList(nodes));
|
||||
}
|
||||
|
||||
async updateRootChildren() {
|
||||
if (!await this.permissionsService.hasAsync(EPermission.public)) {
|
||||
this.navTree.delete(ROOT_NODE_PATH);
|
||||
|
||||
@@ -50,6 +50,19 @@ export class Entity {
|
||||
}
|
||||
}
|
||||
|
||||
removeAll() {
|
||||
const ids: string[] = [];
|
||||
|
||||
for (const [key, value] of this.children) {
|
||||
ids.push(key);
|
||||
value.destroyEntity();
|
||||
}
|
||||
|
||||
for (const id of ids) {
|
||||
this.children.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
getChild(id: string): Entity | undefined {
|
||||
return this.children.get(id);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ const stylesArray = [styles];
|
||||
export const ObjectViewerPanel = observer(function ObjectViewerPanel({
|
||||
tab, handler,
|
||||
}: TabHandlerPanelProps<IObjectViewerTabState>) {
|
||||
const { children, isLoading } = useChildren(tab.handlerState.objectId);
|
||||
const { children, isOutdated, isLoading } = useChildren(tab.handlerState.objectId);
|
||||
const dbObjectPagesService = useService(DBObjectPageService);
|
||||
const pages = dbObjectPagesService.orderedPages;
|
||||
|
||||
if (!children && isLoading) {
|
||||
if (!isOutdated && isLoading) {
|
||||
return <Loader />;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,8 +220,8 @@ export class ObjectViewerTabService {
|
||||
nodeId: tab.handlerState.objectId,
|
||||
parentId: tab.handlerState.parentId,
|
||||
});
|
||||
const children = await this.navNodeManagerService.loadTree(tab.handlerState.objectId);
|
||||
await this.dbObjectService.load(tab.handlerState.objectId);
|
||||
const children = await this.navNodeManagerService.loadTree(tab.handlerState.objectId);
|
||||
|
||||
const folderId = tab.handlerState.folderId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user