From 9e682617e60c86542eae9be6f82fe304febc8575 Mon Sep 17 00:00:00 2001 From: Sychev Andrey <44414066+SychevAndrey@users.noreply.github.com> Date: Thu, 23 Jul 2026 17:33:26 +0200 Subject: [PATCH] dbeaver/pro#9638 [CB] refresh is needed to see replaced connectionfolder in another instance (#4464) * dbeaver/pro#9638 fix: update project filtering logic to use project IDs for active projects Changed all four spots from reference equality to id comparison, matching the rest of the codebase, see https://github.com/dbeaver/cloudbeaver/issues/4430 * dbeaver/pro#9638 refactor(connectionUpdateHandler): move node to a new parent on change * dbeaver/pro#9638 revert commit eb2ba7871e5de3155144183e9be6d08053e2460d * dbeaver/pro#9638 fix: update node parents on move in other session Server events don't carry the actual data, so besides outdating (which lets the handlers invalidate the previous state, e.g. the old location in the navigation tree) we explicitly load the connection to guarantee that the handlers receive the actual state * dbeaver/pro#9638 fix: sync connection folder move from another session * dbeaver/pro#9638 fix: revert back connectionUpdateHandler * dbeaver/pro#9638 fix: remove try catch --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../src/ConnectionInfoResource.ts | 34 ++++++++++++++++--- .../navigationTreeProjectFilter.ts | 4 +-- ...navigationTreeProjectsExpandStateGetter.ts | 4 +-- .../navigationTreeProjectFilter.ts | 2 +- ...navigationTreeProjectsExpandStateGetter.ts | 4 +-- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/webapp/packages/core-connections/src/ConnectionInfoResource.ts b/webapp/packages/core-connections/src/ConnectionInfoResource.ts index 814f18c8af..dea1246fd3 100644 --- a/webapp/packages/core-connections/src/ConnectionInfoResource.ts +++ b/webapp/packages/core-connections/src/ConnectionInfoResource.ts @@ -96,7 +96,7 @@ export class ConnectionInfoResource extends CachedMapResource>( ServerEventId.CbDatasourceUpdated, key => { - if (this.isConnected(key)) { + if (this.isConnected(key) && !this.isOutdated(key)) { const connection = this.get(key); this.dataSynchronizationService .requestSynchronization('connection', connection.map(connection => connection?.name).join('\n')) .then(state => { if (state) { - this.markOutdated(key); + this.updateFromEvent(key); } }); } else { - this.markOutdated(key); + this.updateFromEvent(key); } }, data => @@ -297,6 +297,32 @@ export class ConnectionInfoResource extends CachedMapResource connection?.connected ?? false); } + private async updateFromEvent(key: ResourceKeyList): Promise { + for (const connectionKey of key) { + const currentConnection = this.get(connectionKey); + const newConnection = await this.refresh(connectionKey); + + if (currentConnection?.nodePath !== newConnection?.nodePath) { + if (currentConnection?.nodePath) { + const parent = this.navNodeInfoResource.getParent(currentConnection.nodePath); + + if (parent) { + this.navTreeResource.markOutdated(parent); + } + } + + if (newConnection?.nodePath) { + await this.navNodeInfoResource.loadNodeParents(newConnection.nodePath); + const parent = this.navNodeInfoResource.getParent(newConnection.nodePath); + + if (parent) { + this.navTreeResource.markOutdated(parent); + } + } + } + } + } + getConnectionIdForNodeId(projectId: string, nodeId: string): IConnectionInfoParams | undefined { if (!NodeManagerUtils.isDatabaseObject(nodeId)) { return; diff --git a/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectFilter.ts b/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectFilter.ts index 5177c90169..af3c9432f0 100644 --- a/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectFilter.ts +++ b/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectFilter.ts @@ -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. @@ -63,7 +63,7 @@ export function navigationTreeProjectFilter( if (isRMProjectNode(node)) { const project = projectsNavNodeService.getProject(node.uri); - if (!project || !projectsService.activeProjects.includes(project)) { + if (!project || !projectsService.activeProjects.some(({ id }) => id === project.id)) { return false; } diff --git a/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts b/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts index 64aaad0c47..b36a51f4a8 100644 --- a/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts +++ b/webapp/packages/plugin-navigation-tree-rm/src/Tree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 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. @@ -25,7 +25,7 @@ export function navigationTreeProjectsExpandStateGetter( let active = false; const project = projectsNavNodeService.getByNodeId(nodeId); if (project) { - active = projectsService.activeProjects.includes(project); + active = projectsService.activeProjects.some(({ id }) => id === project.id); } return { diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectFilter.ts b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectFilter.ts index 93f49119c9..676fbdce14 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectFilter.ts +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectFilter.ts @@ -37,7 +37,7 @@ export function navigationTreeProjectFilter( if (isProjectNode(node)) { const project = projectsNavNodeService.getProject(node.uri); - if (!project || !projectsService.activeProjects.includes(project)) { + if (!project || !projectsService.activeProjects.some(({ id }) => id === project.id)) { return false; } diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts index 9c5efeb8c2..097b1ea6ef 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ProjectsRenderer/navigationTreeProjectsExpandStateGetter.ts @@ -1,6 +1,6 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 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. @@ -25,7 +25,7 @@ export function navigationTreeProjectsExpandStateGetter( let active = false; const project = projectsNavNodeService.getByNodeId(nodeId); if (project) { - active = projectsService.activeProjects.includes(project); + active = projectsService.activeProjects.some(({ id }) => id === project.id); } return {