diff --git a/assets/css/admin.css b/assets/css/admin.css index e540853..9fbb125 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -201,7 +201,8 @@ code.file-hash { } .licenses-table .row-actions { - visibility: visible; + visibility: visible !important; + position: static !important; padding: 2px 0 0; } diff --git a/assets/js/versions.js b/assets/js/versions.js index 4e3e4da..fdbc3e8 100644 --- a/assets/js/versions.js +++ b/assets/js/versions.js @@ -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 * 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 $('#versions-table tbody .no-versions').remove(); - // Add new row to table - $('#versions-table tbody').prepend(response.data.html); + // Add new row in sorted position (by version DESC) + 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 $('#new_version').val('');