Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh the 'New item' page #9111

Merged
merged 8 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions core/src/main/resources/hudson/model/View/newJob.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,42 @@ THE SOFTWARE.
<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="h3">${%ItemName.label}</label>
<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 class="input-help">&#187; ${%ItemName.help}</div>
<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>

<div id="items" class="categories flat" role="radiogroup" aria-labelledby="Items" data-valid="false" />
<div>
<div class="jenkins-form-label">${%ItemType.label}</div>
<div id="items" class="categories flat" role="radiogroup" aria-labelledby="Items" data-valid="false" />
</div>

<j:if test="${!empty(app.items)}">
<div class="item-copy">
<p class="description">${%CopyOption.description}</p>
<p class="jenkins-form-label">${%CopyOption.description}</p>
<div class="add-item-copy">
<input type="radio" name="mode" value="copy" />
<div class="icon">
<img src="${resURL}/images/48x48/copy.png" />
</div>
<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>

<div class="footer">
<div class="btn-decorator">
<st:include page="newJobButtonBar.jelly"/>
</div>
</div>
<s:bottomButtonBar>
<st:include page="newJobButtonBar.jelly"/>
</s:bottomButtonBar>
</form>
</div>
</l:main-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NewJob=New {0}
JobName={0} name
ItemName.help=Required field
ItemName.label=Enter an item name
ItemType.label=Select an item type
ItemName.validation.required=This field cannot be empty, please enter a valid name
ItemType.validation.required=Please select an item type
CopyOption.placeholder=Type to autocomplete
Expand Down
9 changes: 0 additions & 9 deletions test/src/test/java/hudson/model/ViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
Expand Down Expand Up @@ -64,7 +63,6 @@
import java.net.HttpURLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -902,13 +900,6 @@ public void newJob_iconClassName() throws Exception {

HtmlPage page = wc.goTo("view/all/newJob");

Object resultClassNames = page.executeJavaScript("document.querySelector('.hudson_model_FreeStyleProject .icon img').className").getJavaScriptResult();
assertThat(resultClassNames, instanceOf(String.class));
String resultClassNamesString = (String) resultClassNames;
List<String> resultClassNamesList = Arrays.asList(resultClassNamesString.split(" "));
assertThat(resultClassNamesList, hasItem("icon-xlg"));
assertThat(resultClassNamesList, hasItem("icon-freestyle-project"));

Object resultSrc = page.executeJavaScript("document.querySelector('.hudson_model_FreeStyleProject .icon img').src").getJavaScriptResult();
assertThat(resultSrc, instanceOf(String.class));
String resultSrcString = (String) resultSrc;
Expand Down
42 changes: 3 additions & 39 deletions war/src/main/js/add-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ $.when(getItems()).done(function (data) {
$(messageId, context).text("» " + message);
}
cleanValidationMessages(context);
hideInputHelp(context);
$(messageId).removeClass("input-message-disabled");
}

Expand All @@ -69,36 +68,6 @@ $.when(getItems()).done(function (data) {
.addClass("input-message-disabled");
}

function hideInputHelp(context) {
$(".input-help", context).addClass("input-message-disabled");
}

function showInputHelp(context) {
$(".input-help", context).removeClass("input-message-disabled");
}

// About Scroll-linked effect: https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Scroll-linked_effects
function doSticky() {
var decorator = $("form .footer .btn-decorator");
var pos = decorator.offset();
var vpH = $(window).height();
if (pos.top >= vpH) {
decorator.css({ position: "fixed" });
}

$(window).scroll(function () {
var footer = $("form .footer");
var ref1 = decorator.offset().top + decorator.outerHeight();
var ref2 = footer.offset().top + footer.outerHeight();
var vpH = $(window).height();
if (ref2 > vpH + $(window).scrollTop()) {
decorator.css({ position: "fixed" });
} else if (ref2 - 1 <= ref1) {
decorator.css({ position: "absolute" });
}
});
}

function enableSubmit(status) {
var btn = $("form .footer .btn-decorator button[type=submit]");
if (status === true) {
Expand Down Expand Up @@ -173,6 +142,9 @@ $.when(getItems()).done(function (data) {
item.setAttribute("role", "radio");
item.setAttribute("aria-checked", "false");

var iconDiv = drawIcon(elem);
item.appendChild(iconDiv);

var label = item.appendChild(document.createElement("label"));

var radio = label.appendChild(document.createElement("input"));
Expand All @@ -189,9 +161,6 @@ $.when(getItems()).done(function (data) {
desc.className = "desc";
desc.innerHTML = checkForLink(elem.description);

var iconDiv = drawIcon(elem);
item.appendChild(iconDiv);

function select(e) {
e.preventDefault();
cleanCopyFromOption();
Expand Down Expand Up @@ -228,7 +197,6 @@ $.when(getItems()).done(function (data) {
iconDiv.className = "icon";

var img1 = document.createElement("img");
img1.className = elem.iconClassName + " icon-xlg";
img1.src = elem.iconQualifiedUrl;
iconDiv.appendChild(img1);

Expand Down Expand Up @@ -304,7 +272,6 @@ $.when(getItems()).done(function (data) {
);
} else {
cleanValidationMessages(".add-item-name");
showInputHelp(".add-item-name");
setFieldValidationStatus("name", true);
if (getFormValidationStatus()) {
enableSubmit(true);
Expand Down Expand Up @@ -373,8 +340,5 @@ $.when(getItems()).done(function (data) {

// Disable the submit button
enableSubmit(false);

// Do sticky the form buttons
doSticky();
});
});
Loading
Loading