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
1=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
2--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-01 08:03:41 +0000
3+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-03 03:56:33 +0000
4@@ -354,6 +354,9 @@
5 if (is_subscribed) {
6 loader._unsubscribe_me();
7 } else {
8+ if (!loader.display_me_in_list) {
9+ loader.subscribers_list.startActivity("Subscribing...");
10+ }
11 loader._subscribePersonURI(
12 LP.links.me, loader.subscribe_me_level);
13 }
14@@ -459,8 +462,6 @@
15 if (update_subscribers_list) {
16 this.subscribers_list.addSubscriber(subscriber, level);
17 this.subscribers_list.indicateSubscriberActivity(subscriber);
18- } else {
19- this.subscribers_list.startActivity("Subscribing...");
20 }
21 var loader = this;
22
23
24=== modified file 'lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js'
25--- lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-02 01:42:10 +0000
26+++ lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-03 03:56:33 +0000
27@@ -2187,6 +2187,13 @@
28 person_uri.match("/~user$"));
29 subscribe_done = true;
30 };
31+ var activity_started = false;
32+ var old_start = module.SubscribersList.prototype.startActivity;
33+ module.SubscribersList.prototype.startActivity =
34+ function(text) {
35+ Y.Assert.areEqual(text, "Subscribing...");
36+ activity_started = true;
37+ };
38
39 loader._setupSubscribeMe();
40
41@@ -2195,12 +2202,14 @@
42 link.simulate('click');
43
44 Y.Assert.isTrue(subscribe_done);
45+ Y.Assert.isTrue(activity_started, 'activity was not started');
46
47 // Restore original methods.
48 module.SubscribersLoader.prototype._subscribePersonURI =
49 old_method;
50 module.SubscribersLoader.prototype._updateSubscribeMeLink =
51 old_update_method;
52+ module.SubscribersList.prototype.startActivity = old_start;
53 },
54
55 test_unsubscribeMe: function() {
56@@ -2496,8 +2505,8 @@
57
58 test_subscribe_success_without_list_update: function() {
59 // When subscribing someone such that the subscribers list should not
60- // updated, check that the correct start/stop progress indication
61- // calls are used ie stopActivity is called indicating success.
62+ // updated, check that the correct stop progress indication
63+ // call is used ie stopActivity is called indicating success.
64
65 var subscriber = { name: "user", self_link: "/~user" };
66
67@@ -2507,14 +2516,7 @@
68 window.LP.links.me = "/~user";
69
70 // Mock-up stopActivity to ensure it's called.
71- var activity_started = false;
72 var activity_stopped = false;
73- var old_start = module.SubscribersList.prototype.startActivity;
74- module.SubscribersList.prototype.startActivity =
75- function(text) {
76- Y.Assert.areEqual(text, "Subscribing...");
77- activity_started = true;
78- };
79 var old_stop = module.SubscribersList.prototype.stopActivity;
80 module.SubscribersList.prototype.stopActivity =
81 function() {
82@@ -2536,12 +2538,9 @@
83 };
84
85 loader._subscribe(person, 'Level1');
86-
87- Y.Assert.isTrue(activity_started, 'activity was not started');
88 Y.Assert.isTrue(activity_stopped, 'activity was not stopped');
89
90 // Restore original methods.
91- module.SubscribersList.prototype.startActivity = old_start;
92 module.SubscribersList.prototype.stopActivity = old_stop;
93 },
94