Skip to content

Commit

Permalink
Merge pull request #48 from jglick/newJob
Browse files Browse the repository at this point in the history
[JENKINS-33759] Use standard `newJob` view, not cloned `new` view
  • Loading branch information
jglick committed Mar 28, 2016
2 parents 3857169 + 0d3eb05 commit faeb303
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 95 deletions.
56 changes: 0 additions & 56 deletions src/main/java/com/cloudbees/hudson/plugins/folder/Folder.java
Expand Up @@ -28,14 +28,12 @@
import hudson.Extension;
import hudson.Util;
import hudson.model.Action;
import hudson.model.AutoCompletionCandidates;
import hudson.model.Descriptor;
import hudson.model.Descriptor.FormException;
import hudson.model.Failure;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.ItemGroupMixIn;
import hudson.model.ItemVisitor;
import hudson.model.Items;
import hudson.model.ListView;
import hudson.model.TopLevelItem;
Expand All @@ -46,7 +44,6 @@
import hudson.util.FormValidation;
import hudson.views.ListViewColumn;
import hudson.views.ViewJobFilter;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
Expand Down Expand Up @@ -373,59 +370,6 @@ public TopLevelItem newInstance(ItemGroup parent, String name) {
return new Folder(parent, name);
}

/**
* Auto-completion for the "copy from" field in the new job page.
*/
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@AncestorInPath final Folder f,
@QueryParameter final String value) {
// TODO use ofJobNames but filter by isAllowedChild
final AutoCompletionCandidates r = new AutoCompletionCandidates();

abstract class VisitorImpl extends ItemVisitor {
abstract String getPathNameOf(Item i);

@Override
public void onItemGroup(ItemGroup<?> group) {
super.onItemGroup(group);
}

@Override
public void onItem(Item i) {
String name = getPathNameOf(i);
if (name.startsWith(value)) {
if (i instanceof TopLevelItem) {
TopLevelItem tli = (TopLevelItem) i;
if (f.isAllowedChild(tli)) {
r.add(name);
}
}
}

if (value.startsWith(name)) {
super.onItem(i);
}
}
}

// absolute path name "/foo/bar/zot"
new VisitorImpl() {
String getPathNameOf(Item i) {
return '/' + i.getFullName();
}
}.walk();

// relative path name "foo/bar/zot" from this folder
// TODO: support ".." notation
new VisitorImpl() {
String baseName = f.getFullName();

String getPathNameOf(Item i) {
return i.getFullName().substring(baseName.length() + 1);
}
}.onItemGroup(f);

return r;
}
}

private class MixInImpl extends ItemGroupMixIn {
Expand Down
@@ -1,2 +1 @@
delete=Delete {0}
newJob=New {0}

This file was deleted.

This file was deleted.

Expand Up @@ -24,5 +24,5 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
<j:set var="url" value="${h.getNearestAncestorUrl(request,it)}"/>
<l:task icon="images/24x24/new-package.png" href="${url}/new" title="${%newJob(it.newPronoun)}" permission="${it.CREATE}" />
<l:task icon="images/24x24/new-package.png" href="${url}/newJob" title="${%newJob(it.newPronoun)}" permission="${it.CREATE}" />
</j:jelly>
Expand Up @@ -130,7 +130,7 @@ public class FolderTest {
}

private void copyFromGUI(Folder f, JenkinsRule.WebClient wc, String fromName, String toName) throws Exception {
HtmlPage page = wc.getPage(f, "new");
HtmlPage page = wc.getPage(f, "newJob");
((HtmlInput)page.getElementById("name")).setValueAttribute(toName);
HtmlInput fe = (HtmlInput) page.getElementById("from");
fe.focus();
Expand Down

0 comments on commit faeb303

Please sign in to comment.