Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Foster2015-07-08 12:10:24 -0400
committerBob Foster2015-07-08 12:10:24 -0400
commit923957645a0e396b043d1e587c12c31acb40c5ec (patch)
tree63adb4024e97225ccf37abdaaf1adc96af430358
parentfe4a34c4b879f93389ba86029a2dd72f6523f860 (diff)
downloadorg.eclipse.hudson.core-923957645a0e396b043d1e587c12c31acb40c5ec.tar.gz
org.eclipse.hudson.core-923957645a0e396b043d1e587c12c31acb40c5ec.tar.xz
org.eclipse.hudson.core-923957645a0e396b043d1e587c12c31acb40c5ec.zip
Fix Bug 471474 - When “More…” is clicked from the Build History area, all the existing builds will be displayed twice
-rw-r--r--hudson-core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly35
-rw-r--r--hudson-war/src/main/webapp/scripts/hudson-behavior.js51
2 files changed, 50 insertions, 36 deletions
diff --git a/hudson-core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly b/hudson-core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
index 5637185f..9ddf2ff2 100644
--- a/hudson-core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
+++ b/hudson-core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
@@ -7,11 +7,11 @@
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
-# Contributors:
+# Contributors:
#
# Kohsuke Kawaguchi, Winston Prakash
-#
-#************************************************************************** -->
+#
+#************************************************************************** -->
<?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">
@@ -30,6 +30,13 @@
</j:parse>
<div id="buildHistoryDiv">
<script>
+ function replace(a, b) {
+ var p = a.parentNode;
+ var next = a.nextSibling;
+ p.removeChild(a);
+ p.insertBefore(b,next);
+ }
+
function loadAllBuildHistory() {
// first display the "loading..." icon
var box = $("loadAllBuildHistory");
@@ -40,15 +47,19 @@
method: "get",
onComplete: function(rsp,_) {
<!-- neither outerHTML nor responseXML works in Firefox 2.0 -->
+ // Save headers from buildHistory
var hist = $$("buildHistory");
- var p = hist.parentNode;
- var next = hist.nextSibling;
- p.removeChild(hist);
+ var histheaders = hist.headers;
- var div = document.createElement('div');
- div.innerHTML = rsp.responseText;
+ // Swap the divs
+ var olddiv = $$("buildHistoryDiv");
+ var newdiv = document.createElement('div');
+ newdiv.innerHTML = rsp.responseText;
+ replace(olddiv, newdiv);
- p.insertBefore(div,next);
+ // Add headers to new buildHistory
+ hist = $$("buildHistory");
+ hist.headers = histheaders;
}
});
}
@@ -87,8 +98,8 @@
</td>
</tr>
</l:pane>
+ <script defer="true">
+ updateBuildHistory("${it.baseUrl}/buildHistory/ajax",${it.nextBuildNumberToFetch});
+ </script>
</div>
- <script defer="true">
- updateBuildHistory("${it.baseUrl}/buildHistory/ajax",${it.nextBuildNumberToFetch});
- </script>
</j:jelly>
diff --git a/hudson-war/src/main/webapp/scripts/hudson-behavior.js b/hudson-war/src/main/webapp/scripts/hudson-behavior.js
index dc6b4f81..3a727dd8 100644
--- a/hudson-war/src/main/webapp/scripts/hudson-behavior.js
+++ b/hudson-war/src/main/webapp/scripts/hudson-behavior.js
@@ -1587,31 +1587,34 @@ function updateBuildHistory(ajaxUrl,nBuild) {
function updateBuilds() {
var bh = $('buildHistory');
- new Ajax.Request(ajaxUrl, {
- requestHeaders: bh.headers,
- onSuccess: function(rsp) {
- var rows = bh.rows;
-
- //delete rows with transitive data
- while (rows.length > 2 && Element.hasClassName(rows[1], "transitive"))
- Element.remove(rows[1]);
-
- // insert new rows
- var div = document.createElement('div');
- div.innerHTML = rsp.responseText;
- Behaviour.applySubtree(div);
-
- var pivot = rows[0];
- var newRows = div.firstChild.rows;
- for (var i = newRows.length - 1; i >= 0; i--) {
- pivot.parentNode.insertBefore(newRows[i], pivot.nextSibling);
+ // There may be a race while loadAllBuildHistory is changing dom.
+ if (typeof bh.headers != "undefined") {
+ new Ajax.Request(ajaxUrl, {
+ requestHeaders: bh.headers,
+ onSuccess: function(rsp) {
+ var rows = bh.rows;
+
+ //delete rows with transitive data
+ while (rows.length > 2 && Element.hasClassName(rows[1], "transitive"))
+ Element.remove(rows[1]);
+
+ // insert new rows
+ var div = document.createElement('div');
+ div.innerHTML = rsp.responseText;
+ Behaviour.applySubtree(div);
+
+ var pivot = rows[0];
+ var newRows = div.firstChild.rows;
+ for (var i = newRows.length - 1; i >= 0; i--) {
+ pivot.parentNode.insertBefore(newRows[i], pivot.nextSibling);
+ }
+
+ // next update
+ bh.headers = ["n",rsp.getResponseHeader("n")];
+ window.setTimeout(updateBuilds, 5000);
}
-
- // next update
- bh.headers = ["n",rsp.getResponseHeader("n")];
- window.setTimeout(updateBuilds, 5000);
- }
- });
+ });
+ }
}
window.setTimeout(updateBuilds, 5000);
}

Back to the top