From 374dd4b52f064b9d12db7cb8ecefcb3a00ec7f3c Mon Sep 17 00:00:00 2001 From: Nathan Vieira Marcelino Date: Mon, 27 Nov 2023 12:11:18 -0300 Subject: [PATCH] chore:sort install repositories version dropdown - development should be the last option - versions DESC --- .../workspaceSettings/RepositoriesCard.tsx | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx b/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx index 8e9bf799..8456f871 100644 --- a/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx +++ b/frontend/src/features/workspaces/components/workspaceSettings/RepositoriesCard.tsx @@ -121,7 +121,26 @@ export const RepositoriesCard: FC = () => { }) .then((data) => { if (data) { - setAvailableVersions(data?.splice(0, 10)); + const devVersion = data.find( + (item) => + item.version === "dev" || item.version === "development", + ); + const versionsOnly = data + .filter( + (item) => + item.version !== "dev" && item.version !== "development", + ) + .splice(0, 10); + + const sortedVersions = versionsOnly.sort( + (a, b) => parseFloat(b.version) - parseFloat(a.version), + ); + + const sortedData = devVersion + ? [...sortedVersions, devVersion] + : sortedVersions; + + setAvailableVersions(sortedData); } setStep("SELECT_VERSION"); })