Skip to content

Commit f49e626

Browse files
authored
Revert "Enhancement: Add Year to Job Run Timestamp in pipeline-stage-view-plu…" (#382)
This reverts commit 5c5b880.
1 parent e0ca147 commit f49e626

File tree

5 files changed

+16
-52
lines changed

5 files changed

+16
-52
lines changed

ui/src/main/js/view/templates/index.js

+16-45
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ registerHBSHelper('formatDate', function (date, toFormat) {
7878
return date;
7979
}
8080

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

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

94-
var options = {};
95-
96-
// Determine which components to display based on the age of the job
97-
var showYear = diff >= oneYear;
98-
var showDate = diff >= oneDay;
99-
var showTime = true; // Always show time if requested
100-
101-
if (toFormat === 'month') {
102-
if (showDate) {
103-
options.month = 'short';
104-
} else {
105-
return ''; // Do not display month
106-
}
107-
} else if (toFormat === 'dom') {
108-
if (showDate) {
109-
options.day = '2-digit';
110-
} else {
111-
return ''; // Do not display day
112-
}
113-
} else if (toFormat === 'year') {
114-
if (showYear) {
115-
options.year = 'numeric';
116-
} else {
117-
return ''; // Do not display year
118-
}
119-
} else if (toFormat === 'time') {
120-
if (showTime) {
121-
options.hour = '2-digit';
122-
options.minute = '2-digit';
123-
options.hour12 = false;
124-
} else {
125-
return ''; // This case won't occur since we always show time
126-
}
127-
} else {
128-
// Default case: return full date if needed
129-
return theDate.toLocaleString(userLocale);
93+
var theDate = new Date(date);
94+
if (toFormat == 'month') {
95+
return theDate.toLocaleDateString(userLocale, {month: 'short'});
13096
}
131-
132-
return theDate.toLocaleString(userLocale, options);
97+
if (toFormat == 'dom') {
98+
return theDate.toLocaleDateString(userLocale, {day: '2-digit'});
99+
}
100+
if (toFormat == 'time') {
101+
return theDate.toLocaleTimeString(userLocale, {hour: '2-digit',minute: '2-digit', hour12: false });
102+
}
103+
return theDate.toLocaleDateString(userLocale, options)
133104
});
134105

135106
/**
@@ -177,7 +148,7 @@ function getTemplate(templateName) {
177148
if (!templateInstance) {
178149
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.';
179150
}
180-
151+
181152
// handles precompiled and compiled templates
182153
return templateInstance.default || templateInstance;
183154
}
@@ -226,4 +197,4 @@ exports.apply = function (templateName, dataModel, divWrap) {
226197
*/
227198
exports.dateFormatting = function (on) {
228199
dateFormattingOn = on;
229-
}
200+
}

ui/src/main/js/view/templates/pipeline-staged.hbs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
<div class="stage-start-box">
4848
<div class="stage-start-time">
4949
<div class="date">{{formatDate this.startTimeMillis 'month'}} {{formatDate this.startTimeMillis 'dom'}}</div>
50-
<div class="year">{{formatDate this.startTimeMillis 'year'}}</div>
5150
<div class="time">{{formatDate this.startTimeMillis 'time'}}</div>
5251
</div>
5352
{{#if this._links.changesets}}<div class="changeset-box" cbwf-controller="run-changesets" objectUrl="{{this._links.changesets.href}}"></div>

ui/src/test/resources/view/pipeline_staged/render/04_rest_api_runs_failed.html

-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ <h2>Stage View</h2>
5959
<div class="stage-start-box">
6060
<div class="stage-start-time">
6161
<div class="date">1414318349569 1414318349569</div>
62-
<div class="year">1414318349569</div>
6362
<div class="time">1414318349569</div>
6463
</div>
6564
<div class="changeset-box no-changes">No Changes</div>
@@ -126,7 +125,6 @@ <h2>Stage View</h2>
126125
<div class="stage-start-box">
127126
<div class="stage-start-time">
128127
<div class="date">1414318232950 1414318232950</div>
129-
<div class="year">1414318232950</div>
130128
<div class="time">1414318232950</div>
131129
</div>
132130
<div class="changeset-box no-changes">No Changes</div>

ui/src/test/resources/view/pipeline_staged/render/07_rest_api_runs_in_progress.html

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ <h2>Stage View</h2>
4343
<div class="stage-start-box">
4444
<div class="stage-start-time">
4545
<div class="date">1414318232950 1414318232950</div>
46-
<div class="year">1414318232950</div>
4746
<div class="time">1414318232950</div>
4847
</div>
4948
<div class="changeset-box no-changes">No Changes</div>

ui/src/test/resources/view/pipeline_staged/render/expected.html

-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ <h2>Stage View</h2>
5151
<div class="stage-start-box">
5252
<div class="stage-start-time">
5353
<div class="date">1411556423000 1411556423000</div>
54-
<div class="year">1411556423000</div>
5554
<div class="time">1411556423000</div>
5655
</div>
5756
<div class="changeset-box no-changes">No Changes</div>
@@ -109,7 +108,6 @@ <h2>Stage View</h2>
109108
<div class="stage-start-box">
110109
<div class="stage-start-time">
111110
<div class="date">1411556089000 1411556089000</div>
112-
<div class="year">1411556089000</div>
113111
<div class="time">1411556089000</div>
114112
</div>
115113
<div class="changeset-box no-changes">No Changes</div>
@@ -164,7 +162,6 @@ <h2>Stage View</h2>
164162
<div class="stage-start-box">
165163
<div class="stage-start-time">
166164
<div class="date">1411552553000 1411552553000</div>
167-
<div class="year">1411552553000</div>
168165
<div class="time">1411552553000</div>
169166
</div>
170167
<div class="changeset-box no-changes">No Changes</div>

0 commit comments

Comments
 (0)