Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable20] Do not allow to keep maintenance mode active in web updater #364

Merged
merged 1 commit into from
Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 19 additions & 24 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1791,10 +1791,9 @@ public function logVersion() {
<div class="output hidden"></div>
</li>
<li id="step-maintenance-mode" class="step <?php if($stepNumber >= 11) { echo 'passed-step'; }?>">
<h2>Keep maintenance mode active?</h2>
<h2>Continue with web based updater</h2>
<div class="output hidden">
<button id="maintenance-enable">Yes (for usage with command line tool)</button>
<button id="maintenance-disable">No (for usage of the web based updater)</button>
<button id="maintenance-disable">Disable maintenance mode and continue in the web based updater</button>
</div>
</li>
<li id="step-done" class="step <?php if($stepNumber >= 12) { echo 'passed-step'; }?>">
Expand Down Expand Up @@ -2128,17 +2127,25 @@ function performStep(number, callback) {
}
},
12: function (response) {
done = true;
window.removeEventListener('beforeunload', confirmExit);
if (response.proceed === true) {
successStep('step-done');

// show button to get to the web based migration steps
var el = document.getElementById('step-done')
.getElementsByClassName('output')[0];
el.classList.remove('hidden');

// above is the fallback if the Javascript redirect doesn't work
window.location.href = "<?php echo htmlspecialchars(str_replace('/index.php', '/../', $updaterUrl), ENT_QUOTES); ?>";
} else {
errorStep('step-done', 11);
errorStep('step-done', 12);
var text = escapeHTML(response.response);
text += '<br><details><summary>Show detailed response</summary><pre><code>' +
escapeHTML(response.detailedResponseText) + '</code></pre></details>';
addStepText('step-done', text);
}
done = true;
},
};

Expand Down Expand Up @@ -2169,19 +2176,12 @@ function retryUpdate() {
startUpdate();
}

function askForMaintenance(keepActive) {
function askForMaintenance() {
var el = document.getElementById('step-maintenance-mode')
.getElementsByClassName('output')[0];
if (keepActive) {
el.innerHTML = 'Maintenance mode will kept active.<br>Now trigger the migration via command line: <code>./occ upgrade</code><br>';
successStep('step-maintenance-mode');
currentStep('step-done');
performStep(12, performStepCallbacks[12]);
} else {
el.innerHTML = 'Maintenance mode will get disabled.<br>';
currentStep('step-maintenance-mode');
performStep(11, performStepCallbacks[11]);
}
el.innerHTML = 'Maintenance mode will get disabled.<br>';
currentStep('step-maintenance-mode');
performStep(11, performStepCallbacks[11]);
}

if(document.getElementById('startUpdateButton')) {
Expand All @@ -2197,26 +2197,21 @@ function askForMaintenance(keepActive) {
retryUpdate();
};
}
if(document.getElementById('maintenance-enable')) {
document.getElementById('maintenance-enable').onclick = function (e) {
e.preventDefault();
askForMaintenance(true);
};
}
if(document.getElementById('maintenance-disable')) {
document.getElementById('maintenance-disable').onclick = function (e) {
e.preventDefault();
askForMaintenance(false);
askForMaintenance();
};
}

// Show a popup when user tries to close page
window.onbeforeunload = confirmExit;
function confirmExit() {
if (done === false && started === true) {
return 'Update is in progress. Are you sure, you want to close?';
}
}
// this is unregistered in step 12
window.addEventListener('beforeunload', confirmExit);
</script>
<?php endif; ?>

Expand Down