{% extends "scanpipe/base.html" %}
{% load humanize %}

{% block title %}ScanCode.io: Projects{% endblock %}

{% block extrahead %}
  <style>
    ul#id_is_archived {display: inline-flex;}
    ul#id_is_archived li {margin-right: 1rem;}
    ul#id_is_archived li a {color: #7a7a7a;}
    ul#id_is_archived li a:hover {text-decoration: underline;}
    ul#id_is_archived li a.is-active {color: #363636;}
  </style>
{% endblock %}

{% block content %}
  <div class="container is-max-widescreen">
    {% include 'scanpipe/includes/navbar_header.html' %}
    <div class="mx-5 mb-2">{% include 'scanpipe/includes/messages.html' %}</div>

    <section class="mx-5 mb-5">
      <div class="is-flex is-justify-content-space-between mb-2">
        <div>
          {% include 'scanpipe/includes/breadcrumb.html' %}
          {{ filter.form.is_archived }}
          {% if filter.is_active %}
            <a class="is-grey-link" href="{% url 'project_list' %}">
              <i class="fa-solid fa-times"></i> Clear search and filters
            </a>
          {% endif %}
        </div>
        <a href="{% url 'project_add' %}" class="button is-smaller is-link">New Project</a>
      </div>

      <div class="is-flex mb-3">
        <div class="is-flex-grow-1 mr-2">
          {% include 'scanpipe/includes/search_field.html' with hide_help=True %}
        </div>
        <div>
          {% include 'scanpipe/dropdowns/filter_dropdown.html' with filter_form_field=filter.form.pipeline only %}
          {% include 'scanpipe/dropdowns/filter_dropdown.html' with filter_form_field=filter.form.status only %}
          {% include 'scanpipe/dropdowns/filter_dropdown.html' with filter_form_field=filter.form.sort only %}
        </div>
      </div>

      {% if object_list %}
        {% include 'scanpipe/includes/project_list_table.html' with projects=object_list %}
      {% else %}
        <div class="tile is-ancestor">
          <div class="tile is-parent">
            <article class="tile is-child box has-text-centered border-dashed">
              {% if filter.is_active %}
                No Projects found. <a href="{% url 'project_list' %}">Clear search and filters</a>
              {% else %}
                <a href="{% url 'project_add' %}">New Project</a>
              {% endif %}
            </article>
          </div>
        </div>
      {% endif %}

      {% if is_paginated %}
        {% include 'scanpipe/includes/pagination.html' with page_obj=page_obj %}
      {% endif %}
    </section>
  </div>

  {% include 'scanpipe/modals/run_modal.html' %}
{% endblock %}