Skip to content

Commit

Permalink
Push
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Aug 18, 2024
1 parent 00c4f53 commit da1622c
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 388 deletions.
16 changes: 16 additions & 0 deletions core/src/main/java/hudson/model/testtest/BaseViewThing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package hudson.model.testtest;

import hudson.model.TopLevelItem;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import javax.servlet.ServletException;

public abstract class BaseViewThing {

public abstract String getDisplayName();

public abstract String getIcon();

public abstract TopLevelItem doCreateItem(StaplerRequest req, StaplerResponse rsp) throws ServletException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package hudson.model.testtest;

import hudson.Extension;
import hudson.model.TopLevelItem;
import java.util.Map;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

@Extension
public class DuplicateProjectThing extends BaseViewThing {

@Override
public String getDisplayName() {
return "Duplicate an existing project";
}

@Override
public String getIcon() {
return "symbol-duplicate";
}

public Map<String, TopLevelItem> getItemMap() {
return Jenkins.get().getItemMap();
}

@Override
public TopLevelItem doCreateItem(StaplerRequest req, StaplerResponse rsp) {
return null;
}
}
25 changes: 25 additions & 0 deletions core/src/main/java/hudson/model/testtest/GithubProjectThing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package hudson.model.testtest;

import hudson.Extension;
import hudson.model.TopLevelItem;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

@Extension
public class GithubProjectThing extends BaseViewThing {

@Override
public String getDisplayName() {
return "Add a GitHub repository";
}

@Override
public String getIcon() {
return "symbol-github";
}

@Override
public TopLevelItem doCreateItem(StaplerRequest req, StaplerResponse rsp) {
return null;
}
}
46 changes: 46 additions & 0 deletions core/src/main/java/hudson/model/testtest/ProjectTypesThing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package hudson.model.testtest;

import hudson.Extension;
import hudson.model.*;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import javax.servlet.ServletException;

@Extension
public class ProjectTypesThing extends BaseViewThing {

@Override
public String getDisplayName() {
return "Project types";
}

@Override
public String getIcon() {
return "symbol-types";
}

@Override
public TopLevelItem doCreateItem(StaplerRequest req, StaplerResponse rsp) throws ServletException {
JSONObject something = req.getSubmittedForm();
String name = something.getString("name");
String type = something.getString("type");

TopLevelItemDescriptor descriptor = Items.all().findByName(type);
if (descriptor == null) {
throw new Failure("No item type ‘" + type + "’ is known");
}

ItemGroupMixIn itemGroupMixIn = Jenkins.get().doCreateItem(req, rsp);

// descriptor.checkApplicableIn(parent);
// acl.getACL().checkCreatePermission(parent, descriptor);

// create empty job and redirect to the project config screen
// result = createProject(descriptor, name, true);

return null;
}
}
69 changes: 31 additions & 38 deletions core/src/main/resources/hudson/model/View/newJob.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,46 @@ 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:getStatic var="permission" className="hudson.model.Item" field="CREATE"/>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<j:getStatic var="permission" className="hudson.model.Item" field="CREATE" />

<l:layout type="one-column" permission="${permission}" title="${%NewJob(it.newPronoun)}">
<l:layout permission="${permission}" title="${%New project}">
<l:header>
<link rel="stylesheet" href="${resURL}/jsbundles/add-item.css" type="text/css" />
<script src="${resURL}/jsbundles/add-item.js" type="text/javascript" defer="true" />
</l:header>

<l:breadcrumb title="${%NewJob(it.newPronoun)}" />

<l:main-panel>
<div id="add-item-panel" style="display: none;">
<h1>${%NewJob(it.newPronoun)}</h1>
<form method="post" action="createItem" name="createItem" id="createItem">
<div class="header">
<div class="add-item-name">
<label for="name" class="jenkins-form-label">${%ItemName.label}</label>
<input name="name" class="jenkins-input" id="name" data-valid="false" type="text" tabindex="0" />
<div id="itemname-required" class="input-validation-message input-message-disabled">&#187; ${%ItemName.validation.required}</div>
<div id="itemname-invalid" class="input-validation-message input-message-disabled"></div>
<div id="itemtype-required" class="input-validation-message input-message-disabled">&#187; ${%ItemType.validation.required}</div>
</div>
</div>
<l:side-panel>
<l:app-bar title="${%NewJob(it.newPronoun)}" />

<div>
<div class="jenkins-form-label">${%ItemType.label}</div>
<div id="items" class="categories flat" role="radiogroup" aria-labelledby="Items" data-valid="false" />
</div>
<l:tasks>
<j:forEach var="item" items="${it.things}" indexVar="index">
<j:if test="${index == 2}">
<div class="swag">Integrate with</div>
</j:if>
<div class="task">
<span class="task-link-wrapper">
<button class="task-link">
<span class="task-icon-link">
<l:icon src="${item.icon}"/>
</span>
<span class="task-link-text">
${item.displayName}
</span>
</button>
</span>
</div>
</j:forEach>
</l:tasks>
</l:side-panel>

<j:if test="${!empty(app.items)}">
<div class="item-copy">
<p class="jenkins-form-label">${%CopyOption.description}</p>
<div class="add-item-copy">
<input type="radio" name="mode" value="copy" />
<label>${%CopyOption.label}</label>
<j:set var="descriptor" value="${it.descriptor}" />
<s:textbox id="from" data-valid="false" name="from" placeholder="${%CopyOption.placeholder}" field="copyNewItemFrom"/>
</div>
</div>
</j:if>

<s:bottomButtonBar>
<st:include page="newJobButtonBar.jelly"/>
</s:bottomButtonBar>
</form>
</div>
<l:main-panel clazz="minithing">
<j:forEach var="item" items="${it.things}">
<div class="dinnerbin">
<st:include page="newJob.jelly" from="${item}"/>
</div>
</j:forEach>
</l:main-panel>
</l:layout>
</j:jelly>
Loading

0 comments on commit da1622c

Please sign in to comment.