Skip to content

Commit

Permalink
Order API keys by name
Browse files Browse the repository at this point in the history
  • Loading branch information
albandum committed Oct 31, 2024
1 parent 443f2f9 commit 4cb931b
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions front/pages/w/[wId]/developers/api-keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,28 @@ export function APIKeys({
/>
</NewDropdownMenuTrigger>
<NewDropdownMenuContent>
{groups.map((group: GroupType) => (
<NewDropdownMenuItem
key={group.id}
label={prettifyGroupName(group)}
onClick={() => setNewApiKeyGroup(group)}
/>
))}
{groups
.sort((a, b) => {
// Put global groups first
if (a.kind === "global" && b.kind !== "global") {
return -1;
}
if (a.kind !== "global" && b.kind === "global") {
return 1;
}

// Then sort alphabetically case insensitive
return prettifyGroupName(a)
.toLowerCase()
.localeCompare(prettifyGroupName(b).toLowerCase());
})
.map((group: GroupType) => (
<NewDropdownMenuItem
key={group.id}
label={prettifyGroupName(group)}
onClick={() => setNewApiKeyGroup(group)}
/>
))}
</NewDropdownMenuContent>
</NewDropdownMenu>
</div>
Expand Down

0 comments on commit 4cb931b

Please sign in to comment.