Skip to content

Commit

Permalink
Merge branch 'master' into Jenkins.load
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Dec 9, 2024
2 parents 4ea92e7 + 930c7ff commit 76d76bd
Show file tree
Hide file tree
Showing 47 changed files with 1,025 additions and 389 deletions.
10 changes: 0 additions & 10 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@
"org.fusesource.jansi:jansi"
]
},
{
"description": "Depends on commons-lang3 which is in progress for removal from core. See: https://issues.jenkins.io/browse/JENKINS-73355",
"matchManagers": [
"maven"
],
"enabled": false,
"matchPackageNames": [
"org.apache.commons:commons-compress"
]
},
{
"description": "Contains incompatible API changes and needs compatibility work. See: https://github.com/jenkinsci/jenkins/pull/4224",
"matchManagers": [
Expand Down
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ THE SOFTWARE.
<artifactId>ant</artifactId>
<version>1.10.15</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2</artifactId>
Expand Down
11 changes: 0 additions & 11 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,6 @@ THE SOFTWARE.
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<exclusions>
<!-- Only needed for Pack200UnpackerAdapter, which we do not use -->
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-core</artifactId>
Expand Down
32 changes: 32 additions & 0 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import hudson.model.View;
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import hudson.search.SearchFactory;
import hudson.search.SearchableModelObject;
import hudson.security.ACL;
import hudson.security.AccessControlled;
Expand Down Expand Up @@ -124,6 +125,7 @@
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -2576,4 +2578,34 @@ static String guessIcon(String iconGuess, String rootURL) {
public static String generateItemId() {
return String.valueOf(Math.floor(Math.random() * 3000));
}

@Restricted(NoExternalUse.class)
public static ExtensionList<SearchFactory> getSearchFactories() {
return SearchFactory.all();
}

/**
* @param keyboardShortcut the shortcut to be translated
* @return the translated shortcut, e.g. CMD+K to ⌘+K for macOS, CTRL+K for Windows
*/
@Restricted(NoExternalUse.class)
public static String translateModifierKeysForUsersPlatform(String keyboardShortcut) {
StaplerRequest2 currentRequest = Stapler.getCurrentRequest2();
currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse2());
String userAgent = currentRequest.getHeader("User-Agent");

List<String> platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD");
boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e));

return keyboardShortcut.replace("CMD", useCmdKey ? "⌘" : "CTRL");
}

@Restricted(NoExternalUse.class)
public static String formatMessage(String format, Object args) {
if (format == null) {
return args.toString();
}

return MessageFormat.format(format, args);
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/hudson/model/Descriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,12 @@ public void calcAutoCompleteSettings(String field, Map<String, Object> attribute
if (method == null)
return; // no auto-completion

// build query parameter line by figuring out what should be submitted
List<String> depends = buildFillDependencies(method, new ArrayList<>());
if (!depends.isEmpty()) {
attributes.put("fillDependsOn", String.join(" ", depends));
}

attributes.put("autoCompleteUrl", String.format("%s/%s/autoComplete%s", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName));
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public void find(String token, List<SearchItem> result) {
public void suggest(String token, List<SearchItem> result) {
find(token, result);
}
}).add("configure", "config", "configure");
});
}

@Override
Expand Down
15 changes: 14 additions & 1 deletion core/src/main/java/hudson/search/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void doSuggestOpenSearch(StaplerRequest2 req, StaplerResponse2 rsp, @Quer
public void doSuggest(StaplerRequest2 req, StaplerResponse2 rsp, @QueryParameter String query) throws IOException, ServletException {
Result r = new Result();
for (SuggestedItem item : getSuggestions(req, query))
r.suggestions.add(new Item(item.getPath()));
r.suggestions.add(new Item(item.getPath(), item.getUrl()));

rsp.serveExposedBean(req, r, Flavor.JSON);
}
Expand Down Expand Up @@ -252,12 +252,25 @@ public static class Result {

@ExportedBean(defaultVisibility = 999)
public static class Item {

@Exported
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "read by Stapler")
public String name;

private final String url;

public Item(String name) {
this(name, null);
}

public Item(String name, String url) {
this.name = name;
this.url = url;
}

@Exported
public String getUrl() {
return url;
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/search/SuggestedItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void getPath(StringBuilder buf) {
buf.append(item.getSearchName());
else {
parent.getPath(buf);
buf.append(' ').append(item.getSearchName());
buf.append(" » ").append(item.getSearchName());
}
}

Expand Down
4 changes: 1 addition & 3 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2346,9 +2346,7 @@ public String getSearchUrl() {
public SearchIndexBuilder makeSearchIndex() {
SearchIndexBuilder builder = super.makeSearchIndex();
if (hasPermission(ADMINISTER)) {
builder.add("configure", "config", "configure")
.add("manage")
.add("log");
builder.add("manage", Messages.ManageJenkinsAction_DisplayName());
}
builder.add(new CollectionSearchIndex<TopLevelItem>() {
@Override
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/jenkins/telemetry/Telemetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public static ExtensionList<Telemetry> all() {
return ExtensionList.lookup(Telemetry.class);
}

@Restricted(NoExternalUse.class) // called by jelly
public static boolean isAnyTrialActive() {
return all().stream().anyMatch(Telemetry::isActivePeriod);
}

/**
* @since 2.147
* @return whether to collect telemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def f=namespace(lib.FormTagLib)

f.section(title: _("Usage Statistics")) {
if (UsageStatistics.DISABLED) {
span(class: "jenkins-not-applicable") {
div(class: "jenkins-not-applicable jenkins-description") {
raw(_("disabledBySystemProperty"))
}
} else if (FIPS140.useCompliantAlgorithms()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?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:f="/lib/form">
<div>
<p>
For any project, it's critical to know how the software is used, but tracking usage data is inherently difficult in open-source projects.
Anonymous usage statistics address this need.
When enabled, Jenkins periodically sends information to the Jenkins project.
The Jenkins project uses this information to set development priorities.
</div>
</p>
<j:invokeStatic className="jenkins.security.FIPS140" method="useCompliantAlgorithms" var="fips"/>
<j:if test="${!fips}">
<h1>General usage statistics</h1>
<h3>General usage statistics</h3>
<div>
<p>Jenkins reports the following general usage statistics:</p>
<ul>
Expand All @@ -24,7 +24,7 @@
</p>
</div>
</j:if>
<h1>Telemetry collection</h1>
<h3>Telemetry collection</h3>
<div>
<p>
<j:choose>
Expand All @@ -38,24 +38,34 @@
Each trial has a specific purpose and a defined end date, after which collection stops, independent of the installed versions of Jenkins or plugins.
Once a trial is complete, the trial results may be aggregated and shared with the developer community.
</p>
<p>
The following trials defined on this instance are active now or in the future:
</p>

<j:invokeStatic className="jenkins.telemetry.Telemetry" method="all" var="collectors"/>
<j:invokeStatic className="jenkins.telemetry.Telemetry" method="isAnyTrialActive" var="anyTrialActive"/>
<j:invokeStatic className="java.time.LocalDate" method="now" var="now"/>
<dl>
<j:forEach items="${collectors}" var="collector">
<j:if test="${not collector.end.isBefore(now)}">
<dt>${collector.displayName}</dt>
<dd>
<st:include it="${collector}" optional="true" page="description.jelly"/>
<p>
Start date: ${collector.start}<br/>
End date: ${collector.end}
</p>
</dd>
</j:if>
</j:forEach>
</dl>
<j:choose>
<j:when test="${!anyTrialActive}">
<p>${%There are currently no active trials.}</p>
</j:when>
<j:otherwise>
<p>
The following trials defined on this instance are active now or in the future:
</p>
<dl>
<j:forEach items="${collectors}" var="collector">
<j:if test="${not collector.end.isBefore(now)}">
<dt>${collector.displayName}</dt>
<dd>
<st:include it="${collector}" optional="true" page="description.jelly"/>
<p>
Start date: ${collector.start}
<br/>
End date: ${collector.end}
</p>
</dd>
</j:if>
</j:forEach>
</dl>
</j:otherwise>
</j:choose>
</div>
</j:jelly>

This file was deleted.

14 changes: 7 additions & 7 deletions core/src/main/resources/lib/form/toggleSwitch.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ THE SOFTWARE.
disabled="${readOnlyMode ? 'true' : null}"
checked="${value ? 'true' : null}"/>
<label class="jenkins-toggle-switch__label ${id != null ? '' : 'attach-previous'}"
for="${id}" data-title="${title}" data-checked-title="${checkedTitle}">
for="${attrs.id}" data-title="${attrs.title}" data-checked-title="${attrs.checkedTitle}">
<j:choose>
<j:when test="${checkedTitle == null}">
${title}
<j:when test="${attrs.checkedTitle == null}">
${attrs.title}
</j:when>
<j:otherwise>
<span class="jenkins-toggle-switch__label__unchecked-title">${title}</span>
<span class="jenkins-toggle-switch__label__checked-title">${checkedTitle}</span>
<span class="jenkins-toggle-switch__label__unchecked-title">${attrs.title}</span>
<span class="jenkins-toggle-switch__label__checked-title">${attrs.checkedTitle}</span>
</j:otherwise>
</j:choose>
</label>
<j:if test="${description != null and !description.trim().isEmpty()}">
<span class="jenkins-toggle-switch__description">${description}</span>
<j:if test="${attrs.description != null and !attrs.description.trim().isEmpty()}">
<span class="jenkins-toggle-switch__description">${attrs.description}</span>
</j:if>
</span>
</j:jelly>
47 changes: 47 additions & 0 deletions core/src/main/resources/lib/layout/command-palette.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
The MIT License
Copyright (c) 2024, Jenkins contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:s="jelly:stapler" xmlns:l="/lib/layout">
<s:documentation>
The command palette overlay
</s:documentation>

<div id="command-palette-i18n" class="i18n"
data-no-results-for="${%No results for}"
data-help="${%Help}"
data-get-help="${%Get help using Jenkins search}"
/>

<dialog id="command-palette" class="jenkins-command-palette__dialog">
<div class="jenkins-command-palette__wrapper">
<div class="jenkins-command-palette">
<l:search-bar id="command-bar" clazz="jenkins-command-palette__search" hasKeyboardShortcut="false" />
<div id="search-results-container" class="jenkins-command-palette__results-container">
<div id="search-results" class="jenkins-command-palette__results" />
</div>
</div>
</div>
</dialog>
</j:jelly>
Loading

0 comments on commit 76d76bd

Please sign in to comment.