<commit_before>var $$ = React.createElement;

var _ = require("substance/helpers");

// Tree Node Component
// ---------------

var TreeNode = React.createClass({
  displayName: "TreeNode",

  handleToggle: function(e) {
    var node = this.props.node;
    node.handleToggle(node.id);
    e.preventDefault();
  },

  render: function() {
    var node = this.props.node;
    var treeComp = this.props.treeComp;
    var tree = treeComp.props.tree;
    var childNodes = tree.getChildren(node.id);

    var childrenEls = [];
    
    childrenEls = childNodes.map(function(node) {
      return $$(TreeNode, {
        treeComp: treeComp,
        key: node.id,
        node: node
      });
    }.bind(this));

    _.each(this.props.children, function(childNode) {
      childrenEls($$(TreeNode, {
        node: childNode
      }));
    });

    return $$("div", {className: 'tree-node'+ (node.active ? ' selected' : '')},
      $$('a', {
        href: "#",
        className: 'name',
        "data-id": node.id,
        onClick: this.handleToggle,
      }, node.name),
      $$('div', {className: 'children'}, childrenEls)
    );
  }
});

// Tree Component
// ---------------<commit_msg>use subjects work names inside writer's to<commit_after>var $$ = React.createElement;

var _ = require("substance/helpers");

// Tree Node Component
// ---------------

var TreeNode = React.createClass({
  displayName: "TreeNode",

  handleToggle: function(e) {
    var node = this.props.node;
    node.handleToggle(node.id);
    e.preventDefault();
  },

  render: function() {
    var node = this.props.node;
    var treeComp = this.props.treeComp;
    var tree = treeComp.props.tree;
    var childNodes = tree.getChildren(node.id);

    var childrenEls = [];
    
    childrenEls = childNodes.map(function(node) {
      return $$(TreeNode, {
        treeComp: treeComp,
        key: node.id,
        node: node
      });
    }.bind(this));

    _.each(this.props.children, function(childNode) {
      childrenEls($$(TreeNode, {
        node: childNode
      }));
    });

    return $$("div", {className: 'tree-node'+ (node.active ? ' selected' : '')},
      $$('a', {
        href: "#",
        className: 'name',
        "data-id": node.id,
        onClick: this.handleToggle,
      }, node.workname),
      $$('div', {className: 'children'}, childrenEls)
    );
  }
});

// Tree Component
// ---------------
{'fraction_non_alphanumeric': 0.1893021312160468, 'fraction_numerical': 0.0, 'mean_word_length': 2.274965800273598, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7141565', 'n_tokens_mistral': 754, 'n_tokens_neox': 748, 'n_words': 150}