diff --git a/pom.xml b/pom.xml index 4f1185ac..1a21ff4b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.jenkins-ci.plugins plugin - 4.86 + 4.88 @@ -58,8 +58,9 @@ 2.35 jenkinsci/pipeline-stage-view-plugin - 2.361.x - 2.361.4 + + 2.426 + ${jenkins.baseline}.3 -SNAPSHOT 18.7.0 8.15.0 @@ -98,21 +99,11 @@ io.jenkins.tools.bom - bom-${bom} - 2102.v854b_fec19c92 + bom-${jenkins.baseline}.x + 3208.vb_21177d4b_cd9 pom import - - org.json - json - 20230618 - - - org.yaml - snakeyaml - 1.33 - diff --git a/ui/package-lock.json b/ui/package-lock.json index 56cde2ca..3ea769bf 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -5122,9 +5122,9 @@ "dev": true }, "node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.0.tgz", + "integrity": "sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==", "dev": true, "peer": true, "dependencies": { @@ -15706,9 +15706,9 @@ "dev": true }, "elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.0.tgz", + "integrity": "sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==", "dev": true, "peer": true, "requires": { diff --git a/ui/src/main/js/util/ajax.js b/ui/src/main/js/util/ajax.js index 6e961d50..20bd0383 100644 --- a/ui/src/main/js/util/ajax.js +++ b/ui/src/main/js/util/ajax.js @@ -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', diff --git a/ui/src/main/js/view/run-input-required.js b/ui/src/main/js/view/run-input-required.js index ff7c3393..28b29f98 100644 --- a/ui/src/main/js/view/run-input-required.js +++ b/ui/src/main/js/view/run-input-required.js @@ -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(); diff --git a/ui/src/main/js/view/templates/index.js b/ui/src/main/js/view/templates/index.js index 6cf8b453..8e50314e 100644 --- a/ui/src/main/js/view/templates/index.js +++ b/ui/src/main/js/view/templates/index.js @@ -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) { @@ -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); }); /** @@ -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; } @@ -197,4 +226,4 @@ exports.apply = function (templateName, dataModel, divWrap) { */ exports.dateFormatting = function (on) { dateFormattingOn = on; -} +} \ No newline at end of file diff --git a/ui/src/main/js/view/templates/pipeline-staged.hbs b/ui/src/main/js/view/templates/pipeline-staged.hbs index 1a191446..a2c59d58 100644 --- a/ui/src/main/js/view/templates/pipeline-staged.hbs +++ b/ui/src/main/js/view/templates/pipeline-staged.hbs @@ -47,6 +47,7 @@
{{formatDate this.startTimeMillis 'month'}} {{formatDate this.startTimeMillis 'dom'}}
+
{{formatDate this.startTimeMillis 'year'}}
{{formatDate this.startTimeMillis 'time'}}
{{#if this._links.changesets}}
diff --git a/ui/src/test/js/helper.js b/ui/src/test/js/helper.js index 66a1a231..8190e5ac 100644 --- a/ui/src/test/js/helper.js +++ b/ui/src/test/js/helper.js @@ -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. *

diff --git a/ui/src/test/resources/view/pipeline_staged/render/04_rest_api_runs_failed.html b/ui/src/test/resources/view/pipeline_staged/render/04_rest_api_runs_failed.html index cad5b9a6..facafeac 100644 --- a/ui/src/test/resources/view/pipeline_staged/render/04_rest_api_runs_failed.html +++ b/ui/src/test/resources/view/pipeline_staged/render/04_rest_api_runs_failed.html @@ -59,6 +59,7 @@

Stage View

1414318349569 1414318349569
+
1414318349569
1414318349569
No Changes
@@ -125,6 +126,7 @@

Stage View

1414318232950 1414318232950
+
1414318232950
1414318232950
No Changes
diff --git a/ui/src/test/resources/view/pipeline_staged/render/07_rest_api_runs_in_progress.html b/ui/src/test/resources/view/pipeline_staged/render/07_rest_api_runs_in_progress.html index 363ba148..ef624a81 100644 --- a/ui/src/test/resources/view/pipeline_staged/render/07_rest_api_runs_in_progress.html +++ b/ui/src/test/resources/view/pipeline_staged/render/07_rest_api_runs_in_progress.html @@ -43,6 +43,7 @@

Stage View

1414318232950 1414318232950
+
1414318232950
1414318232950
No Changes
diff --git a/ui/src/test/resources/view/pipeline_staged/render/expected.html b/ui/src/test/resources/view/pipeline_staged/render/expected.html index 59b132b0..bf082029 100644 --- a/ui/src/test/resources/view/pipeline_staged/render/expected.html +++ b/ui/src/test/resources/view/pipeline_staged/render/expected.html @@ -51,6 +51,7 @@

Stage View

1411556423000 1411556423000
+
1411556423000
1411556423000
No Changes
@@ -108,6 +109,7 @@

Stage View

1411556089000 1411556089000
+
1411556089000
1411556089000
No Changes
@@ -162,6 +164,7 @@

Stage View

1411552553000 1411552553000
+
1411552553000
1411552553000
No Changes