{% extends "packages/package_base.html" %}

{% block title %}
{{ _("Remove %(title)s", title=package.title) }}
{% endblock %}

{% block content %}
	<h2 class="mt-0">{{ self.title() }}</h2>

	{% if package.approved %}
	<form method="POST" action="">
		<h3>{{ _("Change maintenance state") }}</h3>
		<p>
			{{ _("As an alternative to removing your package, you may wish to change the maintenance state.") }}
		</p>
		<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
		<ul>

			{% for state in states %}
				<li>
					<strong>{{ state.title }}</strong>{% if state.get_desc() %}: {{ state.get_desc() }}{% endif %}
				</li>
			{% endfor %}
		</ul>
		<p>
			{% for state in states %}
				<input type="submit"
					name="{{ state.name }}" value="{{ state.title }}"
					title="{{ state.get_desc() }}" class="btn btn-primary me-2" />
			{% endfor %}
		</p>
	</form>
	{% endif %}

	<form method="POST" action="" class="mt-5">
		<h3>{{ _("Remove") }}</h3>
		<p>
			{{ _("In order to avoid data loss, you cannot permanently delete packages.
			You can remove them from ContentDB, which will cause them to not be
			visible to any users. Removed packages may be permanently deleted at a
			later point. ContentDB staff can restore removed packages, if needed.") }}
		</p>

		{% if package.approved %}
			<p>
				{{ _("Unapproving a package will put it back into Draft, where
				it can be submitted for approval again.") }}
			</p>
		{% else %}
			<p>
				<strong>{{ _("You don't need to delete a package just to change something.") }}</strong>
				{{ _("Click 'Edit' at the top right of the package page.") }}
			</p>
		{% endif %}

		{% if hard_deps %}
			{% set hard_deps_links -%}
				{%- for dep in hard_deps -%}
					{%- if not loop.first and loop.length > 2 %}, {% endif -%}
					{%- if loop.last and loop.length > 1 %} {{ _("and") }} {% endif -%}
					<a href="{{ dep.get_url('packages.view') }}">{{ dep.title }}</a>
				{%- endfor -%}
			{%- endset %}
			<p class="text-danger">
				<i class="fas fa-exclamation-triangle me-2"></i>
				{{ _("Removing this package will break the following mods: %(names)s", names=hard_deps_links) }}
			</p>
		{% endif %}

		<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />

		<div class="form-group mb-3">
			<label for="reason" class="form-label">{{ _("Reason") }}</label>
			<span class="ms-1 text-danger">
				<small>
					<i class="fas fa-asterisk"></i>
				</small>
			</span>
			<span class="ms-3 text-muted">
				{{ _("Required") }}
			</span>
			<input id="reason" class="form-control" type="text" name="reason" required minlength="5" maxlength="500">
			<small class="form-text text-muted">
				{{ _("Reason for unapproval / deletion, this is shown in the audit log") }}
			</small>
		</div>

		<a class="btn btn-secondary float-end" href="{{ package.get_url('packages.view') }}">{{ _("Cancel") }}</a>

		<input type="submit" name="delete" value="{{ _('Remove') }}" class="btn btn-danger me-2" />

		{% if package.approved %}
			<input type="submit" name="unapprove" value="{{ _('Unpublish') }}" class="btn btn-warning" />
		{% endif %}
	</form>
{% endblock %}
