mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 12:02:20 +00:00
[JENKINS-72020] Restore ability to reorder clouds (#8492)
* [JENKINS-72020] Reorder clouds Adding back controls to reorder clouds. Since clouds order is taken into account for node provisioning, users should be able to reorder them as needed. * Use tertiary buttons * Separate screen for reordering * Include reordering in the cloud list directly (thanks @timja) * Show the save button after the first reordering * Separate JS Only display order column when admin * Fix reviews * Remove unused string * Put drag-and-drop handle in the cloud icon column * Add missing permission check * Add a small blurb to clarify what cloud order is used for.
This commit is contained in:
1 parent
0ace9ad585
commit
16bca2e2ea
7 files changed
+103
-30
No files matched your search
@@ -39,6 +39,11 @@ import hudson.util.FormValidation;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.servlet.ServletException;
|
||||
@@ -248,6 +253,25 @@ public class CloudSet extends AbstractModelObject implements Describable<CloudSe
|
||||
rsp.sendRedirect2(".");
|
||||
}
|
||||
|
||||
@POST
|
||||
public void doReorder(StaplerRequest req, StaplerResponse rsp) throws IOException {
|
||||
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
|
||||
var names = req.getParameterValues("name");
|
||||
if (names == null) {
|
||||
throw new Failure("No cloud names given");
|
||||
}
|
||||
var namesList = Arrays.asList(names);
|
||||
var clouds = new ArrayList<>(Jenkins.get().clouds);
|
||||
Collections.sort(clouds, Comparator.comparingInt(c -> getIndexOf(namesList, c)));
|
||||
Jenkins.get().clouds.replaceBy(clouds);
|
||||
rsp.sendRedirect2(".");
|
||||
}
|
||||
|
||||
private static int getIndexOf(List<String> namesList, Cloud cloud) {
|
||||
var i = namesList.indexOf(cloud.name);
|
||||
return i == -1 ? Integer.MAX_VALUE : i;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends Descriptor<CloudSet> implements StaplerProxy {
|
||||
|
||||
|
||||
Reference in new issue
Block a user