Fix version sorting and license actions visibility

- Sort product versions by version DESC when adding via AJAX
- Make license actions always visible in admin overview

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-26 15:09:42 +01:00
parent c6d6269ee3
commit 86b5bdb075
2 changed files with 37 additions and 3 deletions

View File

@@ -201,7 +201,8 @@ code.file-hash {
} }
.licenses-table .row-actions { .licenses-table .row-actions {
visibility: visible; visibility: visible !important;
position: static !important;
padding: 2px 0 0; padding: 2px 0 0;
} }

View File

@@ -174,6 +174,24 @@
}); });
}, },
/**
* Compare two semantic version strings
* Returns: positive if a > b, negative if a < b, 0 if equal
*/
compareVersions: function(a, b) {
var partsA = a.split('.').map(Number);
var partsB = b.split('.').map(Number);
for (var i = 0; i < 3; i++) {
var numA = partsA[i] || 0;
var numB = partsB[i] || 0;
if (numA !== numB) {
return numA - numB;
}
}
return 0;
},
/** /**
* Extract version from filename * Extract version from filename
* Supports patterns like: plugin-v1.2.3.zip, plugin-1.2.3.zip, v1.2.3.zip * Supports patterns like: plugin-v1.2.3.zip, plugin-1.2.3.zip, v1.2.3.zip
@@ -244,8 +262,23 @@
// Remove "no versions" row if present // Remove "no versions" row if present
$('#versions-table tbody .no-versions').remove(); $('#versions-table tbody .no-versions').remove();
// Add new row to table // Add new row in sorted position (by version DESC)
$('#versions-table tbody').prepend(response.data.html); var $newRow = $(response.data.html);
var newVersion = (response.data.version && response.data.version.version) || version;
var inserted = false;
$('#versions-table tbody tr').each(function() {
var rowVersion = $(this).find('td:first strong').text();
if (self.compareVersions(newVersion, rowVersion) > 0) {
$newRow.insertBefore($(this));
inserted = true;
return false; // break
}
});
if (!inserted) {
$('#versions-table tbody').append($newRow);
}
// Clear form // Clear form
$('#new_version').val(''); $('#new_version').val('');