<div class="tagManagerManageList tagManagerVersionList">
    <div piwik-content-block
         feature="Tag Manager"
         content-title="{{ 'TagManager_ManageX'|translate:('TagManager_Versions'|translate) }}">
    <p>{{ 'TagManager_VersionUsageBenefits'|translate }} {{ 'TagManager_ConfigureEnvironmentsSuperUser'|translate }}</p>

    <table piwik-content-table>
        <thead>
            <tr>
                <th class="index">{{ 'TagManager_Revision'|translate }}</th>
                <th class="name">{{ 'General_Name'|translate }}</th>
                <th class="description">{{ 'General_Description'|translate }}</th>
                <th class="environments">{{ 'TagManager_Environments'|translate }}</th>
                <th class="created">{{ 'TagManager_Created'|translate }}</th>
                <th class="action">{{ 'General_Actions'|translate }}</th>
            </tr>
        </thead>
        <tbody>
        <tr ng-show="versionList.model.isLoading || versionList.model.isUpdating">
            <td colspan="7">
                <span class="loadingPiwik"><img src="plugins/Morpheus/images/loading-blue.gif"/> {{ 'General_LoadingData'|translate }}</span>
            </td>
        </tr>
        <tr ng-show="!versionList.model.isLoading && (versionList.model.versions|length) == 0">
            <td colspan="7">
                {{ 'TagManager_NoVersionsFound'|translate }}
                <a ng-click="versionList.createVersion()"
                   class="createContainerVersionNow"
                   ng-show="versionList.hasWriteAccess">Create a new version now</a>
            </td>
        </tr>
        <tr ng-repeat="version in versionList.model.versions|orderBy:'revision':true"
            id="version{{ version.idcontainerversion }}"
            class="versions">
            <td class="index">{{ version.revision }}</td>
            <td class="name">{{ version.name }}</td>
            <td class="description" title="{{ version.description }}">{{ versionList.truncateText(version.description, 30) }}</td>
            <td class="environments"><span ng-repeat="release in version.releases" title="{{ 'TagManager_ReleaseInfo'|translate:release.release_login:release.release_date_pretty }}">{{ release.environment|ucfirst }}<span ng-show="!$last">, </span></span></td>
            <td class="created"><span>{{ version.created_date_pretty }}</span></td>
            <td class="action">
                <a ng-click="versionList.publishVersion(version)"
                   ng-show="versionList.hasWriteAccess"
                   title="{{ 'TagManager_PublishVersion'|translate:version.name }}"
                   class="table-action icon-rocket"></a>
                <a ng-click="versionList.enableDebugMode(version.idcontainerversion)"
                   title="{{ 'TagManager_EnablePreviewDebug'|translate }}"
                   ng-show="versionList.hasWriteAccess"
                   class="table-action icon-bug"></a>
                <a ng-href="?module=TagManager&action=exportContainerVersion&idContainer={{ versionList.idContainer }}&idContainerVersion={{ version.idcontainerversion }}&idSite={{version.idsite}}&period=day&date=yesterday"
                   title="{{ 'TagManager_ExportX'|translate:('TagManager_Version'|translate) }}"
                   target="_blank"
                   ng-click="versionList.exportVersion(version.idcontainerversion, version.name);$event.preventDefault();"
                   class="table-action icon-export"></a>
                <a ng-click="versionList.editVersion(version.idcontainerversion)"
                   ng-show="versionList.hasWriteAccess"
                   class="table-action icon-edit" title="{{ 'TagManager_EditX'|translate:('TagManager_Version'|translate) }}"></a>
                <a ng-click="versionList.deleteVersion(version)" class="table-action icon-delete"
                   ng-show="(version.releases|length) === 0 && versionList.hasWriteAccess"
                   title="{{ 'TagManager_DeleteX'|translate:('TagManager_Version'|translate) }}"
                ></a>
            </td>
        </tr>
        </tbody>
    </table>

    <div class="tableActionBar">
        <a class="createNewVersion"
           ng-show="versionList.hasWriteAccess"
           ng-click="versionList.createVersion()"
        ><span class="icon-add"></span> {{ 'TagManager_CreateNewVersion'|translate }}</a>

        <a class="exportDraft" target="_blank"
           ng-click="versionList.exportVersion(null, 'draft');$event.preventDefault();"
           ng-href="?module=TagManager&action=exportContainerVersion&idContainer={{ versionList.idContainer }}&idSite={{versionList.idSite}}&period=day&date=yesterday"
        ><span class="icon-export"></span> {{ 'TagManager_ExportDraft'|translate }}</a>

        <a class="importVersion" ng-click="versionList.importVersion()" ng-show="versionList.hasWriteAccess"
        ><span class="icon-upload"></span> {{ 'TagManager_Import'|translate }}</a>
    </div>
    </div>

    <div class="ui-confirm" id="confirmDeleteVersion">
        <h2>{{ 'TagManager_DeleteVersionConfirm'|translate }} </h2>
        <input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
        <input role="no" type="button" value="{{ 'General_No'|translate }}"/>
    </div>

    <div class="ui-confirm" id="confirmPublishVersion">
        <h2>{{ 'TagManager_PublishVersion'|translate:versionList.versionToBePublished.name }}</h2>

        <div ng-show="versionList.versionToBePublished.availableEnvironments.length">
            <div piwik-field uicontrol="select" name="environment"
                 ng-model="versionList.versionToBePublished.deployEnvironment"
                 title="{{ 'TagManager_Environment'|translate }}"
                 options="versionList.versionToBePublished.availableEnvironments"
                 full-width="true">
            </div>

            <div ng-show="!versionList.canPublishToLive"
                 style="margin-bottom: 0;"
                 class="alert alert-info">
                {{ 'TagManager_PublishLiveEnvironmentCapabilityRequired'|translate:('TagManager_CapabilityPublishLiveContainer'|translate) }}
            </div>
        </div>

        <div ng-if="!versionList.versionToBePublished.availableEnvironments.length" class="alert alert-info"
             style="margin-top: 16px;">
            {{ 'TagManager_VersionAlreadyPublishedToAllEnvironments'|translate }}
        </div>

        <input role="yes" type="button" value="{{ 'TagManager_PublishRelease'|translate }}"/>
        <input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
    </div>
</div>