Skip to content

Commit

Permalink
Sort namespace list in clone VM modal
Browse files Browse the repository at this point in the history
  • Loading branch information
pcbailey committed Apr 21, 2020
1 parent 07b79d1 commit 830600e
Showing 1 changed file with 21 additions and 10 deletions.
Expand Up @@ -171,16 +171,27 @@ export const CloneVMModal = withHandlePromise((props: CloneVMModalProps) => {
onChange={(v) => onNamespaceChanged(v)}
id={asId('namespace')}
>
{getLoadedData(namespaces, []).map((n) => {
const namespaceName = getName(n);
return (
<FormSelectOption
key={namespaceName}
value={namespaceName}
label={namespaceName}
/>
);
})}
{getLoadedData(namespaces, [])
.sort((n1, n2) => {
const n1Name = getName(n1);
const n2Name = getName(n2);

if (n1Name === n2Name) {
return 0;
}

return n1Name < n2Name ? -1 : 1;
})
.map((n) => {
const namespaceName = getName(n);
return (
<FormSelectOption
key={namespaceName}
value={namespaceName}
label={namespaceName}
/>
);
})}
</FormSelect>
</FormGroup>
<FormGroup fieldId={asId('start')}>
Expand Down

0 comments on commit 830600e

Please sign in to comment.