Merge lp:~rvb/launchpad/dds-req-packagediff-fix-flashing into lp:launchpad

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 12719
Proposed branch: lp:~rvb/launchpad/dds-req-packagediff-fix-flashing
Merge into: lp:launchpad
Diff against target: 134 lines (+45/-18)
4 files modified
lib/lp/registry/javascript/distroseriesdifferences_details.js (+5/-10)
lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.html (+5/-3)
lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.js (+31/-4)
lib/lp/registry/templates/distroseriesdifference-listing-extra.pt (+4/-1)
To merge this branch: bzr merge lp:~rvb/launchpad/dds-req-packagediff-fix-flashing
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+55775@code.launchpad.net

Commit message

[r=jcsackett][bug=746277] Fix the retry link to request package diffs on localpackagediffs page.

Description of the change

This branch fixes the retry link to request package diffs so that removing the link removes all the js listeners.

== Summary ==
On the +localpackagediffs page, when a package diff fails, a retry link is displayed. The listener was not properly cleared so it seemed that the clickable zone of this retry link was far too wide. This branch refactors the way the initial link is added so that removing it clears all the js listeners.

== Tests ==
lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.html

== QA ==
On a failing package diff request (https://dogfood.launchpad.net/deribuntu/dangerous/+localpackagediffs), make sure than the Retry click listener is limited to the word "Retry".

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

As I said in IRC, it could be worth getting a UI person to validate your decision not to have the red flash animation anymore. I think you're notion of already getting instant feedback is correct--it's your call if you think you should get UI checks on it too.

Otherwise, this looks good. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/javascript/distroseriesdifferences_details.js'
2--- lib/lp/registry/javascript/distroseriesdifferences_details.js 2011-03-28 16:33:48 +0000
3+++ lib/lp/registry/javascript/distroseriesdifferences_details.js 2011-03-31 15:43:56 +0000
4@@ -457,7 +457,7 @@
5 */
6 namespace.setup_request_derived_diff = function(container, dsd_link) {
7 // Setup handler for diff requests.
8- container.one('.package-diff-placeholder').on('click', function(e) {
9+ container.one('.package-diff-compute-request').on('click', function(e) {
10 e.preventDefault();
11 compute_package_diff(container, dsd_link);
12 });
13@@ -511,7 +511,7 @@
14 };
15 var failure_cb = function(transaction_id, response, args) {
16 container.one('p.update-in-progress-message').remove();
17- var retry_handler = function(e) {
18+ var recompute = function(e) {
19 e.preventDefault();
20 compute_package_diff(container, dsd_link);
21 };
22@@ -519,20 +519,15 @@
23 var msg = response.responseText;
24
25 // If the error is not of the type raised by an error properly
26- // raisedby python then set a standard error message.
27+ // raised by python then set a standard error message.
28 if (response.status !== 400) {
29 msg = 'Failed to compute package diff.';
30 }
31 var failure_msg = Y.lp.soyuz.base.makeFailureNode(
32- Y.Escape.html(msg), retry_handler);
33- var placeholder = container.one('.package-diff-placeholder')
34+ Y.Escape.html(msg), recompute);
35+ var placeholder = container.one('.package-diff-placeholder');
36 placeholder.set('innerHTML','');
37 placeholder.appendChild(failure_msg);
38-
39- var anim = Y.lazr.anim.red_flash({
40- node: placeholder
41- });
42- anim.run();
43 };
44 var config = {
45 on: {
46
47=== modified file 'lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.html'
48--- lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.html 2011-03-28 20:45:09 +0000
49+++ lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.html 2011-03-31 15:43:56 +0000
50@@ -42,9 +42,11 @@
51 evolution</a>
52 <span class="package-diff-button"></span>
53 <dt class="package-diff-placeholder">
54- <a class="js-action sprite add" href="#">
55- Compute differences from last common version:
56- </a></dt>
57+ <span class="package-diff-compute-request">
58+ <a class="js-action sprite add" href="">
59+ Compute differences from last common version:
60+ </a>
61+ </span></dt>
62 <dd>
63 <ul class="package-diff-status">
64 <li>
65
66=== modified file 'lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.js'
67--- lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.js 2011-03-28 21:32:35 +0000
68+++ lib/lp/registry/javascript/tests/test_distroseriesdifferences_details.js 2011-03-31 15:43:56 +0000
69@@ -75,10 +75,37 @@
70 config.on.success(completed_voc);
71 }
72 };
73-
74 dsd_details.poll_interval = 2000;
75-
76- },
77+ },
78+
79+ test_request_wrong_click: function() {
80+ // Click on the placeholder has no effect.
81+ // The listeners are on the the link with class
82+ // '.package-diff-compute-request'.
83+ // bug=746277.
84+ var placeholder = Y.one('#placeholder');
85+ placeholder.set('innerHTML', placeholder_content);
86+ placeholder
87+ .one('#derived')
88+ .removeClass('PENDING')
89+ .addClass('FAILED');
90+ dsd_details.setup_packages_diff_states(
91+ placeholder.one('.diff-extra-container'), dsd_uri);
92+ var func_req = undefined;
93+ var lp_prot = Y.lp.client.Launchpad.prototype;
94+ lp_prot.named_post = function(url, func, config) {
95+ func_req = func;
96+ config.on.success();
97+ };
98+
99+ var wrong_button = placeholder.one('.package-diff-placeholder');
100+
101+ wrong_button.simulate('click');
102+ var package_diff = Y.one('#parent');
103+
104+ // The request has not been triggered.
105+ Assert.isTrue(package_diff.hasClass('request-derived-diff'));
106+ },
107
108 test_request_package_diff_computation: function() {
109 // A click on the button changes the package diff status and requests
110@@ -98,7 +125,7 @@
111 config.on.success();
112 };
113
114- var button = Y.one('.package-diff-placeholder');
115+ var button = placeholder.one('.package-diff-compute-request');
116
117 button.simulate('click');
118 var package_diff = Y.one('#parent');
119
120=== modified file 'lib/lp/registry/templates/distroseriesdifference-listing-extra.pt'
121--- lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-03-31 05:54:22 +0000
122+++ lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-03-31 15:43:56 +0000
123@@ -42,7 +42,10 @@
124 <dt
125 tal:condition="python: not(context.package_diff) or not(context.parent_package_diff)"
126 class="package-diff-placeholder">
127- <a class="js-action sprite add" href="#">Compute differences from last common version</a>:
128+ <span class="package-diff-compute-request">
129+ <a class="js-action sprite add" href="">
130+ Compute differences from last common version</a>:
131+ </span>
132 </dt>
133 <dt
134 tal:condition="python: context.package_diff and context.parent_package_diff">