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

UI renovation #328

Merged
merged 7 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,10 @@ class MyPortlet extends DashboardPortlet {
xmlns:dp="/hudson/plugins/view/dashboard" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<dp:decorate portlet="${it}"> <!-- This is to say that this is a dashboard view portlet -->
<tr><td> <!-- This is needed because everything is formatted as a table - ugly, I know -->

<dp:decorate-plain portlet="${it}"> <!-- This is to say that this is a dashboard view portlet -->
<!-- you can include a separate file with the logic to display your data or you can write here directly -->
<div align="center">
<st:include page="myportlet.jelly"/>
</div>

</td></tr>
</dp:decorate>
</dp:decorate-plain>
</j:jelly>
```

Expand Down
8 changes: 6 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<revision>2</revision>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.version>2.401.3</jenkins.version>
<jenkins.version>2.426.2</jenkins.version>
<spotless.check.skip>false</spotless.check.skip>
</properties>

Expand All @@ -53,7 +53,7 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.401.x</artifactId>
<artifactId>bom-2.426.x</artifactId>
<version>2675.v1515e14da_7a_6</version>
<type>pom</type>
<scope>import</scope>
Expand All @@ -62,6 +62,10 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>ionicons-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
private static final int MIN_COLUMN_COUNT = 3;

private final int columnCount;

private boolean fillColumnFirst = false;

@DataBoundConstructor
Expand All @@ -30,13 +31,17 @@
this.fillColumnFirst = fillColumnFirst;
}

public boolean isFillColumnFirst() {
return fillColumnFirst;
}

public int getColumnCount() {
return columnCount <= 0 ? MIN_COLUMN_COUNT : columnCount;
}

public List<List<Job>> getJobs() {
List<Job> jobs = this.getDashboard().getJobs();
Collections.sort(jobs, (p1, p2) -> p1.getDisplayName().compareToIgnoreCase(p2.getDisplayName()));
Collections.sort(jobs, (p1, p2) -> p1.getFullDisplayName().compareToIgnoreCase(p2.getFullDisplayName()));

Check warning on line 44 in src/main/java/hudson/plugins/view/dashboard/core/JobsPortlet.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 44 is not covered by tests

if (this.fillColumnFirst) {
return transposed(jobs);
Expand Down
36 changes: 16 additions & 20 deletions src/main/java/hudson/plugins/view/dashboard/stats/StatJobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import hudson.Extension;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Job;
import hudson.model.TopLevelItem;
import hudson.plugins.view.dashboard.DashboardPortlet;
Expand Down Expand Up @@ -34,51 +33,48 @@
*/
@Deprecated
public enum HealthStatus {
HEALTH_OVER_80("health-80plus.gif", Messages.Dashboard_NoRecentBuildsFailed()),
HEALTH_60_TO_79("health-60to79.gif", Messages.Dashboard_RecentBuildsFailed("20", "40")),
HEALTH_40_TO_59("health-40to59.gif", Messages.Dashboard_RecentBuildsFailed("40", "60")),
HEALTH_20_TO_39("health-20to39.gif", Messages.Dashboard_RecentBuildsFailed("60", "80")),
HEALTH_0_TO_19("health-00to19.gif", Messages.Dashboard_AllRecentBuildsFailed()),
HEALTH_UNKNOWN("empty.gif", Messages.Dashboard_UnknownStatus());
HEALTH_OVER_80("symbol-weather-icon-health-80plus", Messages.Dashboard_NoRecentBuildsFailed(), 100),
HEALTH_60_TO_79("symbol-weather-icon-health-60to79", Messages.Dashboard_RecentBuildsFailed("20", "40"), 80),
HEALTH_40_TO_59("symbol-weather-icon-health-40to59", Messages.Dashboard_RecentBuildsFailed("40", "60"), 60),
HEALTH_20_TO_39("symbol-weather-icon-health-20to39", Messages.Dashboard_RecentBuildsFailed("60", "80"), 40),
HEALTH_0_TO_19("symbol-weather-icon-health-00to19", Messages.Dashboard_AllRecentBuildsFailed(), 20),
HEALTH_UNKNOWN("symbol-indeterminate", Messages.Dashboard_UnknownStatus(), 0);
// private HealthReport healthReport;
private final String iconUrl;
private final String iconClassName;
private final String description;

HealthStatus(String iconUrl, String description) {
this.iconUrl = iconUrl;
private int score;

HealthStatus(String iconClassName, String description, int score) {
this.iconClassName = iconClassName;
this.description = description;
this.score = score;
}

public static HealthStatus getHealthStatus(Job job) {
int score = job.getBuildHealth().getScore();
if (score <= 20) {
return HEALTH_0_TO_19;
}
if (score <= 40) {
return HEALTH_20_TO_39;
}
if (score <= 60) {
return HEALTH_40_TO_59;
}
if (score <= 80) {
return HEALTH_60_TO_79;
}

return job.getFirstBuild() != null ? HEALTH_OVER_80 : HEALTH_UNKNOWN;
}

public String getIconUrl() {
return Hudson.RESOURCE_PATH + "/images/32x32/" + iconUrl;
public String getIconClassName() {
return iconClassName;
}

public String getIconUrl(String size) {
if (iconUrl == null) {
return Hudson.RESOURCE_PATH + "/images/" + size + "/" + HEALTH_UNKNOWN.getIconUrl();
}
if (iconUrl.startsWith("/")) {
return iconUrl.replace("/32x32/", "/" + size + "/");
}
return Hudson.RESOURCE_PATH + "/images/" + size + "/" + iconUrl;
public int getScore() {
return score;

Check warning on line 77 in src/main/java/hudson/plugins/view/dashboard/stats/StatJobs.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 36-77 are not covered by tests
}

public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,89 +1,91 @@
<!--
The MIT License

Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi

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.
-->

<!--
Edit View Page
-->
<?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" xmlns:i="jelly:fmt">
<st:include page="configure-entries.jelly" class="${it.class.superclass}"/>

<f:section title="${%Dashboard Portlets}">
<f:block>
<f:checkbox name="includeStdJobList" field="includeStdJobList" />
${%Show standard Jenkins list at the top of the page}
</f:block>
<f:block>
<f:checkbox name="hideJenkinsPanels" field="hideJenkinsPanels" />
${%Full screen view - hide standard Jenkins panels}
</f:block>
<f:optionalBlock name="useCssStyle" title="${%Set CSS custom parameters}"
checked="${it.useCssStyle}">
<f:entry title="${%Left portlet width}" help="/plugin/dashboard-view/help/help-configPortletWidth.html">
<f:textbox name="leftPortletWidth" field="leftPortletWidth" />
</f:entry>

<f:entry title="${%Right portlet width}" help="/plugin/dashboard-view/help/help-configPortletWidth.html">
<f:textbox name="rightPortletWidth" field="rightPortletWidth" />
</f:entry>
</f:optionalBlock>
</f:section>

<j:set var="descriptors" value="${it.getSortedDashboardPortletDescriptors()}" />

<f:section title="${%Portlets at the top of the page}">
<f:block>
<f:hetero-list name="topPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.topPortlets}"
addCaption="${%Add Dashboard Portlet to the top of the view}"/>
</f:block>
</f:section>
<f:section title="${%Portlets in the left column}">
<f:block>
<f:hetero-list name="leftPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.leftPortlets}"
addCaption="${%Add Dashboard Portlet to left column}"/>
</f:block>
</f:section>
<f:section title="${%Portlets in the right column}">
<f:block>
<f:hetero-list name="rightPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.rightPortlets}"
addCaption="${%Add Dashboard Portlet to right column}"/>
</f:block>
</f:section>
<f:section title="${%Portlets at the bottom of the page}">
<f:block>
<f:hetero-list name="bottomPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.bottomPortlets}"
addCaption="${%Add Dashboard Portlet to bottom of the view}"/>
</f:block>
<p/>
</f:section>

</j:jelly>
<!--
The MIT License

Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi

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.
-->

<!--
Edit View Page
-->
<?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" xmlns:i="jelly:fmt">
<st:include page="configure-entries.jelly" class="${it.class.superclass}"/>

<f:section title="${%Dashboard Portlets}">
<f:entry title="${%Show standard Jenkins list at the top of the page}">
<f:checkbox name="includeStdJobList" field="includeStdJobList" />
</f:entry>
<f:entry title="${%Full screen view - hide standard Jenkins panels}">
<f:checkbox name="hideJenkinsPanels" field="hideJenkinsPanels" />
</f:entry>
<f:optionalBlock name="useCssStyle" title="${%Set CSS custom parameters}"
checked="${it.useCssStyle}">
<f:entry title="${%Left portlet width}" help="/plugin/dashboard-view/help/help-configPortletWidth.html">
<f:textbox name="leftPortletWidth" field="leftPortletWidth" />
</f:entry>

<f:entry title="${%Right portlet width}" help="/plugin/dashboard-view/help/help-configPortletWidth.html">
<f:textbox name="rightPortletWidth" field="rightPortletWidth" />
</f:entry>
</f:optionalBlock>
</f:section>

<j:set var="descriptors" value="${it.getSortedDashboardPortletDescriptors()}" />

<f:section title="${%Portlets at the top of the page}">
<f:block>
<f:hetero-list name="topPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.topPortlets}"
addCaption="${%Add Dashboard Portlet to the top of the view}"
oneEach="true"/>
</f:block>
</f:section>
<f:section title="${%Portlets in the left column}">
<f:block>
<f:hetero-list name="leftPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.leftPortlets}"
addCaption="${%Add Dashboard Portlet to left column}"
oneEach="true"/>
</f:block>
</f:section>
<f:section title="${%Portlets in the right column}">
<f:block>
<f:hetero-list name="rightPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.rightPortlets}"
addCaption="${%Add Dashboard Portlet to right column}"
oneEach="true"/>
</f:block>
</f:section>
<f:section title="${%Portlets at the bottom of the page}">
<f:block>
<f:hetero-list name="bottomPortlet" hasHeader="true"
descriptors="${descriptors}"
items="${it.bottomPortlets}"
addCaption="${%Add Dashboard Portlet to bottom of the view}"
oneEach="true"/>
</f:block>
<p/>
</f:section>

</j:jelly>
Loading