import { observer } from 'mobx-react-lite' ; import { useContext } from 'react' ; import styled from 'reshadow' ; import { TreeNodeNestedMessage , TREE_NODE_STYLES } from '@cloudbeaver/core-blocks' ; import { useService } from '@cloudbeaver/core-di' ; import { useStyles } from '@cloudbeaver/core-theming' ; import { NavNodeInfoResource } from '../../shared/NodesManager/NavNodeInfoResource' ; import type { NavTreeNodeComponent } from '../NavigationNodeComponent' ; import { TreeContext } from '../TreeContext' ; import { NavigationNode } from './NavigationNode' ; export const NavigationNodeElement = observer ( function NavigationNodeElement ( { nodeId , path , expanded , } ) { const context = useContext ( TreeContext ) ; const navNodeInfoResource = useService ( NavNodeInfoResource ) ; const styles = useStyles ( TREE_NODE_STYLES ) ; if ( context ?. tree . renderers ) { for ( const renderer of context . tree . renderers ) { const CustomRenderer = renderer ( nodeId ) ; if ( CustomRenderer ) { return < CustomRenderer nodeId = { nodeId } expanded = { expanded } component = { NavigationNodeElement } / > ; } } } const node = navNodeInfoResource . get ( nodeId ) ; if ( ! node ) { return styled ( styles ) ( < TreeNodeNestedMessage > Node not found < /TreeNodeNestedMessage>); } return < NavigationNode node = { node } path = { path } expanded = { expanded } component = { NavigationNodeElement } / > ; } ) ;