Skip to content

Commit

Permalink
Merge branch 'master' into fix/stage-view-overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
olamy authored Nov 25, 2024
2 parents 43e3f49 + 53fd2a5 commit 6949501
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 45 deletions.
21 changes: 6 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.86</version>
<version>4.88</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -58,8 +58,9 @@
<properties>
<revision>2.35</revision>
<gitHubRepo>jenkinsci/pipeline-stage-view-plugin</gitHubRepo>
<bom>2.361.x</bom>
<jenkins.version>2.361.4</jenkins.version>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.426</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<changelist>-SNAPSHOT</changelist>
<node.version>18.7.0</node.version>
<npm.version>8.15.0</npm.version>
Expand Down Expand Up @@ -98,21 +99,11 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${bom}</artifactId>
<version>2102.v854b_fec19c92</version>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>3208.vb_21177d4b_cd9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
12 changes: 6 additions & 6 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ui/src/main/js/util/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ exports.jenkinsAjaxPOST = function () {
var data = arguments[1];
var success = arguments[2];
if (typeof data !== 'string') {
// TODO simplify when Prototype.js is removed
data = Object.toJSON ? Object.toJSON(data) : JSON.stringify(data);
data = JSON.stringify(data);
}
fetch(path, {
method: 'post',
Expand Down
3 changes: 1 addition & 2 deletions ui/src/main/js/view/run-input-required.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ exports.render = function (inputRequiredModel, onElement) {

// Perform the POST. Needs to be encoded into a "json" parameter with an
// array object named "parameter" :)
// TODO simplify when Prototype.js is removed
var parameters = {
json: Object.toJSON ? Object.toJSON({ parameter: inputNVPs }) : JSON.stringify({ parameter: inputNVPs })
json: JSON.stringify({ parameter: inputNVPs })
};
ajax.jenkinsAjaxPOSTURLEncoded(proceedUrl, parameters, function() {
popover.hide();
Expand Down
61 changes: 45 additions & 16 deletions ui/src/main/js/view/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ registerHBSHelper('formatDate', function (date, toFormat) {
return date;
}

var options = { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false };
if (timeZone) {
options.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
}
var theDate = new Date(date);
var now = new Date();
var diff = now - theDate; // Difference in milliseconds
var oneDay = 24 * 60 * 60 * 1000; // milliseconds in one day
var oneYear = 365 * oneDay; // milliseconds in one year

let userLocale
if (navigator.languages && navigator.languages.length) {
Expand All @@ -90,17 +91,45 @@ registerHBSHelper('formatDate', function (date, toFormat) {
userLocale = navigator.language
}

var theDate = new Date(date);
if (toFormat == 'month') {
return theDate.toLocaleDateString(userLocale, {month: 'short'});
}
if (toFormat == 'dom') {
return theDate.toLocaleDateString(userLocale, {day: '2-digit'});
}
if (toFormat == 'time') {
return theDate.toLocaleTimeString(userLocale, {hour: '2-digit',minute: '2-digit', hour12: false });
var options = {};

// Determine which components to display based on the age of the job
var showYear = diff >= oneYear;
var showDate = diff >= oneDay;
var showTime = true; // Always show time if requested

if (toFormat === 'month') {
if (showDate) {
options.month = 'short';
} else {
return ''; // Do not display month
}
} else if (toFormat === 'dom') {
if (showDate) {
options.day = '2-digit';
} else {
return ''; // Do not display day
}
} else if (toFormat === 'year') {
if (showYear) {
options.year = 'numeric';
} else {
return ''; // Do not display year
}
} else if (toFormat === 'time') {
if (showTime) {
options.hour = '2-digit';
options.minute = '2-digit';
options.hour12 = false;
} else {
return ''; // This case won't occur since we always show time
}
} else {
// Default case: return full date if needed
return theDate.toLocaleString(userLocale);
}
return theDate.toLocaleDateString(userLocale, options)

return theDate.toLocaleString(userLocale, options);
});

/**
Expand Down Expand Up @@ -148,7 +177,7 @@ function getTemplate(templateName) {
if (!templateInstance) {
throw 'No template by the name "' + templateName + '". Check ui/src/main/js/view/templates/index.js and make sure the template is registered in the templateCache.';
}

// handles precompiled and compiled templates
return templateInstance.default || templateInstance;
}
Expand Down Expand Up @@ -197,4 +226,4 @@ exports.apply = function (templateName, dataModel, divWrap) {
*/
exports.dateFormatting = function (on) {
dateFormattingOn = on;
}
}
1 change: 1 addition & 0 deletions ui/src/main/js/view/templates/pipeline-staged.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">{{formatDate this.startTimeMillis 'month'}} {{formatDate this.startTimeMillis 'dom'}}</div>
<div class="year">{{formatDate this.startTimeMillis 'year'}}</div>
<div class="time">{{formatDate this.startTimeMillis 'time'}}</div>
</div>
{{#if this._links.changesets}}<div class="changeset-box" cbwf-controller="run-changesets" objectUrl="{{this._links.changesets.href}}"></div>
Expand Down
4 changes: 0 additions & 4 deletions ui/src/test/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ var log = require('fancy-log');
var fs = require('fs');
var requireUncached = require("require-uncached");

Object.toJSON = function(object) {
return JSON.stringify(object);
}

/**
* require one of the pipeline source modules.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ <h2>Stage View</h2>
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">1414318349569 1414318349569</div>
<div class="year">1414318349569</div>
<div class="time">1414318349569</div>
</div>
<div class="changeset-box no-changes">No Changes</div>
Expand Down Expand Up @@ -125,6 +126,7 @@ <h2>Stage View</h2>
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">1414318232950 1414318232950</div>
<div class="year">1414318232950</div>
<div class="time">1414318232950</div>
</div>
<div class="changeset-box no-changes">No Changes</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h2>Stage View</h2>
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">1414318232950 1414318232950</div>
<div class="year">1414318232950</div>
<div class="time">1414318232950</div>
</div>
<div class="changeset-box no-changes">No Changes</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h2>Stage View</h2>
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">1411556423000 1411556423000</div>
<div class="year">1411556423000</div>
<div class="time">1411556423000</div>
</div>
<div class="changeset-box no-changes">No Changes</div>
Expand Down Expand Up @@ -108,6 +109,7 @@ <h2>Stage View</h2>
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">1411556089000 1411556089000</div>
<div class="year">1411556089000</div>
<div class="time">1411556089000</div>
</div>
<div class="changeset-box no-changes">No Changes</div>
Expand Down Expand Up @@ -162,6 +164,7 @@ <h2>Stage View</h2>
<div class="stage-start-box">
<div class="stage-start-time">
<div class="date">1411552553000 1411552553000</div>
<div class="year">1411552553000</div>
<div class="time">1411552553000</div>
</div>
<div class="changeset-box no-changes">No Changes</div>
Expand Down

0 comments on commit 6949501

Please sign in to comment.