{% extends "admin/base_site.html" %}
{% load djblets_js i18n %}


{% block title %}{% trans "Licenses" %}{% endblock %}


{% block content %}
{%  if license_entries %}
<div class="rb-c-licenses" id="licenses-list"></div>
{%  else %}
 <div class="ink-c-alert" role="status">
  <div class="ink-c-alert__content">
   <h3 class="ink-c-alert__heading">
{%   blocktrans %}
    No licensed products are installed.
{%   endblocktrans %}
   </h3>
   <div class="ink-c-alert__body">
    <p>
{%   blocktrans with url="https://www.reviewboard.org/powerpack/" %}
     Upgrade Review Board with <a href="{{url}}">Power Pack</a> for Document
     Review, Reports, User Roles, new source code management integrations, and
     more.
{%   endblocktrans %}
    </p>
  </div>
 </div>
{%  endif %}
{% endblock content %}


{% block scripts-post %}
{{block.super}}
{%  if license_entries %}
<script>
RB.PageManager.ready(function(page) {
    const licensesEl = document.getElementById('licenses-list');
    let collection;
    let license;
    let licenseView;

{%   for license_entry_batch in license_entries %}
{%    if license_entry_batch %}
    collection = new RB.LicenseCollection([], {
        model: {{license_entry_batch.model}},
    });

{%     for license_entry in license_entry_batch.license_infos %}
    license = new {{license_entry_batch.model}}({{license_entry.attrs|json_dumps}}, {
        actionCSRFToken: "{{csrf_token}}",
    });
    licenseView = new {{license_entry_batch.view}}({
        model: license,
    });
    licenseView.renderInto(licensesEl);
    collection.add(license);
{%     endfor %}

    collection.checkForUpdates();
{%    endif %}
{%   endfor %}
});
</script>
{%  endif %}
{% endblock scripts-post %}
