{% load i18n %}
{% load url from future %}
{% with object.git_needs_commit as needs_commit %}

<div class="row">
<div class="col-lg-6">

<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Repository status" %}</h4></div>
<div class="panel-body">
{% if needs_commit %}
<p>{% trans "There are some not committed changes!" %}</p>
{% endif %}
{% if object.git_needs_merge %}
<p>{% trans "The remote repository needs to be merged!" %}</p>
{% endif %}
{% if object.git_needs_push %}
<p>{% trans "There are some new commits in the local repository!" %}</p>
{% endif %}
{% if not needs_commit and not object.git_needs_merge and not object.git_needs_push %}
<p>{% trans "The local repository is up to date." %}</p>
{% endif %}

{% if object.subproject_set %}
{% else %}
{% with object.get_last_remote_commit as commit %}
<p>
{% trans "Last remote commit:" %}
{% include "git-commit-info.html" %}
</p>
{% endwith %}
{% with object.get_export_url as export_url %}
{% if export_url %}
<p>
{% trans "Git repository with Weblate translations:" %}
<code class="git-repo ui-corner-all">{{ export_url }}</code>
</p>
{% endif %}
{% endwith %}
{% endif %}
</div>
</div>

<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Repository details" %}</h4></div>
      <div class="panel-body">
        {% if object.subproject_set %}
        {% for sp in object.subproject_set.all %}
        <h4>{{ sp }}</h3>
        <pre>{{ sp.repository.status }}</pre>
        {% endfor %}
        {% else %}
        <pre>{{ object.repository.status }}</pre>
        {% endif %}
      </div>
</div>

</div>

<div class="col-lg-6">
{% if perms.trans.commit_translation or perms.trans.update_translation %}
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Repository tools" %}</h4></div>
<div class="panel-body">

<table class="table table-condensed">

<tr>
<td>
<a href="{{ object.get_commit_url }}" class="btn btn-default{% if not needs_commit %} disabled{% endif %}">{% trans "Commit" %}</a>
</td>
<td>
<p class="helptext">{% trans "Commit pending changes to the local repository" %}</p>
</td>
</tr>

<tr>
<td>
<a href="{{ object.get_update_url }}" class="btn btn-default{% if not perms.trans.update_translation %} disabled{% endif %}">{% trans "Pull" %}</a>
</td>
<td>
<p class="helptext">{% trans "Pull changes from the remote repository" %}</p>
</td>
</tr>
<tr>
<td>
<a href="{{ object.get_push_url }}" class="btn btn-default{% if not perms.trans.push_translation or not object.can_push %} disabled{% endif %}">{% trans "Push" %}</a>
</td>
<td>
<p class="helptext">{% trans "Push changes to the remote repository" %}</p>
</td>
</tr>
<tr>
<td>
<a href="{{ object.get_update_url }}?method=rebase" class="btn btn-default{% if not perms.trans.update_translation %} disabled{% endif %}">{% trans "Rebase" %}</a>
</td>
<td>
<p class="helptext">{% trans "Rebase local changes onto the remote repository" %}</p>
</td>
</tr>
{% if perms.trans.reset_translation %}
<tr>
<td>
<a href="{{ object.get_reset_url }}" class="btn btn-default confirm-reset">{% trans "Reset" %}</a>
</td>
<td>
<p class="helptext">{% trans "Reset all changes in the local repository" %}</p>
</td>
</tr>
{% endif %}


{% if perms.trans.lock_subproject and object.is_lockable %}
{% if object.locked %}
<tr>
<td>
<a href="{{ object.get_unlock_url }}" class="btn btn-default">{% trans "Unlock" %}</a>
</td>
<td>
<p class="helptext">{% trans "Allow changes in the local repository" %}</p>
</td>
</tr>
{% else %}
<tr>
<td>
<a href="{{ object.get_lock_url }}" class="btn btn-default">{% trans "Lock" %}</a>
</td>
<td>
<p class="helptext">{% trans "Prevent any changes in the local repository" %}</p>
</td>
</tr>
{% endif %}
{% endif %}


</table>

</div>

{% endif %}
</div>
</div>
{% endwith %}
