{% extends 'generic/_base.html' %}
{% load form_helpers %}
{% load i18n %}

{% block title %}{% trans action %} {{ branch }}{% endblock %}

{% block tabs %}
  <ul class="nav nav-tabs">
    <li class="nav-item" role="presentation">
      <button class="nav-link active" id="action-form-tab" data-bs-toggle="tab" data-bs-target="#action-form" type="button" role="tab" aria-controls="merge-form" aria-selected="true">
        {% trans action %}
      </button>
    </li>
  </ul>
{% endblock tabs %}

{% block content %}
  {# Form tab #}
  <div class="tab-pane show active" id="action-form" role="tabpanel" aria-labelledby="action-form-tab">
    {% if not action_permitted %}
      <div class="alert alert-warning">
        <i class="mdi mdi-alert-circle"></i>
        {{ action_permitted.message }}
        {% blocktrans %}Only dry runs are permitted.{% endblocktrans %}
      </div>
    {% endif %}
    {% if conflicts_table.rows %}
      <div class="alert alert-danger">
        <i class="mdi mdi-alert-circle"></i>
        {% blocktrans with count=conflicts_table.rows|length %}
          The following {{ count }} conflicts were found. Applying these changes will overwrite data that has
          been modified since the branch was created. Please confirm that each of these changes is desired.
        {% endblocktrans %}
      </div>
    {% else %}
      <div class="alert alert-success">
        <i class="mdi mdi-check-circle"></i>
        {% trans "No conflicts found." %}
      </div>
    {% endif %}
    <form action="" method="post" enctype="multipart/form-data">
      {% csrf_token %}
      {% if conflicts_table.rows %}
        <div class="card">
          <div class="htmx-container table-responsive" id="object_list">
            {% include 'htmx/table.html' with table=conflicts_table %}
          </div>
        </div>
      {% endif %}
      <div class="row">
        <div class="col col-6 offset-3">
          {% render_field form.commit %}
          <div class="text-center my-3">
            <a href="{{ branch.get_absolute_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
            <button type="submit" name="_update" class="btn btn-primary">
              {% trans action %}
            </button>
          </div>
        </div>
      </div>
    </form>
  </div>
  {# /Form tab #}
{% endblock content %}
