<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Backend\Block\Cache\Permissions|null $permissions */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */

$permissions = $block->getData('permissions');
?>
<?php if ($permissions && $permissions->hasAccessToAdditionalActions()): ?>
    <div class="additional-cache-management">
        <h2>
            <span><?= $block->escapeHtml(__('Additional Cache Management')); ?></span>
        </h2>
        <?php if ($permissions->hasAccessToFlushCatalogImages()): ?>
            <p>
                <button id="flushCatalogImages" type="button">
                    <?= $block->escapeHtml(__('Flush Catalog Images Cache')); ?>
                </button>
                <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
                    'onclick',
                    'setLocation(\'' . $block->escapeJs($block->getCleanImagesUrl()) . '\')',
                    'button#flushCatalogImages'
                ) ?>
                <span><?= $block->escapeHtml(__('Pregenerated product images files')); ?></span>
            </p>
        <?php endif; ?>
        <?php if ($permissions->hasAccessToFlushJsCss()): ?>
            <p>
                <button id="flushJsCss" type="button">
                    <?= $block->escapeHtml(__('Flush JavaScript/CSS Cache')); ?>
                </button>
                <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
                    'onclick',
                    'setLocation(\'' . $block->escapeJs($block->getCleanMediaUrl()) . '\')',
                    'button#flushJsCss'
                ) ?>
                <span><?= $block->escapeHtml(__('Themes JavaScript and CSS files combined to one file')) ?></span>
            </p>
        <?php endif; ?>
        <?php if (!$block->isInProductionMode() && $permissions->hasAccessToFlushStaticFiles()): ?>
            <p>
                <button id="flushStaticFiles" type="button">
                    <?= $block->escapeHtml(__('Flush Static Files Cache')); ?>
                </button>
                <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
                    'onclick',
                    'setLocation(\'' . $block->escapeJs($block->getCleanStaticFilesUrl()) . '\')',
                    'button#flushStaticFiles'
                ) ?>
                <span><?= $block->escapeHtml(__('Preprocessed view files and static files')); ?></span>
            </p>
        <?php endif; ?>
        <?= $block->getChildHtml() ?>
    </div>
<?php endif; ?>
