Update Bot Watcher's Dashboard for Buildbot 0.9
[WebKit-https.git] / Tools / BuildSlaveSupport / build.webkit.org-config / public_html / dashboard / Scripts / Buildbot.js
index 3e9d78bc6bfc87fe4fb8e29ce54da07471b5508e..d9d518d88144fd640d23b0049959d098b2788411 100644 (file)
@@ -42,6 +42,11 @@ Buildbot = function(baseURL, queuesInfo, options)
     this._needsAuthentication = typeof options === "object" && options.needsAuthentication === true;
     this._authenticationStatus = Buildbot.AuthenticationStatus.Unauthenticated;
 
+    this.VERSION_LESS_THAN_09 = options && options.USE_BUILDBOT_VERSION_LESS_THAN_09;
+
+    if (!this.VERSION_LESS_THAN_09)
+        this._computeBuilderNameToIDMap();
+
     for (var id in queuesInfo) {
         if (queuesInfo[id].combinedQueues) {
             for (var combinedQueueID in queuesInfo[id].combinedQueues)
@@ -146,9 +151,26 @@ Buildbot.prototype = {
         }
     },
 
+    // FIXME: Remove this logic after <https://github.com/buildbot/buildbot/issues/3465> is fixed.
+    _computeBuilderNameToIDMap: function()
+    {
+        JSON.load(this.baseURL + "api/v2/builders", function(data) {
+            if (!data || !(data.builders instanceof Array))
+                return;
+
+            this._builderNameToIDMap = {};
+            for (var builder of data.builders)
+                this._builderNameToIDMap[builder.name] = builder.builderid;
+        }.bind(this));
+    },
+
     buildPageURLForIteration: function(iteration)
     {
-        return this.baseURL + "builders/" + encodeURIComponent(iteration.queue.id) + "/builds/" + iteration.id;
+        if (this.VERSION_LESS_THAN_09)
+            return this.baseURL + "builders/" + encodeURIComponent(iteration.queue.id) + "/builds/" + iteration.id;
+
+        // FIXME: Remove this._builderNameToIDMap lookup after <https://github.com/buildbot/buildbot/issues/3465> is fixed.
+        return this.baseURL + "#/builders/" + encodeURIComponent(this._builderNameToIDMap[iteration.queue.id]) + "/builds/" + iteration.id;
     },
 
     javaScriptCoreTestFailuresURLForIteration: function(iteration, name)