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

{% block title %}ScanCode.io: {{ project.name }} - Dependencies{% endblock %}

{% block content %}
  <div id="content-header" class="container is-max-widescreen mb-3">
    {% include 'scanpipe/includes/navbar_header.html' %}
    <section class="mx-5">
      <div class="is-flex is-justify-content-space-between">
        {% include 'scanpipe/includes/breadcrumb.html' with linked_project=True current="Dependencies" %}
        {% include 'scanpipe/includes/search_field.html' with extra_class="is-small" %}
      </div>
      {% include 'scanpipe/includes/pagination_header.html' %}
      {% include 'scanpipe/includes/filters_breadcrumb.html' with filterset=filter only %}
    </section>
  </div>

  <div class="container is-fluid mb-3">
    <table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
      {% include 'scanpipe/includes/list_view_thead.html' %}
      <tbody>
        {% for dependency in object_list %}
          <tr class="break-word">
            <td style="min-width: 300px;" title="{{ dependency.dependency_uid }}">
              {# CAUTION: Avoid relying on get_absolute_url to prevent unnecessary query triggers #}
              <a href="{% url 'dependency_detail' project.slug dependency.dependency_uid %}">{{ dependency.purl }}</a>
              {% if dependency.is_vulnerable %}
                <a href="{% url 'dependency_detail' project.slug dependency.dependency_uid %}#vulnerabilities">
                  <i class="fa-solid fa-bug fa-sm has-text-danger" title="Vulnerabilities"></i>
                </a>
              {% endif %}
            </td>
            <td>
              <a href="?type={{ dependency.type }}" class="is-black-link">{{ dependency.type }}</a>
            </td>
            <td>
              {{ dependency.extracted_requirement }}
            </td>
            <td class="break-normal">
              <a href="?scope={{ dependency.scope }}" class="is-black-link">{{ dependency.scope }}</a>
            </td>
            <td>
              <a href="?is_runtime={{ dependency.is_runtime }}" class="is-black-link">{{ dependency.is_runtime }}</a>
            </td>
            <td>
              <a href="?is_optional={{ dependency.is_optional }}" class="is-black-link">{{ dependency.is_optional }}</a>
            </td>
            <td>
              <a href="?is_resolved={{ dependency.is_resolved }}" class="is-black-link">{{ dependency.is_resolved }}</a>
            </td>
            <td>
              {% if dependency.for_package %}
                {# CAUTION: Avoid relying on get_absolute_url to prevent unnecessary query triggers #}
                <a href="{% url 'package_detail' project.slug dependency.for_package.uuid %}" title="{{ dependency.for_package.purl }}">{{ dependency.for_package.purl }}</a>
              {% endif %}
            </td>
            <td>
              {% if dependency.datafile_resource %}
                {# CAUTION: Avoid relying on get_absolute_url to prevent unnecessary query triggers #}
                <a href="{% url 'resource_detail' project.slug dependency.datafile_resource.path %}" title="{{ dependency.datafile_resource.path }}">{{ dependency.datafile_resource.name }}</a>
              {% endif %}
            </td>
            <td>
              <a href="?datasource_id={{ dependency.datasource_id }}" class="is-black-link">{{ dependency.datasource_id }}</a>
            </td>
          </tr>
        {% empty %}
          <tr>
            <td colspan="42" class="has-text-centered p-3">
              No Dependencies found. <a href="?">Clear search and filters</a>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>

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