fix: enhance region sorting to prioritize truly available regions

This commit is contained in:
Christy Jacob
2025-08-22 14:49:29 +05:30
parent 544ec07eb7
commit 77944a09f9
+9 -2
View File
@@ -15,8 +15,15 @@ export function filterRegions(regions: Models.ConsoleRegion[]): RegionOption[] {
return regions
.filter((region) => region.$id !== 'default')
.sort((a, b) => {
if (a.available && !b.available) return 1;
if (!a.available && b.available) return -1;
// Check if regions are truly available (not disabled and available)
const aAvailable = !a.disabled && a.available;
const bAvailable = !b.disabled && b.available;
// Prioritize truly available regions
if (aAvailable && !bAvailable) return -1;
if (!aAvailable && bAvailable) return 1;
// Within the same availability group, sort alphabetically
return a.name.localeCompare(b.name);
})
.map((region) => ({