<div id="docsUpdatePopup">
    <?= Form::open(['id' => 'updateForm']) ?>
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="popup">&times;</button>
            <h4 class="modal-title">
                <?php if ($install): ?>
                    <?= e(trans('winter.docs::lang.titles.installDocs')) ?>
                <?php else: ?>
                    <?= e(trans('winter.docs::lang.titles.updateDocs')) ?>
                <?php endif ?>
            </h4>
        </div>

        <?php if (!$this->fatalError): ?>

            <div id="executeActivity">
                <div class="modal-body modal-no-header">
                    <div class="progress bar-loading-indicator" id="executeLoadingBar">
                        <div class="progress-bar"></div>
                    </div>

                    <div class="loading-indicator-container">
                        <p>&nbsp;</p>
                        <div class="loading-indicator transparent">
                            <div id="executeMessage"></div>
                            <span></span>
                        </div>
                    </div>
                    <p>&nbsp;</p>
                </div>
            </div>

            <div id="executeStatus"></div>

            <script type="text/template" id="executeFailed">
                <div class="modal-body modal-no-header">
                    <div class="callout callout-danger no-icon">
                        <div class="header">
                            <h3><?= e(trans('system::lang.updates.update_failed_label')) ?></h3>
                            <p>{{ reason }}</p>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button
                        type="button"
                        class="btn btn-primary"
                        onclick="$.wn.docsUpdater.retryUpdate()">
                        <?= e(trans('system::lang.updates.retry_label')) ?>
                    </button>
                    <button
                        type="button"
                        class="btn btn-default"
                        data-dismiss="popup">
                        <?= e(trans('backend::lang.form.cancel')) ?>
                    </button>
                </div>
            </script>

        <?php else: ?>

            <div class="modal-body modal-no-header">
                <p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
            </div>
            <div class="modal-footer">
                <button
                    type="button"
                    class="btn btn-default"
                    data-dismiss="popup">
                    <?= e(trans('backend::lang.form.close')) ?>
                </button>
            </div>

        <?php endif ?>


    <?= Form::close() ?>
</div>

<script>
    $('#docsUpdatePopup').on('popupComplete', function() {
        $.wn.docsUpdater.execute(<?= json_encode($updateSteps) ?>)
    })
</script>
