Botwatcher's Dashboard is cramped
[WebKit-https.git] / Tools / BuildSlaveSupport / build.webkit.org-config / public_html / dashboard / Scripts / BuildbotLeaksQueueView.js
1 /*
2  * Copyright (C) 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 BuildbotLeaksQueueView = function(queues)
27 {
28     BuildbotQueueView.call(this, [], queues);
29     this.update();
30 };
31
32 BaseObject.addConstructorFunctions(BuildbotLeaksQueueView);
33
34 BuildbotLeaksQueueView.prototype = {
35     constructor: BuildbotLeaksQueueView,
36     __proto__: BuildbotQueueView.prototype,
37
38     update: function()
39     {
40         QueueView.prototype.update.call(this);
41
42         this.element.removeChildren();
43
44         function appendLeaksQueueStatus(queue)
45         {
46             var appendedStatus = false;
47
48             for (var i = 0; i < queue.iterations.length; ++i) {
49                 var iteration = queue.iterations[i];
50                 if (!iteration.loaded || !iteration.finished)
51                     continue;
52
53                 var messageElement = this.revisionContentForIteration(iteration, null);
54
55                 var buildPageURL = iteration.queue.buildbot.buildPageURLForIteration(iteration);
56
57                 if (iteration.successful)
58                     var status = new StatusLineView(messageElement, StatusLineView.Status.Good, "no leaks", null, buildPageURL);
59                 else if (!iteration.productive)
60                     var status = new StatusLineView(messageElement, StatusLineView.Status.Danger, iteration.text, null, buildPageURL);
61                 else if (iteration.failed) {
62                     var url = iteration.queue.buildbot.buildPageURLForIteration(iteration);
63                     var leakCount = iteration.layoutTestResults.uniqueLeakCount;
64                     if (leakCount) {
65                         var leaksViewerURL = iteration.resultURLs["view leaks"];
66                         var status = new StatusLineView(messageElement, StatusLineView.Status.Neutral, leakCount === 1 ? "unique leak" : "unique leaks", leakCount, leaksViewerURL);
67                     } else
68                         var status = new StatusLineView(messageElement, StatusLineView.Status.Danger, iteration.text, null, buildPageURL);
69                 } else {
70                     var url = iteration.queue.buildbot.buildPageURLForIteration(iteration);
71                     var status = new StatusLineView(messageElement, StatusLineView.Status.Danger, iteration.text, null, buildPageURL);
72                 }
73
74                 this.element.appendChild(status.element);
75                 appendedStatus = true;
76                 break;
77             }
78
79             if (!appendedStatus) {
80                 var status = new StatusLineView("unknown", StatusLineView.Status.Neutral, "last passing build");
81                 this.element.appendChild(status.element);
82             }
83
84             new PopoverTracker(status.statusBubbleElement, this._presentPopoverForLeaksQueue.bind(this), iteration);
85         }
86
87         this.appendBuildStyle.call(this, this.releaseQueues, "Leaks", appendLeaksQueueStatus);
88     },
89
90     addLinkToRow: function(rowElement, className, text, url)
91     {
92         var linkElement = document.createElement("a");
93         linkElement.className = className;
94         linkElement.textContent = text;
95         linkElement.href = url;
96         linkElement.target = "_blank";
97         rowElement.appendChild(linkElement);
98     },
99
100     _popoverContentForLeaksQueue: function(iteration)
101     {
102         var content = document.createElement("div");
103
104         content.className = "leaks-popover";
105
106         this._addIterationHeadingToPopover(iteration, content, "");
107         this._addDividerToPopover(content);
108
109         var row = document.createElement("div");
110         row.textContent = iteration.text;
111         content.appendChild(row);
112
113         this._addDividerToPopover(content);
114
115         for (var linkName in iteration.resultURLs) {
116             var row = document.createElement("div");
117             this.addLinkToRow(row, "result-link", linkName, iteration.resultURLs[linkName]);
118             content.appendChild(row);
119         }
120
121         return content;
122     },
123
124     _presentPopoverForLeaksQueue: function(element, popover, iteration)
125     {
126         var content = this._popoverContentForLeaksQueue(iteration);
127
128         var rect = Dashboard.Rect.rectFromClientRect(element.getBoundingClientRect());
129         popover.content = content;
130         popover.present(rect, [Dashboard.RectEdge.MIN_Y, Dashboard.RectEdge.MAX_Y, Dashboard.RectEdge.MAX_X, Dashboard.RectEdge.MIN_X]);
131         return true;
132     }
133
134 };