From 01324b5ae8c341609f8d3014c669d554a5478c68 Mon Sep 17 00:00:00 2001 From: Evangelos Skopelitis Date: Fri, 13 Dec 2024 14:45:45 -0500 Subject: [PATCH] frontend: k8s: Sort namespaces in UI This change alphabetically sorts namespaces in the UI, addressing the case where namespace lists from k3d/k3s clusters are not sorted by default. Fixes: #2656 Signed-off-by: Evangelos Skopelitis --- frontend/src/components/common/NamespacesAutocomplete.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/common/NamespacesAutocomplete.tsx b/frontend/src/components/common/NamespacesAutocomplete.tsx index 97ff32e8c0..10c4b0c39d 100644 --- a/frontend/src/components/common/NamespacesAutocomplete.tsx +++ b/frontend/src/components/common/NamespacesAutocomplete.tsx @@ -157,7 +157,11 @@ function NamespacesFromClusterAutocomplete( ) { const [namespacesList] = Namespace.useList(); const namespaceNames = useMemo( - () => namespacesList?.map(namespace => namespace.metadata.name) ?? [], + () => + namespacesList + ?.map(namespace => namespace.metadata.name) + .slice() + .sort((a, b) => a.localeCompare(b)) ?? [], [namespacesList] );