{% macro render_banners(package, current_user, validation) -%}

<div class="row mb-4">
	<span class="col">
		{{ _("State") }}: <strong>{{ package.state.value }}</strong>
	</span>

	{% for state in package.get_next_states(current_user) %}
		<form class="col-auto"  method="post" action="{{ package.get_set_state_url(state) }}">
			<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
			<input class="btn btn-sm btn-primary" type="submit" value="{{ state.verb() }}" />
		</form>
	{% endfor %}
</div>

{% for note in validation %}
	<div class="alert alert-{{ note.level }}">
		<div class="row g-3">
			<div class="col-md">
				{{ note.message }}
			</div>
			<div class="col-md-auto">
				{% for button in note.buttons %}
					<a href="{{ button[0] }}" class="btn btn-sm btn-{{ note.level }} ms-2">
						{{ button[1] }}
					</a>
				{% endfor %}
			</div>
		</div>
	</div>
{% endfor %}

<p class="alert alert-secondary">
	{% if package.state == package.state.READY_FOR_REVIEW %}
		{% if not package.get_download_release() %}
			{{ _("Please wait for the release to be approved.") }}
		{% elif package.check_perm(current_user, "APPROVE_NEW") %}
			{{ _("You can now approve this package if you're ready.") }}
		{% else %}
			{{ _("Please wait for the package to be approved.") }}
		{% endif %}
	{% elif package.state.READY_FOR_REVIEW in package.get_next_states(current_user) %}
		{% if package.check_perm(current_user, "EDIT_PACKAGE") %}
			{{ _("You can now submit this package for approval if you're ready.") }}
		{% else %}
			{{ _("This package can be submitted for approval when ready.") }}
		{% endif %}
	{% else %}
		{{ _("You need to fix the above errors before you can submit for review") }}
	{% endif %}
</p>

{% if not package.review_thread and (package.author == current_user or package.check_perm(current_user, "APPROVE_NEW")) %}
	<div class="alert alert-secondary">
		<a class="float-end btn btn-sm btn-secondary" href="{{ url_for('threads.new', pid=package.id, title='Package approval comments') }}">
			{{ _("Open Thread") }}
		</a>

		 {{ _("Package approval thread") }}:
		 {{ _("You can open a thread if you have a question for the approver or package author.") }}
		<div style="clear:both;"></div>
	</div>
{% endif %}

{% endmacro %}
