{% load rules %}

{% has_perm 'bgjobs.can_clear_own_jobs' request.user project as can_clear_own_jobs %}
{% has_perm 'bgjobs.can_clear_all_jobs' request.user project as can_clear_all_jobs %}

<div class="btn-group ml-auto" id="sodar-bg-buttons-list">
  <button class="btn btn-primary dropdown-toggle"
          type="button" data-toggle="dropdown"
          aria-haspopup="true" aria-expanded="false">
    Job Operations
  </button>
  <div class="dropdown-menu dropdown-menu-right">

    {# Clear owned jobs #}
    {% if can_clear_own_jobs %}
      <a class="dropdown-item text-danger"
         href="{% url 'bgjobs:clear_own' project=project.sodar_uuid %}">
        <i class="iconify" data-icon="mdi:delete"></i> Clear Own Jobs
      </a>
    {% endif %}

    {# Clear all jobs #}
    {% if can_clear_all_jobs %}
      <a class="dropdown-item text-danger"
         href="{% url 'bgjobs:clear_all' project=project.sodar_uuid %}">
        <i class="iconify" data-icon="mdi:delete-circle"></i> Clear All Jobs
      </a>
    {% endif %}

  </div>
</div>
