{#
  Variables
    - updateData
    - currentVersion
    - isComposerEnabled (bool)
#}
{% extends '@MauticCore/Default/content.html.twig' %}

{% block mauticContent 'update' %}

{% block headerTitle 'mautic.core.update.index'|trans %}

{% block content %}
<div class="panel panel-default mnb-5 bdr-t-wdh-0">
    <div id="update-panel" class="panel-body">
        <div class="col-sm-offset-2 col-sm-8">
            {%- if updateData.error or 'mautic.core.updater.running.latest.version' == updateData.message %}
              <div class="alert alert-info">
                  {{ updateData.message|trans }}
              </div>
              <div class="text-center">
                  <a class="btn btn-primary" href="{{ path('mautic_dashboard_index') }}" data-toggle="ajax">{{ 'mautic.core.go_to_dashboard'|trans }}</a>
              </div>
            {%- else %}
              <div class="panel panel-default">
                  <div class="panel-heading">
                      <h2 class="panel-title">
                          {{ 'mautic.core.update.available'|trans }}
                      </h2>
                      <div class="panel-body">
                          <table class="table table-hover table-striped table-bordered addon-list" id="updateTable">
                              <tbody>
                              <tr>
                                  <td>{{ 'mautic.core.update.current.version'|trans }}</td>
                                  <td>{{ currentVersion }}</td>
                              </tr>
                              <tr>
                                  <td>{{ 'mautic.core.update.upgrade.version'|trans }}</td>
                                  <td>{{ updateData.version|default('') }}</td>
                              </tr>
                              <tr>
                                  <td>{{ 'mautic.core.update.announcement'|trans }}</td>
                                  <td class="break-word"><a href="{{ updateData.announcement|default('#') }}" target="_blank">{{ updateData.announcement|default('') }}</a></td>
                              </tr>
                              <tr>
                                  <td colspan="2" class="text-center text-danger">{{ 'mautic.core.update.backup_warning'|trans }}</td>
                              </tr>
                              </tbody>
                          </table>
                          {%- if isComposerEnabled %}
                          <div class="alert alert-warning text-center">
                              <strong>{{ 'mautic.core.update.composer'|trans|purify }}</strong>
                          </div>
                          {%- else %}
                          <div class="alert alert-warning text-center">
                              <strong>{{ 'mautic.core.update.ui.deprecated'|trans|purify }}</strong>
                          </div>
                          <div class="text-right">
                              <button class="btn btn-primary" onclick="Mautic.processUpdate('update-panel', 1, '');">{{ 'mautic.core.update.now'|trans }}</button>
                          </div>
                          {%- endif %}
                      </div>
                  </div>
                {%- endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}
