{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load crispy_forms_tags %}

{% block breadcrumbs %}
<li><a href="{% url 'create-component' %}">{% trans "Create component" %}</a></li>
{% endblock %}

{% block content %}

{% if not projects and not form.fields.component.queryset and not branch_form.fields.component.queryset %}

{% trans "You do not have permission to create components in any projects." as msg %}
{% show_message "warning" msg %}

{% if has_billing %}
{% include "snippets/billing-failure.html" %}
{% endif %}

{% else %}

<ul class="nav nav-pills">
{% if projects %}
  <li role="presentation" class="active"><a href="#vcs" data-toggle="tab">{% trans "From version control" %}</a></li>
{% endif %}
{% if form.fields.component.queryset %}
  <li role="presentation"><a href="#existing" data-toggle="tab">{% trans "From existing component" %}</a></li>
{% endif %}
{% if branch_form.fields.component.queryset %}
  <li role="presentation"><a href="#branch" data-toggle="tab">{% trans "Additional branch" %}</a></li>
{% endif %}
{% if zip_form %}
  <li role="presentation"><a href="#zip" data-toggle="tab">{% trans "Upload translations files" %}</a></li>
{% endif %}
{% if doc_form %}
  <li role="presentation"><a href="#doc" data-toggle="tab">{% trans "Translate document" %}</a></li>
{% endif %}
{% if scratch_form %}
  <li role="presentation"><a href="#scratch" data-toggle="tab">{% trans "Start from scratch" %}</a></li>
{% endif %}
</ul>

<div class="tab-content">

{% if projects %}
<div class="tab-pane active" id="vcs">
<form action="{% url 'create-component-vcs' %}" method="post" enctype="multipart/form-data" id="form-create-component-vcs">
{% csrf_token %}
<input type="hidden" name="project" value="{{ selected_project }}" />
<p>{% trans "Create a new translation component from remote version control system repository." %}</p>
{% crispy full_form %}
<input type="submit" value="{% trans "Continue" %}" class="btn btn-primary" id="create-vcs">
</form>
</div>
{% endif %}

{% if form.fields.component.queryset %}
<div class="tab-pane" id="existing">
<form method="post">
{% csrf_token %}
<input type="hidden" name="origin" value="existing" />
<input type="hidden" name="project" value="{{ selected_project }}" />
<p>{% trans "Create a new translation component from a repository already cloned in Weblate." %}</p>
{% crispy existing_form %}
<input type="submit" value="{% trans "Continue" %}" class="btn btn-primary" id="create-existing">
</form>
</div>
{% endif %}

{% if branch_form.fields.component.queryset %}
<div class="tab-pane" id="branch">
<form method="post" class="branch-loader" data-branches="{{ branch_data }}" id="form-create-component-branch">
{% csrf_token %}
<input type="hidden" name="origin" value="branch" />
<input type="hidden" name="project" value="{{ selected_project }}" />
<p>{% trans "Create a new translation component for an additional branch of the existing translation component." %}</p>
{% crispy branch_form %}
<p class="help-block">{% trans "The new component will be created for the selected branch with the exact same configuration as the existing one." %}</p>
<input type="submit" value="{% trans "Continue" %}" class="btn btn-primary" id="create-branch">
</form>
</div>
{% endif %}

{% if zip_form %}
<div class="tab-pane" id="zip">
<form action="{% url 'create-component-zip' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" name="project" value="{{ selected_project }}" />
<p>
  {% trans "Create a new translation component from an uploaded ZIP file containing strings for translation." %}
  {% trans "The filenames within the archive need to have locale codes in them." %}
</p>
{% crispy zip_form %}
<input type="submit" value="{% trans "Continue" %}" class="btn btn-primary" id="create-vcs">
</form>
</div>
{% endif %}

{% if doc_form %}
<div class="tab-pane" id="doc">
<form action="{% url 'create-component-doc' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" name="project" value="{{ selected_project }}" />
<p>{% trans "Create a new translation component from an uploaded document for translation." %}</p>
{% crispy doc_form %}
<input type="submit" value="{% trans "Continue" %}" class="btn btn-primary" id="create-vcs">
</form>
</div>
{% endif %}

{% if scratch_form %}
<div class="tab-pane" id="scratch">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" name="origin" value="scratch" />
<input type="hidden" name="project" value="{{ selected_project }}" />
<p class="check">
{% trans "Create a new empty translation component to start from scratch." %}
{% blocktrans with link_start='<a href="#zip" data-toggle="tab">' link_end='</a>' %}Create a ZIP file containing any existing translation files you have, and {{ link_start }}upload it{{ link_end }}.{% endblocktrans %}
</p>
{% crispy scratch_form %}
<input type="submit" value="{% trans "Continue" %}" class="btn btn-primary" id="create-vcs">
</form>
</div>
{% endif %}

</div>
{% endif %}

{% endblock %}
