import { observer } from "mobx-react" ; import * as React from "react" ; import { TreeElement } from "../../classes/TreeElement" ; import { lazyInject } from "../../inversify.config" ; import SelectedElementService from "../../services/SelectedElementService" ; import SceneStore from "../../stores/SceneStore" ; /**
 * Currently used for an example use of selected scene object store.
 */ @ observer export default class ParentElement extends React . Component < Record < string , unknown > , any > { @ lazyInject ( "SceneStore" ) private readonly sceneStore ! : SceneStore ; @ lazyInject ( "SelectedElementService" ) private readonly selectedElementService ! : SelectedElementService ; public render ( ) { const selectedElement = this . selectedElementService . getSelectedElement ( ) ; if ( selectedElement !== null ) { const parent = this . getParentElement ( selectedElement ) ; if ( parent === null || typeof parent === "undefined" ) { return < div className = "select-parent" / > ; } const myParent = parent ; return ( < div className = "select-parent" > < span onClick = { ( ) => { this . sceneStore . selectedObjectKey = myParent . key ; } } > { myParent . name } < /span> < /div>); } else { return < div > < /div>; } } private getParentElement ( element ) { if ( element && element . parent ) { if ( element . isFile ( ) ) { return this . getParentElement ( element . parent ) ; } else { return element . parent ; } } return null ; } }