Merge lp:~wallyworld/launchpad/subscriber-portlet-spinner into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 13594
Proposed branch: lp:~wallyworld/launchpad/subscriber-portlet-spinner
Merge into: lp:launchpad
Diff against target: 93 lines (+14/-14)
2 files modified
lib/lp/app/javascript/subscribers/subscribers_list.js (+3/-2)
lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js (+11/-12)
To merge this branch: bzr merge lp:~wallyworld/launchpad/subscriber-portlet-spinner
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+70247@code.launchpad.net

Commit message

[r=stevenk][bug=820146] Small fix to display the Subscribing... spinner as soon as the "Subscribe Me" link is clicked.

Description of the change

Small fix to display the Subscribing... spinner as soon as the "Subscribe Me" link is clicked.

== Implementation ==

The subscription portlet normally needs to first retrieve the subscribee details (via an xhr call) in order to indicate progress and do the next step in the subscribe process. However, in the case of "Subscribe Me" where the subscribers list is not to be updated, then the spinner can be displayed before this first xhr is made.

== Tests ==

Update a couple of test_subscribers_lists.js tests to reflect the new behaviour.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/subscribers/subscribers_list.js
  lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-01 08:03:41 +0000
+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-03 03:56:33 +0000
@@ -354,6 +354,9 @@
354 if (is_subscribed) {354 if (is_subscribed) {
355 loader._unsubscribe_me();355 loader._unsubscribe_me();
356 } else {356 } else {
357 if (!loader.display_me_in_list) {
358 loader.subscribers_list.startActivity("Subscribing...");
359 }
357 loader._subscribePersonURI(360 loader._subscribePersonURI(
358 LP.links.me, loader.subscribe_me_level);361 LP.links.me, loader.subscribe_me_level);
359 }362 }
@@ -459,8 +462,6 @@
459 if (update_subscribers_list) {462 if (update_subscribers_list) {
460 this.subscribers_list.addSubscriber(subscriber, level);463 this.subscribers_list.addSubscriber(subscriber, level);
461 this.subscribers_list.indicateSubscriberActivity(subscriber);464 this.subscribers_list.indicateSubscriberActivity(subscriber);
462 } else {
463 this.subscribers_list.startActivity("Subscribing...");
464 }465 }
465 var loader = this;466 var loader = this;
466467
467468
=== modified file 'lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js'
--- lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-02 01:42:10 +0000
+++ lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-03 03:56:33 +0000
@@ -2187,6 +2187,13 @@
2187 person_uri.match("/~user$"));2187 person_uri.match("/~user$"));
2188 subscribe_done = true;2188 subscribe_done = true;
2189 };2189 };
2190 var activity_started = false;
2191 var old_start = module.SubscribersList.prototype.startActivity;
2192 module.SubscribersList.prototype.startActivity =
2193 function(text) {
2194 Y.Assert.areEqual(text, "Subscribing...");
2195 activity_started = true;
2196 };
21902197
2191 loader._setupSubscribeMe();2198 loader._setupSubscribeMe();
21922199
@@ -2195,12 +2202,14 @@
2195 link.simulate('click');2202 link.simulate('click');
21962203
2197 Y.Assert.isTrue(subscribe_done);2204 Y.Assert.isTrue(subscribe_done);
2205 Y.Assert.isTrue(activity_started, 'activity was not started');
21982206
2199 // Restore original methods.2207 // Restore original methods.
2200 module.SubscribersLoader.prototype._subscribePersonURI =2208 module.SubscribersLoader.prototype._subscribePersonURI =
2201 old_method;2209 old_method;
2202 module.SubscribersLoader.prototype._updateSubscribeMeLink =2210 module.SubscribersLoader.prototype._updateSubscribeMeLink =
2203 old_update_method;2211 old_update_method;
2212 module.SubscribersList.prototype.startActivity = old_start;
2204 },2213 },
22052214
2206 test_unsubscribeMe: function() {2215 test_unsubscribeMe: function() {
@@ -2496,8 +2505,8 @@
24962505
2497 test_subscribe_success_without_list_update: function() {2506 test_subscribe_success_without_list_update: function() {
2498 // When subscribing someone such that the subscribers list should not2507 // When subscribing someone such that the subscribers list should not
2499 // updated, check that the correct start/stop progress indication2508 // updated, check that the correct stop progress indication
2500 // calls are used ie stopActivity is called indicating success.2509 // call is used ie stopActivity is called indicating success.
25012510
2502 var subscriber = { name: "user", self_link: "/~user" };2511 var subscriber = { name: "user", self_link: "/~user" };
25032512
@@ -2507,14 +2516,7 @@
2507 window.LP.links.me = "/~user";2516 window.LP.links.me = "/~user";
25082517
2509 // Mock-up stopActivity to ensure it's called.2518 // Mock-up stopActivity to ensure it's called.
2510 var activity_started = false;
2511 var activity_stopped = false;2519 var activity_stopped = false;
2512 var old_start = module.SubscribersList.prototype.startActivity;
2513 module.SubscribersList.prototype.startActivity =
2514 function(text) {
2515 Y.Assert.areEqual(text, "Subscribing...");
2516 activity_started = true;
2517 };
2518 var old_stop = module.SubscribersList.prototype.stopActivity;2520 var old_stop = module.SubscribersList.prototype.stopActivity;
2519 module.SubscribersList.prototype.stopActivity =2521 module.SubscribersList.prototype.stopActivity =
2520 function() {2522 function() {
@@ -2536,12 +2538,9 @@
2536 };2538 };
25372539
2538 loader._subscribe(person, 'Level1');2540 loader._subscribe(person, 'Level1');
2539
2540 Y.Assert.isTrue(activity_started, 'activity was not started');
2541 Y.Assert.isTrue(activity_stopped, 'activity was not stopped');2541 Y.Assert.isTrue(activity_stopped, 'activity was not stopped');
25422542
2543 // Restore original methods.2543 // Restore original methods.
2544 module.SubscribersList.prototype.startActivity = old_start;
2545 module.SubscribersList.prototype.stopActivity = old_stop;2544 module.SubscribersList.prototype.stopActivity = old_stop;
2546 },2545 },
25472546