[% BLOCK renderLogButtons %]
<a class="btn btn-secondary btn-sm" [% HTML.attributes(href => url) %]>pretty</a>
<a class="btn btn-secondary btn-sm" [% HTML.attributes(href => url _ "/raw") %]>raw</a>
<a class="btn btn-secondary btn-sm" [% HTML.attributes(href => url _ "/tail") %]>tail</a>
[% END %]

[% BLOCK renderOutputs %]
  [% start=1; FOREACH output IN outputs %]
    [% IF !start %],<br/>[% END; start=0; output.path %]
  [% END %]
[% END %]

[% BLOCK renderOutputsTable %]
  <table class="info-table">
    [% FOREACH output IN outputs %]
      <tr>
        <th><tt>[% output.name | html %]</tt></th>
        <td><tt>[% IF output.path; output.path | html; ELSE %]<em>n/a</em>[% END %]</tt></td>
      </tr>
    [% END %]
  </table>
[% END; %]

[% BLOCK renderStepDuration %]
  [% IF step.busy == 0 %]
    [% IF step.stoptime %]
      [% INCLUDE renderDuration duration = step.stoptime - step.starttime %]
    [% ELSE %]
      <em>n/a</em>
    [% END %]
  [% ELSIF build.finished %]
    [% INCLUDE renderDuration duration = build.stoptime - step.starttime %]
  [% ELSE %]
    [% INCLUDE renderDuration duration = curTime - step.starttime %]
  [% END %]
[% END %]

[% BLOCK renderStepMachine %]
  [% IF step.busy != 0 || ((step.machine || step.starttime) && (step.status == 0 || step.status == 1 || step.status == 3 || step.status == 4 || step.status == 7)) %]
    [% INCLUDE renderMachineName machine=step.machine %]
  [% ELSE %]
    <em>n/a</em>
  [% END %]
[% END %]

[% BLOCK renderStepStatus %]
  [% IF step.busy != 0 %]
    [% INCLUDE renderBusyStatus %]
  [% ELSIF step.status == 0 %]
    [% IF step.isnondeterministic %]
      <span class="warn">Succeeded with non-determistic result</span>
    [% ELSE %]
      Succeeded
    [% END %]
    [% IF step.timesbuilt && step.timesbuilt > 1 %]
      ([% step.timesbuilt %] times)
    [% END %]
  [% ELSIF step.status == 3 %]
    <span class="error">Aborted</span>[% IF step.errormsg %]: <em>[% HTML.escape(step.errormsg) %]</em>[% END %]
  [% ELSIF step.status == 4 %]
    <span class="error">Cancelled</span>
  [% ELSIF step.status == 7 %]
    <span class="error">Timed out</span>
  [% ELSIF step.status == 8 %]
    <span class="error">Cached failure</span>
  [% ELSIF step.status == 9 %]
    <span class="error">Unsupported system type</span>
  [% ELSIF step.status == 10 %]
    <span class="error">Log limit exceeded</span>
  [% ELSIF step.status == 11 %]
    <span class="error">Output limit exceeded</span>
  [% ELSIF step.status == 12 %]
    <span class="error">Non-determinism detected</span>[% IF step.timesbuilt %] after [% HTML.escape(step.timesbuilt) %] times[% END %]
  [% ELSIF step.status == 13 %]
    <span class="text-muted"><em>Resolved</em></span>
    [% t = resolvedTerminals.${step.stepnr};
       IF t %]
      -- resolved to [%+ INCLUDE renderBuildIdLink id=t.get_column('build') %], step #[% HTML.escape(t.stepnr) %]
      [% IF t.busy != 0 %]
        (<em>Running</em>)
      [% ELSIF t.status == 0 %]
        (Succeeded)
      [% ELSE %]
        (<span class="error">Failed</span>)
      [% END;
     ELSIF step.resolveddrvpath; %]
      -- resolved drv <tt>[% HTML.escape(step.resolveddrvpath) %]</tt> not yet scheduled
    [% END %]
  [% ELSIF step.errormsg %]
    <span class="error">Failed</span>: <em>[% HTML.escape(step.errormsg) %]</em>
  [% ELSE %]
    <span class="error">Failed</span>
  [% END %]
[% END %]
