diff --git a/webapp/packages/core-connections/src/ConnectionInfoResource.ts b/webapp/packages/core-connections/src/ConnectionInfoResource.ts index 814f18c8af5..dea1246fd3e 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 5177c901691..af3c9432f0e 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 64aaad0c470..b36a51f4a8d 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 93f49119c9d..676fbdce147 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 9c5efeb8c26..097b1ea6ef7 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 {