diff --git a/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts b/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts index 0658f617cc..fdf3c3b743 100644 --- a/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts +++ b/webapp/packages/core-app/src/shared/NodesManager/NavTreeResource.ts @@ -14,11 +14,18 @@ import { isResourceKeyList, ResourceKeyList, resourceKeyList, - NavNodeChildrenQuery + NavNodeChildrenQuery as fake } from '@cloudbeaver/core-sdk'; import { NavNodeInfoResource } from './NavNodeInfoResource'; +// TODO: so much dirty +export interface NodePath { + parentPath: string; +} + +type NavNodeChildrenQuery = fake & NodePath; + @injectable() export class NavTreeResource extends CachedMapResource { constructor( @@ -179,7 +186,7 @@ export class NavTreeResource extends CachedMapResource { private setNavObject(data: NavNodeChildrenQuery | NavNodeChildrenQuery[]) { if (Array.isArray(data)) { this.navNodeInfoResource.set( - resourceKeyList(data.map(data => data.navNodeInfo.id)), + resourceKeyList(data.map(data => data.parentPath)), data.map(data => this.navNodeInfoResource.navNodeInfoToNavNode(data.navNodeInfo)).flat() ); @@ -187,27 +194,27 @@ export class NavTreeResource extends CachedMapResource { resourceKeyList(data.map(data => data.navNodeChildren.map(node => node.id)).flat()), data.map( data => data.navNodeChildren.map( - node => this.navNodeInfoResource.navNodeInfoToNavNode(node, data.navNodeInfo.id) + node => this.navNodeInfoResource.navNodeInfoToNavNode(node, data.parentPath) ) ).flat() ); this.set( - resourceKeyList(data.map(data => data.navNodeInfo.id)), + resourceKeyList(data.map(data => data.parentPath)), data.map(data => data.navNodeChildren.map(node => node.id)) ); } else { this.navNodeInfoResource.set( - data.navNodeInfo.id, + data.parentPath, this.navNodeInfoResource.navNodeInfoToNavNode(data.navNodeInfo) ); this.navNodeInfoResource.set( resourceKeyList(data.navNodeChildren.map(node => node.id)), - data.navNodeChildren.map(node => this.navNodeInfoResource.navNodeInfoToNavNode(node, data.navNodeInfo.id)) + data.navNodeChildren.map(node => this.navNodeInfoResource.navNodeInfoToNavNode(node, data.parentPath)) ); - this.set(data.navNodeInfo.id, data.navNodeChildren.map(node => node.id)); + this.set(data.parentPath, data.navNodeChildren.map(node => node.id)); } } @@ -216,6 +223,6 @@ export class NavTreeResource extends CachedMapResource { parentPath, }); - return { navNodeChildren, navNodeInfo }; + return { navNodeChildren, navNodeInfo, parentPath }; } }