mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-11 03:59:35 +00:00
Add downgrade warning for versions without Update Manager
When downgrading to versions before v2.6.0, show a warning that the Update Manager will not be available in older versions and that future updates will need to be done manually via command line.
This commit is contained in:
parent
87352ca6f7
commit
97e3b0aa09
2 changed files with 41 additions and 2 deletions
|
|
@ -133,7 +133,7 @@
|
|||
</div>
|
||||
|
||||
{% if status.update_available and status.can_auto_update and validation.valid %}
|
||||
<form action="{{ path('admin_update_manager_start') }}" method="post" onsubmit="return confirm('{% trans %}update_manager.confirm_update{% endtrans %}');">
|
||||
<form action="{{ path('admin_update_manager_start') }}" method="post" onsubmit="return confirmVersionChange('{{ status.latest_tag }}', false);">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('update_manager_start') }}">
|
||||
<input type="hidden" name="version" value="{{ status.latest_tag }}">
|
||||
|
||||
|
|
@ -237,7 +237,7 @@
|
|||
</a>
|
||||
{% if release.version != status.current_version and status.can_auto_update and validation.valid %}
|
||||
<form action="{{ path('admin_update_manager_start') }}" method="post" class="d-inline"
|
||||
onsubmit="return confirm('{% if release.version > status.current_version %}{% trans %}update_manager.confirm_update{% endtrans %}{% else %}{% trans %}update_manager.confirm_downgrade{% endtrans %}{% endif %}');">
|
||||
onsubmit="return confirmVersionChange('{{ release.tag }}', {{ release.version < status.current_version ? 'true' : 'false' }});">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('update_manager_start') }}">
|
||||
<input type="hidden" name="version" value="{{ release.tag }}">
|
||||
<input type="hidden" name="backup" value="1">
|
||||
|
|
@ -371,4 +371,37 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Version where Update Manager was introduced
|
||||
const UPDATE_MANAGER_MIN_VERSION = '2.6.0';
|
||||
|
||||
function confirmVersionChange(targetVersion, isDowngrade) {
|
||||
const targetClean = targetVersion.replace(/^v/, '');
|
||||
|
||||
if (isDowngrade) {
|
||||
// Check if downgrading to a version without Update Manager
|
||||
if (compareVersions(targetClean, UPDATE_MANAGER_MIN_VERSION) < 0) {
|
||||
return confirm(
|
||||
'{% trans %}update_manager.confirm_downgrade{% endtrans %}\n\n' +
|
||||
'⚠️ {% trans %}update_manager.downgrade_removes_update_manager{% endtrans %}'
|
||||
);
|
||||
}
|
||||
return confirm('{% trans %}update_manager.confirm_downgrade{% endtrans %}');
|
||||
}
|
||||
return confirm('{% trans %}update_manager.confirm_update{% endtrans %}');
|
||||
}
|
||||
|
||||
function compareVersions(v1, v2) {
|
||||
const parts1 = v1.split('.').map(Number);
|
||||
const parts2 = v2.split('.').map(Number);
|
||||
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
||||
const p1 = parts1[i] || 0;
|
||||
const p2 = parts2[i] || 0;
|
||||
if (p1 < p2) return -1;
|
||||
if (p1 > p2) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -14988,5 +14988,11 @@ Buerklin-API Authentication server:
|
|||
<target>Are you sure you want to downgrade Part-DB? This will revert to an older version. A backup will be created before the downgrade.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="um_downgrade_removes_update_manager" name="update_manager.downgrade_removes_update_manager">
|
||||
<segment state="translated">
|
||||
<source>update_manager.downgrade_removes_update_manager</source>
|
||||
<target>WARNING: This version does not include the Update Manager. After downgrading, you will need to update manually using the command line (git checkout, composer install, etc.).</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue