Skip to content

Commit

Permalink
[JENKINS-31863] Sort Credential select list by credenial name
Browse files Browse the repository at this point in the history
  • Loading branch information
AndraeRay committed Mar 9, 2016
1 parent b3e7589 commit 68dc8c9
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -25,6 +25,7 @@


import com.cloudbees.plugins.credentials.common.IdCredentials; import com.cloudbees.plugins.credentials.common.IdCredentials;
import com.cloudbees.plugins.credentials.domains.DomainRequirement; import com.cloudbees.plugins.credentials.domains.DomainRequirement;

import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable; import edu.umd.cs.findbugs.annotations.Nullable;
Expand Down Expand Up @@ -57,6 +58,7 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
Expand Down Expand Up @@ -466,6 +468,7 @@ public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C
+ " likely due to missing optional dependency", e); + " likely due to missing optional dependency", e);
} }
} }
Collections.sort(result, new CredentialsNameComparator());
return result; return result;
} }


Expand Down Expand Up @@ -534,9 +537,11 @@ public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C
+ " likely due to missing optional dependency", e); + " likely due to missing optional dependency", e);
} }
} }

Collections.sort(result, new CredentialsNameComparator());
return result; return result;
} }

/** /**
* Returns the scopes allowed for credentials stored within the specified object or {@code null} if the * Returns the scopes allowed for credentials stored within the specified object or {@code null} if the
* object is not relevant for scopes and the object's container should be considered instead. * object is not relevant for scopes and the object's container should be considered instead.
Expand Down Expand Up @@ -834,3 +839,11 @@ public static ExtensionList<CredentialsProvider> all() {
} }


} }

class CredentialsNameComparator implements Comparator<Credentials>{

@Override
public int compare(Credentials cred1, Credentials cred2) {
return CredentialsNameProvider.name(cred1).compareTo(CredentialsNameProvider.name(cred2));
}
};

0 comments on commit 68dc8c9

Please sign in to comment.