Skip to content

Commit 45fee51

Browse files
committed
Correcting key to properly render the badges
When viewing all badges in the CI jobs, some entries were using the same key across different fields. This led to badges being rendered to random fields. This fix adds the field to the key to better distinguish which badge belongs to which field.
1 parent f3343bd commit 45fee51

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

static/js/dashboard.v2.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function getJSON(url, callback, ...args) {
320320
jsonRequest.send(null);
321321
}
322322

323-
function renderSingleBadge (key, envLabel, envLink, branchLink, badge_url) {
323+
function renderSingleBadge (key, field, envLabel, envLink, branchLink, badge_url) {
324324
var json_obj = JSON.parse(this.responseText)
325325
var branchLabel = json_obj.message
326326
var color = json_obj.color
@@ -341,11 +341,11 @@ function renderSingleBadge (key, envLabel, envLink, branchLink, badge_url) {
341341
badgeText += '<span class="ci-label-branch-' + color + '">' + branchLabel + '</span>'
342342
}
343343
badgeText += '</span>'
344-
document.getElementById(key).outerHTML = badgeText
344+
document.getElementById(key + '-' + field).outerHTML = badgeText
345345
}
346346

347-
function renderBadgePlaceholder (key) {
348-
return '<span id="' + key + '"><svg class="pf-c-spinner pf-m-md" role="progressbar" viewBox="0 0 100 100" aria-label="Loading..."><circle class="pf-c-spinner__path" cx="50" cy="50" r="45" fill="none" /></svg></span>'
347+
function renderBadgePlaceholder (key, field) {
348+
return '<span id="' + key + '-' + field + '"><svg class="pf-c-spinner pf-m-md" role="progressbar" viewBox="0 0 100 100" aria-label="Loading..."><circle class="pf-c-spinner__path" cx="50" cy="50" r="45" fill="none" /></svg></span>'
349349
}
350350

351351
function renderBadges (badges, field, value, links) {
@@ -363,8 +363,9 @@ function renderBadges (badges, field, value, links) {
363363
envLink = encodeURI(b.getURI())
364364
branchLink = encodeURI(repo_url(b.pattern));
365365
}
366-
badgeText += renderBadgePlaceholder(b.string())
367-
getJSON(b.getURI(), renderSingleBadge, b.string(), b.getLabel(field), envLink, branchLink, b.getURI())
366+
console.log(field)
367+
badgeText += renderBadgePlaceholder(b.string(), field)
368+
getJSON(b.getURI(), renderSingleBadge, b.string(), field, b.getLabel(field), envLink, branchLink, b.getURI())
368369
})
369370
badgeText += '</div>'
370371
return badgeText

0 commit comments

Comments
 (0)