renderTree()

in frontend/src/js/components/UtilComponents/TreeBrowser/index.tsx [165:228]


    renderTree(sortedEntries: Tree<T>) {
        return <React.Fragment>
            {sortedEntries.map((e, i) => {
                // Used to set the tab index on the first node
                const isFirst = i === 0;

                if (isTreeNode<T>(e)) {
                    return (
                        <Node
                            key={e.id}
                            ref={n => {if (n !== null) this.childReactComponents.push(n);}}

                            entry={e}
                            index={i}
                            depth={0}
                            isFirst={isFirst}
                            focusSibling={this.focusEntry}

                            // selectedEntries because these can be nodes or leaves
                            selectedEntries={this.props.selectedEntries}
                            focusedEntry={this.props.focusedEntry}
                            // expandedNodes because leaves can't be expanded but the LazyTreeBrowser does
                            // mark them as expanded in anticipation of them loading and becoming nodes
                            expandedNodes={this.props.expandedEntries.filter(isTreeNode)}

                            onFocus={this.props.onFocus}
                            onSelectLeaf={this.props.onSelectLeaf}
                            onExpandLeaf={this.props.onExpandLeaf}
                            clearFocus={this.props.clearFocus}
                            onExpand={this.props.onExpandNode}
                            onCollapse={this.props.onCollapseNode}
                            onDrop={this.onDrop}
                            onContextMenu={this.props.onContextMenu}

                            columnsConfig={this.props.columnsConfig}
                        />
                    );
                } else {
                    return (
                        <Leaf
                            key={e.id}
                            ref={l => {if (l !== null) this.childReactComponents.push(l);}}

                            entry={e}
                            index={i}
                            depth={0}
                            isFirst={isFirst}
                            focusSibling={this.focusEntry}

                            selectedEntries={this.props.selectedEntries}
                            focusedEntry={this.props.focusedEntry}

                            onFocus={this.props.onFocus}
                            onSelect={this.props.onSelectLeaf}
                            onExpand={this.props.onExpandLeaf}
                            onContextMenu={this.props.onContextMenu}

                            columnsConfig={this.props.columnsConfig}
                        />
                    );
                }
            })}
        </React.Fragment>
    }