[% PROCESS common.tt %]

[% BLOCK renderNode %]
  <li>
    [% IF done.${node.path} %]
      <tt>[% node.name | html %]</tt> (<a [% HTML.attributes(href => "#" _ done.${node.path}) %]><em>repeated</em></a>)
    [% ELSE %]
      [% done.${node.path} = global.nodeId; global.nodeId = global.nodeId + 1; %]
      [% IF node.refs.size > 0 %]
        <a href="javascript:" class="tree-toggle"></a>
      [% END %]
      <span [% HTML.attributes(id => done.${node.path}) %]><span class="dep-tree-line">
        [% IF node.buildStep %]
          <a [% HTML.attributes(href => c.uri_for('/build' node.buildStep.get_column('build'))) %]><tt>[% node.name %]</tt></a> [%
            IF buildStepLogExists(node.buildStep);
              INCLUDE renderLogLinks url=c.uri_for('/build' node.buildStep.get_column('build') 'nixlog' node.buildStep.stepnr);
            END %]
        [% ELSE %]
          <tt>[% node.name | html %]</tt> (<em>no info</em>)
        [% END %]
      </span></span>
      [% IF isRoot %]
      <span class="dep-tree-buttons">
        (<a href="#" class="tree-collapse-all">collapse all</a>
        &ndash;
        <a href="#" class="tree-expand-all">expand all</a>)
      </span>
      [% END %]
      [% IF node.refs.size > 0 %]
        <ul class="subtree">
          [% FOREACH ref IN node.refs; INCLUDE renderNode node=ref isRoot=0; END %]
        </ul>
      [% END %]
    [% END %]
  </li>
[% END %]
