{% load i18n %}
{% load txcommontags %}
{% load permissions %}
{% get_permission "project_perm.maintain" for request.user and project as "is_maintainer" %}

<div id="components" class="components">

  <div class="editlinks">
  <p><a class="simlink" href="{% url project_feed param=project.slug %}" title="Project feed"><img border="0" src="{{ MEDIA_URL }}images/icons/feed.png" /></a></p>
  {% if perms.projects.add_component or is_maintainer %}
    <p><a class="i16 add buttonized" href="{% url component_create project_slug=project.slug %}">{% trans "Add" %}</a></p>
  {% endif %}
  </div>

  {% with project.component_set.all as components %}
  <h3>{% blocktrans count components|length as counter %}Project Component{% plural %}Project Components{% endblocktrans %}
    {% render_metacount components _("components") %}
  </h3>

  {% if components %}
  <div class="component_list">
  {% for comp in components|slice:"0:6" %}
    <div class="entry">
      <p class="name"><a href="{{ comp.get_absolute_url }}">{{ comp.name }}</a>
      <sup class="entry_metalink">
       {% if perms.projects.change_component or is_maintainer %}
         <a href="{% url component_edit project_slug=project.slug component_slug=comp.slug %}">{% trans "edit" %}</a>
       {% endif %}
       {% if perms.projects.delete_component or is_maintainer %}
         , <a href="{% url component_delete project_slug=project.slug component_slug=comp.slug %}">{% trans "del" %}</a>
       {% endif %}
      </sup>
      </p>
      <p class="description">{{ comp.description|truncatewords:"10" }}</p></li>
    </div>
    {% endfor %}
  </div>
  {% if components|slice:"6:" %}<p class="more">
  More components:  
  {% for comp in components|slice:"6:" %}
    <a href="{{ comp.get_absolute_url }}">{{ comp.name }}</a>{% if not forloop.last %},{% endif %}
  {% endfor %}
  </p>
  {% endif %}
  {% else %}
  <p>{% trans "No components are registered for this project yet." %}
    {% if perms.projects.add_component or is_maintainer %}
    <a href="{% url component_create project_slug=project.slug %}">{% trans "Add one!" %}</a>
    {% endif %}
  </p>
    {% endif %}
  {% endwith %}
  <p class="i16 tip compact clear">
    {% blocktrans %}<em>Components</em> are smaller, self-contained parts of a larger project which consist of actual files.
    Examples of components of a software project could be "UI" and "Docs" or development branches like <code>HEAD</code>.{% endblocktrans %}</em>
  </p>
</div>
