Merge lp:~bac/launchpad/bug-751397 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: 12770
Proposed branch: lp:~bac/launchpad/bug-751397
Merge into: lp:launchpad
Diff against target: 315 lines (+74/-45)
9 files modified
lib/lp/app/javascript/client.js (+23/-15)
lib/lp/app/javascript/lp.js (+2/-2)
lib/lp/app/javascript/tests/test_lp_collapsibles.js (+5/-3)
lib/lp/bugs/javascript/filebug_dupefinder.js (+2/-2)
lib/lp/bugs/templates/bugtarget-bugs.pt (+17/-14)
lib/lp/registry/javascript/structural-subscription.js (+12/-6)
lib/lp/registry/javascript/tests/test_structural_subscription.js (+10/-0)
lib/lp/soyuz/javascript/lp_dynamic_dom_updater.js (+2/-2)
lib/lp/testing/__init__.py (+1/-1)
To merge this branch: bzr merge lp:~bac/launchpad/bug-751397
Reviewer Review Type Date Requested Status
Deryck Hodge (community) code Approve
Review via email: mp+56617@code.launchpad.net

Commit message

[r=deryck][bug=751397] Don't invoke structural-subscription setup JS if the pillar doesn't use LP for bugs. Also replace Y.fail with Y.error.

Description of the change

= Summary =

In YUI3, Y.fail was renamed Y.error so that Y.fail could be moved to the
test infrastructure. Y.fail should no longer be used in production code
but we had many instances of it. They presented no harm in our tests
since the test infrastructure was requiring the 'test' module but in
production Y.fail is undefined and would mask the true error that needed
to be reported.

Also, I do not invoke the structural subscription JS if the bugtarget
does not use LP for bug tracking, which was the point of the original bug.

== Proposed fix ==

s/Y.fail/Y.error/ftw

== Pre-implementation notes ==

Chat with Deryck.

== Implementation details ==

As above. Also some de-linting, which dominates the diff. Some tests
needed the _should clauses changed from 'fail' to 'error'.

== Tests ==

Windmill tests.

== Demo and Q/A ==

Open https://bugs.launchpad.net/thunderbird and witness that no errors
are raised in the console.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/tests/test_lp_collapsibles.js
  lib/lp/bugs/javascript/filebug_dupefinder.js
  lib/lp/app/javascript/lp.js
  lib/lp/app/javascript/client.js
  lib/lp/bugs/templates/bugtarget-bugs.pt
  lib/lp/registry/javascript/tests/test_structural_subscription.js
  lib/lp/soyuz/javascript/lp_dynamic_dom_updater.js
  lib/lp/registry/javascript/structural-subscription.js

To post a comment you must log in.
Revision history for this message
Deryck Hodge (deryck) wrote :

This looks good. Thanks for all the lint cleanup, too.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/client.js'
2--- lib/lp/app/javascript/client.js 2011-04-05 12:10:01 +0000
3+++ lib/lp/app/javascript/client.js 2011-04-07 12:26:29 +0000
4@@ -1,7 +1,8 @@
5 /* Copyright 2009-2011 Canonical Ltd. This software is licensed under the
6 * GNU Affero General Public License version 3 (see the file LICENSE).
7 *
8- * Utility methods and classes to deal with the Launchpad API using Javascript.
9+ * Utility methods and classes to deal with the Launchpad API using
10+ * Javascript.
11 *
12 * @module Y.lp.client
13 */
14@@ -188,7 +189,8 @@
15 if (old_value != new_value) {
16 fields_changed.push(name);
17 cache[name] = new_value;
18- var field_updated_event_name = 'lp:' + cache_name + ':' + name + ':changed';
19+ var field_updated_event_name =
20+ 'lp:' + cache_name + ':' + name + ':changed';
21 var new_value_html = entry.getHTML(name);
22 var event = {
23 'name': name,
24@@ -232,7 +234,7 @@
25 update_cached_object(name, cached_object, entry);
26 }
27 }
28-}
29+};
30
31 module.wrap_resource_on_success = function(ignore, response, args) {
32 var client = args[0];
33@@ -564,10 +566,12 @@
34 var update_cache = false;
35 on.success = module.wrap_resource_on_success;
36 var client = this;
37- var y_config = { on: on,
38- 'arguments': [client, uri, old_on_success, update_cache],
39- 'headers': headers,
40- data: data};
41+ var y_config = {
42+ on: on,
43+ 'arguments': [client, uri, old_on_success, update_cache],
44+ 'headers': headers,
45+ data: data
46+ };
47 Y.io(uri, y_config);
48 },
49
50@@ -611,10 +615,12 @@
51 };
52 var client = this;
53 var update_cache = false;
54- var y_config = { method: "POST",
55- on: on,
56- 'arguments': [client, uri, old_on_success, update_cache],
57- data: data};
58+ var y_config = {
59+ method: "POST",
60+ on: on,
61+ 'arguments': [client, uri, old_on_success, update_cache],
62+ data: data
63+ };
64 Y.io(uri, y_config);
65 },
66
67@@ -740,9 +746,11 @@
68 'Timeout error, please try again in a few minutes.');
69 // If it was a server error...
70 } else if (o.status >= 500) {
71- var server_error = 'Server error, please contact an administrator.';
72+ var server_error =
73+ 'Server error, please contact an administrator.';
74 if (o.getResponseHeader('X-Lazr-OopsId')) {
75- server_error = server_error + ' OOPS ID:' + o.getResponseHeader('X-Lazr-OOPSid');
76+ server_error = server_error + ' OOPS ID:' +
77+ o.getResponseHeader('X-Lazr-OOPSid');
78 }
79 self.showError(server_error);
80 // Otherwise we send some sane text as an error
81@@ -867,11 +875,11 @@
82 */
83 initializer: function(config) {
84 if (!Y.Lang.isString(config.patch)) {
85- Y.fail("missing config: 'patch' containing the attribute name");
86+ Y.error("missing config: 'patch' containing the attribute name");
87 }
88
89 if (!Y.Lang.isString(config.resource)) {
90- Y.fail("missing config: 'resource' containing the URL to patch");
91+ Y.error("missing config: 'resource' containing the URL to patch");
92 }
93
94 // Save the config object that the user passed in so that we can pass
95
96=== modified file 'lib/lp/app/javascript/lp.js'
97--- lib/lp/app/javascript/lp.js 2011-03-24 15:31:53 +0000
98+++ lib/lp/app/javascript/lp.js 2011-04-07 12:26:29 +0000
99@@ -68,10 +68,10 @@
100
101 // If either the wrapper or the icon is null, raise an error.
102 if (wrapper_div === null) {
103- Y.fail("Collapsible has no wrapper div.");
104+ Y.error("Collapsible has no wrapper div.");
105 }
106 if (icon === null) {
107- Y.fail("Collapsible has no icon.");
108+ Y.error("Collapsible has no icon.");
109 }
110 return wrapper_div;
111 }
112
113=== modified file 'lib/lp/app/javascript/tests/test_lp_collapsibles.js'
114--- lib/lp/app/javascript/tests/test_lp_collapsibles.js 2011-02-03 20:55:58 +0000
115+++ lib/lp/app/javascript/tests/test_lp_collapsibles.js 2011-04-07 12:26:29 +0000
116@@ -14,9 +14,11 @@
117 name: "activate_collapsibles",
118
119 _should: {
120- fail: {
121- test_toggle_collapsible_fails_on_wrapperless_collapsible: true,
122- test_toggle_collapsible_fails_on_iconless_collapsible: true,
123+ error: {
124+ test_toggle_collapsible_fails_on_wrapperless_collapsible:
125+ new Error('Collapsible has no wrapper div.'),
126+ test_toggle_collapsible_fails_on_iconless_collapsible:
127+ new Error('Collapsible has no icon.')
128 }
129 },
130
131
132=== modified file 'lib/lp/bugs/javascript/filebug_dupefinder.js'
133--- lib/lp/bugs/javascript/filebug_dupefinder.js 2011-02-04 15:03:32 +0000
134+++ lib/lp/bugs/javascript/filebug_dupefinder.js 2011-04-07 12:26:29 +0000
135@@ -466,7 +466,6 @@
136 };
137
138 namespace.setup_dupe_finder = function() {
139- Y.log("In setup_dupe_finder");
140 Y.on('domready', function() {
141 config = {on: {success: set_up_dupe_finder,
142 failure: function() {}}};
143@@ -485,4 +484,5 @@
144 };
145
146 }, "0.1", {"requires": [
147- "base", "io", "oop", "node", "event", "lazr.formoverlay", "lazr.effects"]});
148+ "base", "io", "oop", "node", "event", "lazr.formoverlay",
149+ "lazr.effects"]});
150
151=== modified file 'lib/lp/bugs/templates/bugtarget-bugs.pt'
152--- lib/lp/bugs/templates/bugtarget-bugs.pt 2011-03-29 22:34:04 +0000
153+++ lib/lp/bugs/templates/bugtarget-bugs.pt 2011-04-07 12:26:29 +0000
154@@ -12,16 +12,19 @@
155 <metal:block fill-slot="head_epilogue">
156 <meta tal:condition="not: view/bug_tracking_usage/enumvalue:LAUNCHPAD"
157 name="robots" content="noindex,nofollow" />
158- <script type="text/javascript"
159- tal:condition="
160- request/features/malone.advanced-structural-subscriptions.enabled">
161- LPS.use('lp.registry.structural_subscription', function(Y) {
162- var module = Y.lp.registry.structural_subscription;
163- Y.on('domready', function() {
164- module.setup({content_box: "#structural-subscription-content-box"});
165- });
166- });
167- </script>
168+ <tal:uses_launchpad_bugtracker
169+ condition="view/bug_tracking_usage/enumvalue:LAUNCHPAD">
170+ <script type="text/javascript"
171+ tal:condition="
172+ request/features/malone.advanced-structural-subscriptions.enabled">
173+ LPS.use('lp.registry.structural_subscription', function(Y) {
174+ var module = Y.lp.registry.structural_subscription;
175+ Y.on('domready', function() {
176+ module.setup({content_box: "#structural-subscription-content-box"});
177+ });
178+ });
179+ </script>
180+ </tal:uses_launchpad_bugtracker>
181 <style type="text/css">
182 p#more-hot-bugs {float:right; margin-top:7px;}
183 </style>
184@@ -177,6 +180,10 @@
185
186 <p id="no-bugs-report"><a href="+filebug">Report a bug.</a></p>
187 </tal:no_hot_bugs>
188+ <div class="yui-u">
189+ <div id="structural-subscription-content-box"></div>
190+ </div>
191+
192 </tal:uses_launchpad_bugtracker>
193
194 <p id="no-malone"
195@@ -224,10 +231,6 @@
196 </p>
197 </div>
198
199- <div class="yui-u">
200- <div id="structural-subscription-content-box"></div>
201- </div>
202-
203 </div><!-- main -->
204 </body>
205 </html>
206
207=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
208--- lib/lp/registry/javascript/structural-subscription.js 2011-04-06 15:53:14 +0000
209+++ lib/lp/registry/javascript/structural-subscription.js 2011-04-07 12:26:29 +0000
210@@ -660,6 +660,9 @@
211 */
212 function setup_overlay(content_box_id, hide_recipient_picker) {
213 var content_node = Y.one(content_box_id);
214+ if (!Y.Lang.isValue(content_node)) {
215+ Y.error("Node not found: " + content_box_id);
216+ }
217 var container = Y.Node.create(
218 '<div id="overlay-container"><dl>' +
219 ' <dt>Bug mail recipient</dt>' +
220@@ -674,7 +677,8 @@
221 ' description help</span></a> ' +
222 ' </dd>' +
223 ' <dt>Receive mail for bugs affecting' +
224- ' <span id="structural-subscription-context-title"></span> that</dt>' +
225+ ' <span id="structural-subscription-context-title"></span> that' +
226+ ' </dt>' +
227 ' <dd>' +
228 ' <div id="events">' +
229 ' <input type="radio" name="events"' +
230@@ -712,7 +716,8 @@
231 ' <dt></dt>' +
232 ' <dd style="margin-left:25px;">' +
233 ' <div id="accordion-overlay"' +
234- ' style="position:relative; overflow:hidden;"></div>' +
235+ ' style="position:relative; overflow:hidden;">' +
236+ ' </div>' +
237 ' </dd>' +
238 ' </dl>' +
239 ' </div> ' +
240@@ -1519,7 +1524,7 @@
241 // Modify the menu-link-subscribe-to-bug-mail link to be visible.
242 var link = Y.one(link_id);
243 if (!Y.Lang.isValue(link)) {
244- Y.Assert.fail('Link to set as the pop-up link not found.');
245+ Y.error('Link to set as the pop-up link not found.');
246 }
247 link.removeClass('invisible-link');
248 link.addClass('visible-link');
249@@ -1549,6 +1554,7 @@
250 }; // setup
251
252 }, '0.1', {requires: [
253- 'dom', 'node', 'test', 'lazr.anim', 'lazr.formoverlay', 'lazr.overlay',
254- 'lazr.effects', 'lp.app.errors', 'lp.client', 'gallery-accordion'
255-]});
256+ 'dom', 'node', 'lazr.anim', 'lazr.formoverlay',
257+ 'lazr.overlay','lazr.effects', 'lp.app.errors', 'lp.client',
258+ 'gallery-accordion'
259+ ]});
260
261=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
262--- lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-04-06 10:45:33 +0000
263+++ lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-04-07 12:26:29 +0000
264@@ -302,6 +302,8 @@
265
266 _should: {
267 error: {
268+ test_setup_overlay_missing_content_box: new Error(
269+ 'Node not found: #sir-not-appearing-in-this-test')
270 }
271 },
272
273@@ -352,6 +354,14 @@
274 header.get('text'));
275 },
276
277+ test_setup_overlay_missing_content_box: function() {
278+ // Pass in a content_box with a missing id to trigger an error.
279+ this.configuration.content_box =
280+ '#sir-not-appearing-in-this-test';
281+ module.setup(this.configuration);
282+ module._setup_overlay(this.configuration.content_box);
283+ },
284+
285 test_initial_state: function() {
286 // When initialized the <div> elements for the filter
287 // wrapper and the accordion wrapper should be collapsed.
288
289=== modified file 'lib/lp/soyuz/javascript/lp_dynamic_dom_updater.js'
290--- lib/lp/soyuz/javascript/lp_dynamic_dom_updater.js 2011-02-24 00:23:04 +0000
291+++ lib/lp/soyuz/javascript/lp_dynamic_dom_updater.js 2011-04-07 12:26:29 +0000
292@@ -344,8 +344,8 @@
293 * @private
294 */
295 _handleFailure: function(id, request) {
296- Y.fail("LP.DynamicDomUpdater for " + this.get("host") +
297- " failed to get dynamic data.");
298+ Y.error("LP.DynamicDomUpdater for " + this.get("host") +
299+ " failed to get dynamic data.");
300 }
301 });
302
303
304=== modified file 'lib/lp/testing/__init__.py'
305--- lib/lp/testing/__init__.py 2011-04-05 00:47:45 +0000
306+++ lib/lp/testing/__init__.py 2011-04-07 12:26:29 +0000
307@@ -1253,7 +1253,7 @@
308 """Provide a temporary directory as a ContextManager."""
309 tempdir = tempfile.mkdtemp()
310 yield tempdir
311- shutil.rmtree(tempdir)
312+ shutil.rmtree(tempdir, ignore_errors=True)
313
314
315 @contextmanager