Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"validate-dependencies": "core-cli-validate-dependencies"
},
"dependencies": {
"@cloudbeaver/core-connections": "workspace:*",
"@cloudbeaver/core-data-context": "workspace:*",
"@cloudbeaver/core-di": "workspace:*",
"@cloudbeaver/core-localization": "workspace:*",
"@cloudbeaver/core-navigation-tree": "workspace:*",
"@cloudbeaver/core-view": "workspace:*",
"@cloudbeaver/plugin-datasource-context-switch": "workspace:*",
"@cloudbeaver/plugin-navigation-tree": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
/*
* 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.
*/

import type { IDataContextProvider } from '@cloudbeaver/core-data-context';
import { NavigationTreeService, DATA_CONTEXT_ELEMENTS_TREE, MENU_ELEMENTS_TREE_TOOLS } from '@cloudbeaver/plugin-navigation-tree';
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
import { ActionService, type IAction, KeyBindingService, MenuService } from '@cloudbeaver/core-view';
import { ConnectionInfoResource } from '@cloudbeaver/core-connections';
import { NavNodeInfoResource } from '@cloudbeaver/core-navigation-tree';
import { ConnectionSchemaManagerService } from '@cloudbeaver/plugin-datasource-context-switch';

import { ACTION_LINK_OBJECT } from './ACTION_LINK_OBJECT.js';
import { KEY_BINDING_LINK_OBJECT } from './KEY_BINDING_LINK_OBJECT.js';

@injectable(() => [ActionService, KeyBindingService, NavigationTreeService, ConnectionSchemaManagerService, MenuService])
@injectable(() => [
ActionService,
KeyBindingService,
NavigationTreeService,
ConnectionSchemaManagerService,
MenuService,
ConnectionInfoResource,
NavNodeInfoResource,
])
export class ObjectViewerNavTreeLinkMenuService extends Bootstrap {
constructor(
private readonly actionService: ActionService,
private readonly keyBindingService: KeyBindingService,
private readonly navigationTreeService: NavigationTreeService,
private readonly connectionSchemaManagerService: ConnectionSchemaManagerService,
private readonly menuService: MenuService,
private readonly connectionInfoResource: ConnectionInfoResource,
private readonly navNodeInfoResource: NavNodeInfoResource,
) {
super();
}

override register() {

Check warning on line 42 in webapp/packages/plugin-object-viewer-nav-tree-link/src/ObjectViewerNavTreeLinkMenuService.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Missing return type on function
this.navigationTreeService.registerAction(ACTION_LINK_OBJECT);

this.actionService.addHandler({
Expand All @@ -36,9 +49,8 @@
isHidden: context => {
const tree = context.get(DATA_CONTEXT_ELEMENTS_TREE)!;

const navNode = this.connectionSchemaManagerService.activeNavNode;
const nodeInTree = navNode?.path.includes(tree.baseRoot);
return !nodeInTree;
const { path } = this.getActiveNode(tree.baseRoot);
return !path?.includes(tree.baseRoot);
},
handler: this.elementsTreeActionHandler.bind(this),
});
Expand Down Expand Up @@ -79,14 +91,37 @@
for (const loader of this.connectionSchemaManagerService.currentObjectLoaders) {
await loader.load();
}
const navNode = this.connectionSchemaManagerService.activeNavNode;

if (navNode) {
await this.navigationTreeService.showNode(navNode.nodeId, navNode.path);
const { id, path } = this.getActiveNode(tree.baseRoot);

if (id && path) {
await this.navigationTreeService.showNode(id, path);
}

break;
}
}
}

private getActiveNode(baseRoot: string): {
id: string | undefined;
path: string[] | undefined;
} {
const navNode = this.connectionSchemaManagerService.activeNavNode;
const activeConnectionKey = this.connectionSchemaManagerService.activeConnectionKey;

let id = navNode?.nodeId;
let path = navNode?.path;

if (!path?.includes(baseRoot) && activeConnectionKey) {
const connection = this.connectionInfoResource.get(activeConnectionKey);

if (connection?.nodePath && connection.connected) {
id = connection.nodePath;
path = this.navNodeInfoResource.getParents(connection.nodePath);
}
}

return { id, path };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
{
"path": "../core-cli"
},
{
"path": "../core-connections"
},
{
"path": "../core-data-context"
},
Expand All @@ -19,6 +22,9 @@
{
"path": "../core-localization"
},
{
"path": "../core-navigation-tree"
},
{
"path": "../core-view"
},
Expand Down
2 changes: 2 additions & 0 deletions webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3743,9 +3743,11 @@ __metadata:
resolution: "@cloudbeaver/plugin-object-viewer-nav-tree-link@workspace:packages/plugin-object-viewer-nav-tree-link"
dependencies:
"@cloudbeaver/core-cli": "workspace:*"
"@cloudbeaver/core-connections": "workspace:*"
"@cloudbeaver/core-data-context": "workspace:*"
"@cloudbeaver/core-di": "workspace:*"
"@cloudbeaver/core-localization": "workspace:*"
"@cloudbeaver/core-navigation-tree": "workspace:*"
"@cloudbeaver/core-view": "workspace:*"
"@cloudbeaver/plugin-datasource-context-switch": "workspace:*"
"@cloudbeaver/plugin-navigation-tree": "workspace:*"
Expand Down
Loading