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

refactor: migrated setup and update to Twig #3001

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ server {
# Private APIs
rewrite api/(autocomplete|bookmark/([0-9]+)|user/data/update|user/password/update|user/request-removal|contact|voting|register|captcha|share|comment/create|faq/create|question/create) /api/index.php last;

# Setup and update pages
rewrite setup/ /setup/index.php last;
rewrite update/ /update/index.php last;

# Setup APIs
rewrite api/setup/(check|backup|update-database) /api/index.php last;

Expand Down
4 changes: 4 additions & 0 deletions phpmyfaq/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
# User pages
RewriteRule ^user/(ucp|bookmarks|request-removal|logout|register) index.php?action=$1 [L,QSA]

# Setup and update pages
RewriteRule ^setup/(.*) setup/index.php [L,QSA]
RewriteRule ^update/(.*) update/index.php [L,QSA]

# Administration API
RewriteRule ^admin/api/(.*) admin/api/index.php [L,QSA]

Expand Down
8 changes: 4 additions & 4 deletions phpmyfaq/assets/src/configuration/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export const handleUpdateNextStepButton = () => {
if (nextStepButton && nextStep) {
nextStepButton.addEventListener('click', (event) => {
event.preventDefault();
window.location.replace(`./update.php?step=${nextStep.value}`);
window.location.replace(`./update?step=${nextStep.value}`);
Dismissed Show dismissed Hide dismissed
});
}
};

export const handleUpdateInformation = async () => {
if (window.location.href.endsWith('update.php')) {
if (window.location.href.endsWith('/update')) {
const installedVersion = document.getElementById('phpmyfaq-update-installed-version');

try {
Expand Down Expand Up @@ -67,7 +67,7 @@ export const handleUpdateInformation = async () => {
};

export const handleConfigBackup = async () => {
if (window.location.href.endsWith('update.php?step=2')) {
if (window.location.href.endsWith('/update?step=2')) {
const installedVersion = document.getElementById('phpmyfaq-update-installed-version');

try {
Expand Down Expand Up @@ -96,7 +96,7 @@ export const handleConfigBackup = async () => {
};

export const handleDatabaseUpdate = async () => {
if (window.location.href.endsWith('update.php?step=3')) {
if (window.location.href.endsWith('/update?step=3')) {
const installedVersion = document.getElementById('phpmyfaq-update-installed-version');

try {
Expand Down
25 changes: 14 additions & 11 deletions phpmyfaq/assets/src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,26 @@ document.addEventListener('DOMContentLoaded', () => {
function showTab(n) {
const currentStep = document.getElementsByClassName('step');

if (currentStep) {
if (currentStep.length > 0) {
currentStep[n].style.display = 'block';
}

const prevButton = document.getElementById('prevBtn');
const nextButton = document.getElementById('nextBtn');
if (n === 0) {
prevButton.style.display = 'none';
} else {
prevButton.style.display = 'inline';
}
if (n === currentStep.length - 1) {
nextButton.innerHTML = 'Submit';
} else {
nextButton.innerHTML = 'Next';

if (prevButton && nextButton) {
if (n === 0) {
prevButton.style.display = 'none';
} else {
prevButton.style.display = 'inline';
}
if (n === currentStep.length - 1) {
nextButton.innerHTML = 'Submit';
} else {
nextButton.innerHTML = 'Next';
}
stepIndicator(n);
}
stepIndicator(n);
}

const nextPrev = (n) => {
Expand Down
258 changes: 132 additions & 126 deletions phpmyfaq/assets/templates/admin/configuration/upgrade.twig
Original file line number Diff line number Diff line change
@@ -1,145 +1,151 @@
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">
<i class="bi bi-arrow-clockwise" aria-hidden="true"></i>
{{ adminHeaderUpgrade }}
</h1>
<h1 class="h2">
<i class="bi bi-arrow-clockwise" aria-hidden="true"></i>
{{ adminHeaderUpgrade }}
</h1>
</div>

<div class="row">
<div class="col-6">
<div class="col-6">

<div id="pmf-update-step-health-check" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
{{ headerCheckHealth }}
</h5>
<p class="card-text">
{{ msgHealthCheck }}
</p>
<!-- Step 1: Check for system health -->
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-check-health">
{{ buttonCheckHealth }}
</button>
<output id="result-check-health"></output>
</div>
</div>
<div id="pmf-update-step-health-check" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
{{ headerCheckHealth }}
</h5>
<p class="card-text">
{{ msgHealthCheck }}
</p>
<!-- Step 1: Check for system health -->
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-check-health">
{{ buttonCheckHealth }}
</button>
<output id="result-check-health"></output>
</div>
</div>
</div>

<div id="pmf-update-step-check-versions" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
{{ headerCheckUpdates }}
</h5>
<p class="card-text">
{{ msgUpdateCheck }}
</p>
<!-- Step 2: Check for a new version -->
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-check-updates">
{{ buttonCheckUpdates }}
</button>
<output id="result-check-versions"></output>
</div>
</div>
<div id="pmf-update-step-check-versions" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
{{ headerCheckUpdates }}
</h5>
<p class="card-text">
{{ msgUpdateCheck }}
</p>
<!-- Step 2: Check for a new version -->
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-check-updates">
{{ buttonCheckUpdates }}
</button>
<output id="result-check-versions"></output>
</div>
</div>
</div>

<div id="pmf-update-step-download" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
{{ headerDownloadPackage }}
</h5>
<p class="card-text">
{{ msgDownloadPackage }}
</p>
<!-- Nightlies can be downloaded always if activated -->
{% if isOnNightlies %}
<p class="alert alert-warning">
{{ alertNightlyBuild }}
</p>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-download-now">
{{ buttonDownloadPackage }}
</button>
<output id="result-download-nightly"></output>
</div>
{% endif %}
</div>
</div>
<div id="pmf-update-step-download" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
{{ headerDownloadPackage }}
</h5>
<p class="card-text">
{{ msgDownloadPackage }}
</p>
<!-- Nightlies can be downloaded always if activated -->
{% if isOnNightlies %}
<p class="alert alert-warning">
{{ alertNightlyBuild }}
</p>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-download-now">
{{ buttonDownloadPackage }}
</button>
<output id="result-download-nightly"></output>
</div>
{% endif %}
</div>
</div>

<div id="pmf-update-step-extract-package" class="card shadow w-100 mb-3 d-none">
<div class="card-body">
<h5 class="card-title">
{{ headerExtractPackage }}
</h5>
<p class="card-text">
{{ msgExtractPackage }}
</p>
<!-- Step 4: Extract downloaded package -->
<div>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-extract-package">
{{ buttonExtractPackage }}
</button>
<output id="result-extract-package"></output>
</div>
</div>
</div>
<div id="pmf-update-step-extract-package" class="card shadow w-100 mb-3 d-none">
<div class="card-body">
<h5 class="card-title">
{{ headerExtractPackage }}
</h5>
<p class="card-text">
{{ msgExtractPackage }}
</p>
<!-- Step 4: Extract downloaded package -->
<div>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-primary mb-2" id="pmf-button-extract-package">
{{ buttonExtractPackage }}
</button>
<output id="result-extract-package"></output>
</div>
</div>
</div>
</div>

<div id="pmf-update-step-install-package" class="card shadow w-100 mb-3 d-none">
<div class="card-body">
<h5 class="card-title">
5. Install downloaded package
</h5>
<p class="card-text">
This extracts the downloaded package into your filesystem.
</p>
<!-- Step 5: Install downloaded package -->
<div>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<div>
<button type="button" class="btn btn-primary mb-2" id="pmf-button-install-package">
Install downloaded package
</button>
</div>
<div>
<ol>
<li>Backup of current installation <span id="pmf-backup-done"></span></li>
<li>Installation of new files <span id="pmf-installation-done"></span></li>
</ol>
</div>
<div class="w-25">
<div class="progress w-100 mt-1 mb-2" role="progressbar">
<div class="progress-bar progress-bar-striped progress-bar-animated"
id="result-backup-package" style="width: 0">
0%
</div>
</div>
<div class="progress w-100" role="progressbar">
<div class="progress-bar progress-bar-striped progress-bar-animated"
id="result-install-package" style="width: 0">
0%
</div>
</div>
</div>
</div>
<div id="pmf-update-step-install-package" class="card shadow w-100 mb-3 d-none">
<div class="card-body">
<h5 class="card-title">
5. Install downloaded package
</h5>
<p class="card-text">
This extracts the downloaded package into your filesystem.
</p>
<!-- Step 5: Install downloaded package -->
<div>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<div>
<button type="button" class="btn btn-primary mb-2" id="pmf-button-install-package">
Install downloaded package
</button>
</div>
<div>
<ol>
<li>Backup of current installation <span id="pmf-backup-done"></span></li>
<li>Installation of new files <span id="pmf-installation-done"></span></li>
</ol>
</div>
<div class="w-25">
<div class="progress w-100 mt-1 mb-2" role="progressbar">
<div class="progress-bar progress-bar-striped progress-bar-animated"
id="result-backup-package" style="width: 0">
0%
</div>
</div>
<div class="progress w-100" role="progressbar">
<div class="progress-bar progress-bar-striped progress-bar-animated"
id="result-install-package" style="width: 0">
0%
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</div>
<div class="col-6">
<div>
<p class="alert alert-info">
You can still use the manual <a href="../update">update process</a> if you prefer.
</p>
</div>
<div class="col-6">
<div>
{{ msgLastCheckDate }}
<output id="dateLastChecked">{{ dateLastChecked | date('Y-m-d H:i:s') }}</output>
</div>
<div>
{{ msgLastVersionAvailable }}
<output id="versionLastChecked">n/a</output>
</div>
<div>
{{ msgReleaseEnvironment }} <output id="releaseEnvironment">{{ releaseEnvironment }}</output>
</div>
<div>
{{ msgLastCheckDate }}
<output id="dateLastChecked">{{ dateLastChecked | date('Y-m-d H:i:s') }}</output>
</div>
<div>
{{ msgLastVersionAvailable }}
<output id="versionLastChecked">n/a</output>
</div>
<div>
{{ msgReleaseEnvironment }}
<output id="releaseEnvironment">{{ releaseEnvironment }}</output>
</div>
</div>
</div>
Loading