{% extends "django_dagster/base.html" %}
{% load i18n %}

{% block content_title %}<h1>{{ title }}</h1>{% endblock %}

{% block dagster_breadcrumbs %}
&rsaquo; {% trans 'Jobs' %}
{% endblock %}

{% block dagster_content %}
{% if jobs is not None %}
    {% if jobs %}
    <div id="changelist">
    <div class="results">
    <table id="result_list">
        <thead>
            <tr>
                {% if current_sort == 'name' %}
                <th scope="col" class="sorted ascending column-name">
                    <div class="sortoptions">
                        <a href="?o=-name" class="toggle ascending" role="button" title="{% trans 'Toggle sorting' %}"></a>
                    </div>
                    <div class="text"><a role="button" href="?o=-name">{% trans 'Name' %}</a></div>
                    <div class="clear"></div>
                </th>
                {% elif current_sort == '-name' %}
                <th scope="col" class="sorted descending column-name">
                    <div class="sortoptions">
                        <a href="?o=name" class="toggle descending" role="button" title="{% trans 'Toggle sorting' %}"></a>
                    </div>
                    <div class="text"><a role="button" href="?o=name">{% trans 'Name' %}</a></div>
                    <div class="clear"></div>
                </th>
                {% else %}
                <th scope="col" class="sortable column-name">
                    <div class="text"><a role="button" href="?o=name">{% trans 'Name' %}</a></div>
                    <div class="clear"></div>
                </th>
                {% endif %}
                <th scope="col"><div class="text">{% trans 'Description' %}</div></th>
                {% if dagster_url %}
                <th scope="col"><div class="text">{% trans 'Dagster UI' %}</div></th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            {% for job in jobs %}
            <tr>
                <th scope="row">
                    <a href="{% url 'admin:django_dagster_dagsterjob_change' job.name %}">{{ job.name }}</a>
                </th>
                <td>{{ job.description|default:"—" }}</td>
                {% if dagster_url %}
                <td>{% if job.dagster_ui_url %}<a href="{{ job.dagster_ui_url }}" target="_blank" rel="noopener" title="{% trans 'View in Dagster UI' %}">&#x2197;</a>{% endif %}</td>
                {% endif %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
    </div>
    </div>
    {% else %}
    <p>{% trans 'No jobs found. Make sure your Dagster instance has code locations loaded.' %}</p>
    {% endif %}
{% endif %}
{% endblock %}
