{% extends "layout.html" %}
{% block sidebar %}{% include "cupboard/sidebar.html" %}{% endblock %}
{% from "run_util.html" import display_result_code, display_publish_result_code %}
{% block page_title %}Cupboard - Publish History{% endblock %}
{% block body %}
 <div class="section" id="publish-history">
<h1>Publish History</h1>

{% if is_admin %}
<button id="scan">Refresh Merge Proposal Status</button>
<button id="autopublish">Automatically Publish</button>

<script>
$(document).ready(function(){
	$("#scan").click(function(){ $.post("/api/publish/scan"); });
	$("#autopublish").click(function(){ $.post("/api/publish/autopublish"); });
});
</script>
{% endif %}
<p>Last {{ count }} publish actions:</p>
<table class="docutils" border="1">
<colgroup>
<col width="6%">
<col width="10%">
<col width="6%">
<col width="4%">
<col width="49%">
</colgroup>
<thead valign="bottom">
<tr class="row-odd">
<th class="head">Time</th>
<th class="head">Package</th>
<th class="head">Branch Name</th>
<th class="head">Mode</th>
<th class="head">Result</th>
</tr>
</thead>
<tbody valign="top">
{% for id, timestamp, package, branch_name, mode, merge_proposal_url, result_code, description, vcs_browser in history %}
<tr class="row-even">
	<td><a href="{{ id }}">{{ format_timestamp(timestamp) }}</a></td>
<td><a class="reference external" href="../pkg/{{ package }}">{{ package }}</a></td>
<td>{{ branch_name }}</td>
<td>{{ mode }}</td>
<td>{{ display_publish_result_code(result_code) }}: {% if '\n' in description %}<pre>{{ description }}</pre>{% else %}{{ description }}{% endif %}
{% if mode == 'propose' %}{% if merge_proposal_url %} - <a href="{{ merge_proposal_url }}">Merge Proposal</a> (<a href="../merge-proposal?url={{ merge_proposal_url|urlencode }}">Info</a>){% endif %}{% endif %}
{% if mode == 'push' and result_code == 'success' %}{% if vcs_browser %} - <a href="{{ vcs_browser }}">Branch</a>{% endif %}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
