Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2]
php: [8.1, 8.2, 8.3]
database: ["mariadb:10.2", "mysql:8"]
services:
database:
Expand Down
24 changes: 23 additions & 1 deletion resources/scripts/components/dashboard/DashboardContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,30 @@ export default () => {
() => getServers({ page, type: showOnlyAdmin && rootAdmin ? 'admin' : undefined })
);

const [sortedServers, setSortedServers] = useState<Server[]>([]);

useEffect(() => {
if (!servers) return;

const sorted = servers.items.slice().sort((a, b) => {
const aDescription = a.description || '';
const bDescription = b.description || '';

const aMatch = aDescription.match(/^\[(\d+)\]/);
const bMatch = bDescription.match(/^\[(\d+)\]/);

const aNumber = aMatch ? parseInt(aMatch[1], 10) : Number.MAX_SAFE_INTEGER;
const bNumber = bMatch ? parseInt(bMatch[1], 10) : Number.MAX_SAFE_INTEGER;

if (aNumber === bNumber) {
// Se i numeri sono uguali, ordina per nome
return a.name.localeCompare(b.name);
}

return aNumber - bNumber;
});
setSortedServers(sorted);

if (servers.pagination.currentPage > 1 && !servers.items.length) {
setPage(1);
}
Expand Down Expand Up @@ -65,7 +87,7 @@ export default () => {
{!servers ? (
<Spinner centered size={'large'} />
) : (
<Pagination data={servers} onPageSelect={setPage}>
<Pagination data={{ items: sortedServers, pagination: servers.pagination }} onPageSelect={setPage}>
{({ items }) =>
items.length > 0 ? (
items.map((server, index) => (
Expand Down