Skip to content

Commit

Permalink
[FIXED JENKINS-12490] auto-complete the copy new node page
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Jan 22, 2012
1 parent a2e6b59 commit 3a5b72c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -62,6 +62,9 @@
<li class=bug>
month should not be 0.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12356">issue 12356</a>)
<li class=bug>
"Create a new slave" page didn't auto-complete for copying.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12490">issue 12490</a>)
<li class=bug>
Fixed a bug in the auto-overwrite of bundled plugins.
<li class=rfe>
Expand Down
31 changes: 29 additions & 2 deletions core/src/main/java/hudson/model/ComputerSet.java
Expand Up @@ -25,6 +25,7 @@

import hudson.BulkChange;
import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.Util;
import hudson.XmlFile;
import hudson.model.Descriptor.FormException;
Expand Down Expand Up @@ -59,7 +60,7 @@
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public final class ComputerSet extends AbstractModelObject {
public final class ComputerSet extends AbstractModelObject implements Describable<ComputerSet> {
/**
* This is the owner that persists {@link #monitors}.
*/
Expand Down Expand Up @@ -298,7 +299,7 @@ public FormValidation doCheckName(@QueryParameter String value) throws IOExcepti
return FormValidation.error(e.getMessage());
}
}

/**
* Accepts submission from the configuration page.
*/
Expand Down Expand Up @@ -333,6 +334,32 @@ public Api getApi() {
return new Api(this);
}

public Descriptor<ComputerSet> getDescriptor() {
return Jenkins.getInstance().getDescriptorOrDie(ComputerSet.class);
}

@Extension
public static class DescriptorImpl extends Descriptor<ComputerSet> {
@Override
public String getDisplayName() {
return "";
}

/**
* Auto-completion for the "copy from" field in the new job page.
*/
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value) {
final AutoCompletionCandidates r = new AutoCompletionCandidates();

for (Node n : Jenkins.getInstance().getNodes()) {
if (n.getNodeName().startsWith(value))
r.add(n.getNodeName());
}

return r;
}
}

/**
* Just to force the execution of the static initializer.
*/
Expand Down

0 comments on commit 3a5b72c

Please sign in to comment.