Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: Tools/GardeningServer/scripts/ui/notifications.js

Issue 405843002: Delete garden-o-matic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update run_unittests.html Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google 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 var ui = ui || {};
27 ui.notifications = ui.notifications || {};
28
29 (function(){
30
31 var kMaxTestsPerGroup = 3;
32
33 ui.notifications.Stream = base.extends('ol', {
34 init: function()
35 {
36 this.className = 'notifications';
37 },
38 add: function(notification)
39 {
40 this.appendChild(notification);
41 return notification;
42 }
43 });
44
45 ui.notifications.Notification = base.extends('li', {
46 init: function()
47 {
48 this._how = this.appendChild(document.createElement('div'));
49 this._how.className = 'how';
50 this._what = this.appendChild(document.createElement('div'));
51 this._what.className = 'what';
52 this._index = 0;
53 // FIXME: Why is this requestAnimationFrame needed to make the
54 // animation happen?
55 requestAnimationFrame(function() {
56 this.animate([
57 {opacity: '0'},
58 {opacity: '1'},
59 ], 200);
60 }.bind(this));
61 },
62 dismiss: function()
63 {
64 this.animate([
65 {opacity: '1'},
66 {opacity: '0'},
67 ], 200).onfinish = this.remove.bind(this);
68 },
69 });
70
71 ui.notifications.Info = base.extends(ui.notifications.Notification, {
72 init: function(message)
73 {
74 this.update(message);
75 },
76 update: function(message)
77 {
78 this._what.textContent = message;
79 },
80 updateWithNode: function(node)
81 {
82 this._what.innerHTML = '';
83 this._what.appendChild(node);
84 }
85 });
86
87 ui.notifications.FailingTestGroup = base.extends('li', {
88 init: function(groupName, testNameList)
89 {
90 this.appendChild(ui.createLinkNode(ui.urlForFlakinessDashboard(testNameL ist), groupName));
91 }
92 });
93
94 var Cause = base.extends('li', {
95 init: function()
96 {
97 this._description = this.appendChild(document.createElement('div'));
98 this._description.className = 'description';
99 }
100 });
101
102 ui.notifications.SuspiciousCommit = base.extends(Cause, {
103 init: function(commitData)
104 {
105 this._revision = commitData.revision;
106 this._description.appendChild(ui.createLinkNode(trac.changesetURL(commit Data.revision), commitData.revision));
107 this._details = this._description.appendChild(document.createElement('sp an'));
108 this._addDetail('title', commitData);
109 this._addDetail('author', commitData);
110 this._addDetail('reviewer', commitData);
111 this._addDetail('bugID', commitData,
112 ui.urlForCrbug,
113 function(value) {
114 return value.split(/\s*,\s*/);
115 }
116 );
117 },
118 hasRevision: function(revision)
119 {
120 return this._revision == revision;
121 },
122 _addDetail: function(part, commitData, linkFunction)
123 {
124 var content = commitData[part];
125 if (!content)
126 return;
127
128 var span = this._details.appendChild(document.createElement('span'));
129 span.className = part;
130
131 if (linkFunction) {
132 var parts = Array.isArray(content) ? content : [content];
133 parts.forEach(function(item, index) {
134 if (index > 0)
135 span.appendChild(document.createTextNode(', '));
136 var link = ui.createLinkNode(linkFunction(item), item);
137 link.className = part + '-item';
138 span.appendChild(link);
139 });
140 } else {
141 span.textContent = content;
142 }
143 }
144 });
145
146 ui.notifications.Failure = base.extends(ui.notifications.Notification, {
147 init: function()
148 {
149 this._problem = this._what.appendChild(document.createElement('div'));
150 this._problem.className = 'problem';
151 this._effects = this._problem.appendChild(document.createElement('ul'));
152 this._effects.className = 'effects';
153 this._causes = this._what.appendChild(document.createElement('ul'));
154 this._causes.className = 'causes';
155 },
156 });
157
158 ui.notifications.FailingTests = base.extends(ui.notifications.Failure, {
159 init: function() {
160 // FIXME: Convert actions to a link from test!
161 this._problem.appendChild(new ui.actions.List([
162 new ui.actions.Examine().makeDefault()
163 ]));
164 this._testNameList = [];
165 },
166 testNameList: function()
167 {
168 return this._testNameList;
169 },
170 containsFailureAnalysis: function(failureAnalysis)
171 {
172 return this._testNameList.indexOf(failureAnalysis.testName) != -1;
173 },
174 addFailureAnalysis: function(failureAnalysis)
175 {
176 if (this.containsFailureAnalysis(failureAnalysis))
177 return false;
178 this._testNameList.push(failureAnalysis.testName);
179 this._effects.innerHTML = '';
180 this._forEachTestGroup(function(groupName, testNameList) {
181 this._effects.appendChild(new ui.notifications.FailingTestGroup(grou pName, testNameList))
182 }.bind(this));
183 return true;
184 },
185 _forEachTestGroup: function(callback)
186 {
187 var individualTests = [];
188 base.forEachDirectory(this._testNameList, function(groupLabel, testsInDi rectory) {
189 if (testsInDirectory.length <= kMaxTestsPerGroup) {
190 individualTests = individualTests.concat(testsInDirectory);
191 return;
192 }
193 callback(groupLabel, testsInDirectory);
194 });
195 individualTests.forEach(function(testName) {
196 callback(testName, [testName]);
197 });
198 }
199 });
200
201 ui.notifications.FailingTestsSummary = base.extends(ui.notifications.FailingTest s, {
202 init: function() {
203 this._where = this._how.appendChild(new ui.failures.FailureGrid());
204 },
205 purge: function() {
206 this._where.purge();
207 },
208 updateBuilderResults: function(resultNodesByBuilder)
209 {
210 this._where.update(resultNodesByBuilder);
211 },
212 addFailureAnalysis: function(failureAnalysis)
213 {
214 this.updateBuilderResults(failureAnalysis.resultNodesByBuilder);
215 if (!ui.notifications.FailingTests.prototype.addFailureAnalysis.call(thi s, failureAnalysis))
216 return false;
217 },
218 addCommitData: function(commitData)
219 {
220 return this._causes.appendChild(new ui.notifications.SuspiciousCommit(co mmitData));
221 }
222 });
223
224 ui.notifications.BuildersFailing = base.extends(ui.notifications.Failure, {
225 init: function(message)
226 {
227 if (message)
228 this._problem.insertBefore(document.createTextNode(message + ':'), t his._problem.firstChild);
229 },
230 setFailingBuilders: function(failuresList)
231 {
232 this._effects.innerHTML = '';
233 Object.keys(failuresList).map(function(builderName) {
234 var effect = document.createElement('li');
235 effect.className = 'builder';
236 effect.appendChild(new ui.failures.Builder(builderName, failuresList [builderName]));
237 this._effects.appendChild(effect);
238 }.bind(this));
239 }
240 });
241
242 })();
OLDNEW
« no previous file with comments | « Tools/GardeningServer/scripts/ui/failures_unittests.js ('k') | Tools/GardeningServer/scripts/ui/notifications_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698