{% extends "mini_buildd/base.html" %}
{% block title %}{% block titledup %}{{ view.mbd_distribution }}{% endblock %}{% endblock %}
{% block tooltip %}in {{ view.mbd_repository }}{% endblock %}
{% block menu %}
	<li><a class="mbd-icon" href="{% url 'admin:mini_buildd_distribution_changelist' %}"><img class="mbd-icon" src="{% static 'icons/configure.svg' %}" alt="Configure"></a></li>
{% endblock %}

{% block content %}
	{% with r=view.mbd_repository d=view.mbd_distribution %}
		{% mbd_token as table_id %}
		<table id="{{ table_id }}" style="width: 100%;">
			{% mbd_datatable table_id columns='[null, {"searchable": false}, {"searchable": false}, {"searchable": false}, {"searchable": false}]' %}
			<thead>
				<tr>
					<th>Suite</th>
					<th>Flags</th>
					<th>Build Info</th>
					<th>Snapshots</th>
					<th>Menu</th>
				</tr>
			</thead>
			<tbody>
				{% for s in r.layout.suiteoption_set.all|mbd_sorted %}
					{% mbd_dict_get view.mbd_xtra s.suite.name as distribution %}
					<tr>
						<td class="mbd-distribution-{{ s.suite.name }}">{{ distribution.name }}</td>
						<td>
							{% if s.uploadable %}<span class="mbd-notice" title="Uploadable (mandatory version regex)">U({{ distribution.mandatory_version_regex }})</span>{% endif %}
							{% if s.experimental %}<span class="mbd-warning" title="Experimental">E</span>{% endif %}
							{% if s.migrates_to %}<span class="mbd-success" title="Migrates to"> =&gt; {{ s.migrates_to.suite.name }}</span>{% endif %}
						</td>
						<td>
							<nav>
								<ul>
									{% if s.uploadable %}
										<li>
											<details>
												<summary>APT sources.list</summary>
												{% mbd_file content=distribution.apt_build_sources_list %}
											</details>
										</li>
										<li>
											<details>
												<summary>APT preferences</summary>
												{% mbd_file content=distribution.apt_build_preferences %}
											</details>
										</li>
									{% endif %}
								</ul>
							</nav>
						</td>
						<td>
							{% if not s.migrates_to and not s.experimental %}
								<details>
									<summary>{{ distribution.snapshots|length }} Snapshots</summary>
									{% mbd_token as snapshots_table_id %}
									<table id="{{ snapshots_table_id }}">
										{% mbd_datatable snapshots_table_id %}
										<thead>
											<tr>
												<th>Name</th>
												<th>Menu</th>
											</tr>
										</thead>
										<tbody>
											{% for snap in distribution.snapshots %}
												<tr>
													<td>{{ snap }}</td>
													<td>
														<nav>
															<ul>
																<li>{% mbd_api "sources_list" value_codenames=d.base_source.codename value_repositories=r.identity value_suites=s.suite.name value_snapshot=snap %}</li>
																<li>{% mbd_api "snapshot_delete" value_distribution=distribution.name value_name=snap %}</li>
															</ul>
														</nav>
													</td>
												</tr>
											{% endfor %}
										</tbody>
										<tfoot>
											<tr>
												<th colspan="2">{% mbd_api "snapshot_create" value_distribution=distribution.name %}</th>
											</tr>
										</tfoot>
									</table>
								</details>
							{% endif %}
						</td>
						<td>
							<nav>
								<ul>
									<li>{% mbd_api "sources_list" value_codenames=d.base_source.codename value_repositories=r.identity value_suites=s.suite.name %}</li>
									{% if s.uploadable %}
										<li>{% mbd_api "port_ext" value_distributions=distribution.name %}</li>
										{% if s.migrates_to %}
											<li>{% mbd_api "keyring_packages" value_distributions=distribution.name %}</li>
										{% endif %}
										{% if s.experimental %}
											<li>{% mbd_api "test_packages" value_distributions=distribution.name %}</li>
										{% endif %}
									{% endif %}
								</ul>
							</nav>
						</td>
					</tr>
				{% endfor %}
			</tbody>
		</table>
	{% endwith %}
{% endblock %}
