Merge lp:~gary/launchpad/bug750561-2 into lp:launchpad/db-devel

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 10421
Proposed branch: lp:~gary/launchpad/bug750561-2
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~gary/launchpad/bug750561-2-base-merge
Diff against target: 135 lines (+60/-7)
2 files modified
lib/lp/registry/javascript/structural-subscription.js (+19/-5)
lib/lp/registry/javascript/tests/test_structural_subscription.js (+41/-2)
To merge this branch: bzr merge lp:~gary/launchpad/bug750561-2
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+57216@code.launchpad.net

Commit message

[r=benji][bug=750561] add a spinner for when you mute a structural subscription.

Description of the change

This branch adds an activity indicator (spinner) to the team structural subscription per-person "mute" UI. It is a follow-on to https://code.launchpad.net/~gary/launchpad/bug750561/+merge/57195 which adds spinners for adding, editing, and deleting. This is done separately because the muting functionality is only in db-devel.

This branch has a dependency on that previous branch. I merged it into db-devel and resolved conflicts in order to give this MP a clean diff.

In the tests, as with the previous branch, I cleaned up and normalized our use of "simulate" as part of the work.

To look at the effects, follow these instructions http://pastebin.ubuntu.com/592749/ and then add a subscription for a team. The new subscription will allow you to change whether you personally receive these messages. Toggling this value will briefly show the spinner.

To QA, make sure you are in a team that has access to the feature-flagged UI (or simply be happy that it is behind feature flags, and move on).

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good.

Unlike some of the other string constants in this file, I like the use
of descriptive names for the muted and unmuted CSS classes.

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/registry/javascript/structural-subscription.js'
2--- lib/lp/registry/javascript/structural-subscription.js 2011-04-11 18:47:29 +0000
3+++ lib/lp/registry/javascript/structural-subscription.js 2011-04-11 18:47:30 +0000
4@@ -18,7 +18,9 @@
5 ADDED_OR_CHANGED = 'added-or-changed',
6 ADVANCED_FILTER = 'advanced-filter',
7 MATCH_ALL = 'match-all',
8- MATCH_ANY = 'match-any'
9+ MATCH_ANY = 'match-any',
10+ MUTE_ICON_CLASS = 'no',
11+ UNMUTE_ICON_CLASS = 'yes'
12 ;
13
14 var add_subscription_overlay;
15@@ -1137,9 +1139,19 @@
16 */
17 function make_mute_handler(filter_info, node){
18 var error_handler = new Y.lp.client.ErrorHandler();
19+ var mute_node = node.one('a.mute-subscription');
20+ var icon_class = function () {
21+ if (filter_info.is_muted) {
22+ return UNMUTE_ICON_CLASS;
23+ } else {
24+ return MUTE_ICON_CLASS;
25+ }
26+ }
27 error_handler.showError = function(error_msg) {
28- var mute_node = node.one('a.mute-subscription');
29- Y.lp.app.errors.display_error(mute_node, error_msg);
30+ Y.lp.app.errors.display_error(mute_node, error_msg);
31+ };
32+ error_handler.clearProgressUI = function () {
33+ mute_node.replaceClass('spinner', icon_class());
34 };
35 return function() {
36 var fname;
37@@ -1150,6 +1162,7 @@
38 }
39 var config = {
40 on: {success: function(){
41+ mute_node.removeClass('spinner');
42 if (fname === 'mute') {
43 filter_info.is_muted = true;
44 } else {
45@@ -1160,6 +1173,7 @@
46 failure: error_handler.getFailureHandler()
47 }
48 };
49+ mute_node.replaceClass(icon_class(), 'spinner');
50 namespace.lp_client.named_post(filter_info.filter.self_link,
51 fname, config);
52 };
53@@ -1219,12 +1233,12 @@
54 var description = node.one('.filter-description');
55 if (muted) {
56 control.set('text', 'Receive emails from this subscription');
57- control.replaceClass('no', 'yes');
58+ control.replaceClass(MUTE_ICON_CLASS, UNMUTE_ICON_CLASS);
59 label.setStyle('display', null);
60 description.setStyle('color', '#bbb');
61 } else {
62 control.set('text', 'Do not receive emails from this subscription');
63- control.replaceClass('yes', 'no');
64+ control.replaceClass(UNMUTE_ICON_CLASS, MUTE_ICON_CLASS);
65 label.setStyle('display', 'none');
66 description.setStyle('color', null);
67 }
68
69=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
70--- lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-04-11 18:47:29 +0000
71+++ lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-04-11 18:47:30 +0000
72@@ -1421,7 +1421,7 @@
73 var mute_label_node = filter_node.one('.mute-label');
74 var mute_link = filter_node.one('a.mute-subscription');
75 this.lp_client.named_post.args = []
76- Y.Event.simulate(Y.Node.getDOMNode(mute_link), 'click');
77+ mute_link.simulate('click');
78 Assert.areEqual(this.lp_client.received[0][0], 'named_post');
79 Assert.areEqual(
80 this.lp_client.received[0][1][0],
81@@ -1443,7 +1443,7 @@
82 var mute_label_node = filter_node.one('.mute-label');
83 var mute_link = filter_node.one('a.mute-subscription');
84 this.lp_client.named_post.args = []
85- Y.Event.simulate(Y.Node.getDOMNode(mute_link), 'click');
86+ mute_link.simulate('click');
87 Assert.areEqual(this.lp_client.received[0][0], 'named_post');
88 Assert.areEqual(
89 this.lp_client.received[0][1][0],
90@@ -1452,6 +1452,45 @@
91 this.lp_client.received[0][1][1], 'unmute');
92 Assert.areEqual(mute_label_node.getStyle('display'), 'none');
93 Assert.isTrue(mute_link.hasClass('no'));
94+ },
95+
96+ test_mute_spinner: function () {
97+ // The mute link shows a spinner while a mute is requested.
98+ // When the mute succeeds, the spinner is removed.
99+ module.setup_bug_subscriptions(
100+ {content_box: content_box_id,
101+ lp_client: this.lp_client});
102+ var listing = this.test_node.one(subscription_listing_id);
103+ var filter_node = listing.one('#subscription-filter-0');
104+ var mute_link = filter_node.one('a.mute-subscription');
105+ this.lp_client.named_post.args = []
106+ this.lp_client.named_post.halt = true
107+ mute_link.simulate('click');
108+ Assert.isTrue(mute_link.hasClass('spinner'));
109+ Assert.isFalse(mute_link.hasClass('no'));
110+ this.lp_client.named_post.resume();
111+ Assert.isTrue(mute_link.hasClass('yes'));
112+ Assert.isFalse(mute_link.hasClass('spinner'));
113+ },
114+
115+ test_mute_spinner_fail: function () {
116+ // The mute link shows a spinner while a mute is requested.
117+ // If the mute fails, the spinner is removed.
118+ module.setup_bug_subscriptions(
119+ {content_box: content_box_id,
120+ lp_client: this.lp_client});
121+ var listing = this.test_node.one(subscription_listing_id);
122+ var filter_node = listing.one('#subscription-filter-0');
123+ var mute_link = filter_node.one('a.mute-subscription');
124+ this.lp_client.named_post.fail = true
125+ this.lp_client.named_post.args = [true, true];
126+ this.lp_client.named_post.halt = true
127+ mute_link.simulate('click');
128+ Assert.isTrue(mute_link.hasClass('spinner'));
129+ Assert.isFalse(mute_link.hasClass('no'));
130+ this.lp_client.named_post.resume();
131+ Assert.isTrue(mute_link.hasClass('no'));
132+ Assert.isFalse(mute_link.hasClass('spinner'));
133 }
134
135 }));

Subscribers

People subscribed via source and target branches

to status/vote changes: