Merge lp:~gary/launchpad/bug740631 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: 10639
Proposed branch: lp:~gary/launchpad/bug740631
Merge into: lp:launchpad/db-devel
Diff against target: 640 lines (+171/-108)
11 files modified
lib/canonical/launchpad/icing/sprite.css.in (+8/-0)
lib/lp/bugs/browser/bug.py (+4/-4)
lib/lp/bugs/browser/bugsubscription.py (+15/-9)
lib/lp/bugs/browser/tests/test_bug_views.py (+10/-0)
lib/lp/bugs/browser/tests/test_bugsubscription_views.py (+43/-8)
lib/lp/bugs/javascript/bugtask_index_portlets.js (+56/-52)
lib/lp/bugs/javascript/subscription.js (+9/-10)
lib/lp/bugs/javascript/tests/test_subscription.js (+6/-9)
lib/lp/bugs/templates/bug-portlet-subscription.pt (+3/-2)
lib/lp/registry/javascript/structural-subscription.js (+6/-6)
lib/lp/registry/javascript/tests/test_structural_subscription.js (+11/-8)
To merge this branch: bzr merge lp:~gary/launchpad/bug740631
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+63251@code.launchpad.net

Commit message

[r=danilo][bug=740631] Fix multiple problems with the mute functionality and interactions on the bug page, add separate mute/unmute icons, and fix other assorted problems along the way.

Description of the change

Despite the fact that the name of this branch is bug740631 (adding distinguishable icons for mute and unmute), the main point of it is to polish up the mute/unmute changes before they go live to everyone next week. We expected them to be addressed by our rework of these bits for bug 772754, but that's not quite ready yet. Therefore, this branch spends a bit of time polishing what we have.

This addresses the following issues identified by Danilo in his qa of the work for bug 772763:

> - "Unmute" links keeps pointing to "+subscribe" instead of "+mute" (+mute page was changed to
> support both muting/unmuting, and doesn't redirect to +subscribe when bug mail is muted anymore);
> this means that people will be sent to the wrong page if they have no JS

This was a simple change in lib/lp/bugs/browser/bug.py, in the code that draws the link. It also adds the new mute/unmute icons.

> - When there is a mute on a bug, but no subscription, clicking on "Subscribe" fails to pop-up the
> window; also, going to +subscribe page renders an empty form which doesn't work in that case (this
> two are likely related)

I addressed this by adding an option within lib/lp/bugs/browser/bugsubscription.py to "unmute and subscribe", which means that there is actually something to draw, in addition to being a reasonable option for a user to see when they click on "subscribe".

> - When one tries to "Subscribe" originally (or unmute when they have an old subscription, or
> unsubscribe yourself), subscription overlay pop-up stays loaded when you click on check-mark to
> apply the action even though the action succeeds; this is especially bad if there's an error since
> then the error pop-up is below the subscription overlay

I found this to be tricky to address with the existing JS, but the changes in lib/lp/bugs/javascript/bugtask_index_portlets.js seem to do the right thing.

I also addressed the following problems.

- Anonymous users would get an OOPS when they visited a bug page if the feature flag was turned on for them.

- test_unmute_unmutes was getting a cached value for self.bug.isSubscribed, which did not actually demonstrate the desired end state. I changed the code to use the pattern elsewhere in the file. An alternative approach that works is to commit the transaction, but I thought this was preferable.

- In some cases, two instances of the user's name would be added to the "directly subscribed" display.

- In some cases, an instance of the user's name would turn permanently green after a success "flash".

- +subscriptions had not been modified to take advantage of the new mute functionality. I did so by changing options.

- The test for the ellipsis hack in lib/lp/registry/javascript/tests/test_structural_subscription.js did not work in webkit-based browsers.

In addition to that, I added in the new mute/unmute icons Huw provided for bug 740631.

Thank you,

Gary

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Other than the check Y.Lang.isValue(do_next) which you promised to make Y.Lang.isFunction(do_next), everything looks great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/icing/sprite.css.in'
2--- lib/canonical/launchpad/icing/sprite.css.in 2011-03-23 01:05:54 +0000
3+++ lib/canonical/launchpad/icing/sprite.css.in 2011-06-02 16:23:03 +0000
4@@ -45,6 +45,14 @@
5 background-image: url(/@@/yes.png); /* sprite-ref: icon-sprites */
6 background-repeat: no-repeat;
7 }
8+.mute {
9+ background-image: url(/@@/mute.png); /* sprite-ref: icon-sprites */
10+ background-repeat: no-repeat;
11+ }
12+.unmute {
13+ background-image: url(/@@/unmute.png); /* sprite-ref: icon-sprites */
14+ background-repeat: no-repeat;
15+ }
16 .crowd {
17 background-image: url(/@@/crowd.png); /* sprite-ref: icon-sprites */
18 background-repeat: no-repeat;
19
20=== added file 'lib/canonical/launchpad/images/mute.png'
21Binary files lib/canonical/launchpad/images/mute.png 1970-01-01 00:00:00 +0000 and lib/canonical/launchpad/images/mute.png 2011-06-02 16:23:03 +0000 differ
22=== added file 'lib/canonical/launchpad/images/unmute.png'
23Binary files lib/canonical/launchpad/images/unmute.png 1970-01-01 00:00:00 +0000 and lib/canonical/launchpad/images/unmute.png 2011-06-02 16:23:03 +0000 differ
24=== modified file 'lib/lp/bugs/browser/bug.py'
25--- lib/lp/bugs/browser/bug.py 2011-05-20 14:48:53 +0000
26+++ lib/lp/bugs/browser/bug.py 2011-06-02 16:23:03 +0000
27@@ -285,13 +285,13 @@
28 user = getUtility(ILaunchBag).user
29 if self.context.bug.isMuted(user):
30 text = "Unmute bug mail"
31- link = "+subscribe"
32+ icon = 'unmute'
33 else:
34 text = "Mute bug mail"
35- link = "+mute"
36+ icon = 'mute'
37
38 return Link(
39- link, text, icon='remove', summary=(
40+ '+mute', text, icon=icon, summary=(
41 "Mute this bug so that you will not receive emails "
42 "about it."))
43
44@@ -537,7 +537,7 @@
45 def user_should_see_mute_link(self):
46 """Return True if the user should see the Mute link."""
47 if features.getFeatureFlag('malone.advanced-subscriptions.enabled'):
48- user_is_subscribed = (
49+ user_is_subscribed = self.user is not None and (
50 self.context.isMuted(self.user) or
51 self.context.isSubscribed(self.user) or
52 self.context.isSubscribedToDupes(self.user) or
53
54=== modified file 'lib/lp/bugs/browser/bugsubscription.py'
55--- lib/lp/bugs/browser/bugsubscription.py 2011-05-24 19:33:23 +0000
56+++ lib/lp/bugs/browser/bugsubscription.py 2011-06-02 16:23:03 +0000
57@@ -275,10 +275,18 @@
58 'unsubscribe <a href="%s">%s</a> from this bug' % (
59 canonical_url(person),
60 cgi.escape(person.displayname))))
61- if not self_subscribed and not is_really_muted:
62- subscription_terms.insert(0,
63- SimpleTerm(
64- self.user, self.user.name, 'subscribe me to this bug'))
65+ if not self_subscribed:
66+ if not is_really_muted:
67+ subscription_terms.insert(0,
68+ SimpleTerm(
69+ self.user, self.user.name,
70+ 'subscribe me to this bug'))
71+ elif not self.user_is_subscribed_directly:
72+ subscription_terms.insert(0,
73+ SimpleTerm(
74+ 'update-subscription', 'update-subscription',
75+ 'unmute bug mail from this bug and subscribe me to '
76+ 'this bug'))
77
78 # Add punctuation to the list of terms.
79 if len(subscription_terms) > 1:
80@@ -289,7 +297,7 @@
81
82 subscription_vocabulary = SimpleVocabulary(subscription_terms)
83 if (self._use_advanced_features and
84- self.user_is_subscribed_directly):
85+ (self.user_is_subscribed_directly or self.user_is_muted)):
86 default_subscription_value = self._update_subscription_term.value
87 else:
88 default_subscription_value = (
89@@ -319,7 +327,7 @@
90 if self._use_advanced_features:
91 self.widgets['bug_notification_level'].widget_class = (
92 'bug-notification-level-field')
93- if self._subscriber_count_for_current_user == 0:
94+ if (len(self.form_fields['subscription'].field.vocabulary)==1):
95 # We hide the subscription widget if the user isn't
96 # subscribed, since we know who the subscriber is and we
97 # don't need to present them with a single radio button.
98@@ -330,9 +338,7 @@
99 # subscribe theirself or unsubscribe their team.
100 self.widgets['subscription'].visible = True
101
102- if (self.user_is_subscribed_to_dupes_only or
103- (self._use_advanced_features and self.user_is_muted and
104- not self.user_is_subscribed)):
105+ if self.user_is_subscribed_to_dupes_only:
106 # If the user is subscribed via a duplicate but is not
107 # directly subscribed, we hide the
108 # bug_notification_level field, since it's not used.
109
110=== modified file 'lib/lp/bugs/browser/tests/test_bug_views.py'
111--- lib/lp/bugs/browser/tests/test_bug_views.py 2011-05-24 19:33:23 +0000
112+++ lib/lp/bugs/browser/tests/test_bug_views.py 2011-06-02 16:23:03 +0000
113@@ -203,6 +203,16 @@
114 self._hasCSSClass(html, 'mute-link-container', 'hidden'),
115 'No "hidden" CSS class in mute-link-container.')
116
117+ def test_mute_subscription_link_not_rendered_for_anonymous(self):
118+ # If a person is not already subscribed to a bug in some way,
119+ # the mute link will not be displayed to them.
120+ with FeatureFixture({self.feature_flag_1: 'on'}):
121+ view = create_initialized_view(
122+ self.bug, name="+portlet-subscription")
123+ self.assertFalse(view.user_should_see_mute_link)
124+ html = view.render()
125+ self.assertFalse('mute_subscription' in html)
126+
127 def test_mute_subscription_link_shown_if_muted(self):
128 # If a person is muted but not otherwise subscribed, they should still
129 # see the (un)mute link.
130
131=== modified file 'lib/lp/bugs/browser/tests/test_bugsubscription_views.py'
132--- lib/lp/bugs/browser/tests/test_bugsubscription_views.py 2011-05-24 19:33:23 +0000
133+++ lib/lp/bugs/browser/tests/test_bugsubscription_views.py 2011-06-02 16:23:03 +0000
134@@ -227,7 +227,7 @@
135 self.assertFalse(
136 harness.view.widgets['bug_notification_level'].visible)
137
138- def test_muted_subs_have_unmute_option(self):
139+ def test_muted_subs_have_subscribe_option_and_unmute_option(self):
140 # If a user has a muted subscription, but no previous
141 # direct bug subscription, the BugSubscriptionSubscribeSelfView's
142 # subscription field will show an "Unmute" option.
143@@ -240,10 +240,14 @@
144 self.bug.default_bugtask, name='+subscribe')
145 subscription_widget = (
146 subscribe_view.widgets['subscription'])
147- # The Unmute option is actually treated the same way as
148- # the unsubscribe option.
149- self.assertEqual(
150- "unmute bug mail from this bug",
151+ update_term = subscription_widget.vocabulary.getTermByToken(
152+ 'update-subscription')
153+ self.assertEqual(
154+ "unmute bug mail from this bug and subscribe me to this "
155+ "bug, or",
156+ update_term.title)
157+ self.assertEqual(
158+ "unmute bug mail from this bug.",
159 subscription_widget.vocabulary.getTerm(self.person).title)
160
161 def test_muted_subs_have_unmute_and_restore_option(self):
162@@ -270,8 +274,8 @@
163 update_term.title)
164
165 def test_unmute_unmutes(self):
166- # Using the "Unmute bug mail" option when the user has a muted
167- # subscription will unmute.
168+ # Using the "Unmute bug mail" option when the user has muted their
169+ # email will unmute.
170 with person_logged_in(self.person):
171 self.bug.mute(self.person, self.person)
172
173@@ -287,7 +291,38 @@
174 self.bug.default_bugtask, form=form_data,
175 name='+subscribe')
176 self.assertFalse(self.bug.isMuted(self.person))
177- self.assertFalse(self.bug.isSubscribed(self.person))
178+ subscription = self.bug.getSubscriptionForPerson(self.person)
179+ self.assertIs(
180+ None, subscription,
181+ "There should be no BugSubscription for this person.")
182+
183+ def test_unmute_and_subscribe(self):
184+ # Using the "unmute bug mail from this bug and subscribe me to this
185+ # bug" option when the user has muted their email will unmute and
186+ # subscribe.
187+ with FeatureFixture({self.feature_flag: ON}):
188+ with person_logged_in(self.person):
189+ self.bug.mute(self.person, self.person)
190+ level = BugNotificationLevel.METADATA
191+ form_data = {
192+ 'field.subscription': 'update-subscription',
193+ 'field.bug_notification_level': level.title,
194+ # Although this isn't used we must pass it for the
195+ # sake of form validation.
196+ 'field.actions.continue': 'Continue',
197+ }
198+ create_initialized_view(
199+ self.bug.default_bugtask, form=form_data,
200+ name='+subscribe')
201+ self.assertFalse(self.bug.isMuted(self.person))
202+ subscription = self.bug.getSubscriptionForPerson(self.person)
203+ self.assertEqual(
204+ BugNotificationLevel.METADATA,
205+ subscription.bug_notification_level,
206+ "Bug notification level of subscription should be METADATA, is "
207+ "actually %s." % (subscription.bug_notification_level.title
208+ if subscription is not None
209+ else '[not subscribed!]'))
210
211 def test_bug_notification_level_field_has_widget_class(self):
212 # The bug_notification_level widget has a widget_class property
213
214=== modified file 'lib/lp/bugs/javascript/bugtask_index_portlets.js'
215--- lib/lp/bugs/javascript/bugtask_index_portlets.js 2011-05-26 06:20:57 +0000
216+++ lib/lp/bugs/javascript/bugtask_index_portlets.js 2011-06-02 16:23:03 +0000
217@@ -305,8 +305,8 @@
218 Y.lp.app.errors.display_error(link, error_msg);
219 };
220 handler.clearProgressUI = hide_spinner;
221- return function (e) {
222- if (!Y.Lang.isUndefined(e)) {
223+ return function (e, do_next) {
224+ if (Y.Lang.isValue(e)) {
225 e.halt();
226 }
227 var is_muted = parent_node.hasClass('muted-true');
228@@ -353,6 +353,9 @@
229 set_subscription_link_parent_class(
230 subscription_link, is_subscribed, is_dupe_subscribed);
231 subscription.disable_spinner(label);
232+ if (Y.Lang.isFunction(do_next)) {
233+ do_next(response);
234+ }
235 },
236 failure: handler.getFailureHandler()
237 },
238@@ -366,7 +369,7 @@
239 * Toggle the mute state.
240 */
241
242-function toggle_mute() {
243+function toggle_mute(do_next) {
244 if (LP.links.me === undefined) {
245 return;
246 }
247@@ -374,7 +377,7 @@
248 if (Y.Lang.isNull(link)) {
249 return;
250 }
251- return _get_toggle_mute(link)();
252+ return _get_toggle_mute(link)(null, do_next);
253 }
254
255 /*
256@@ -391,9 +394,11 @@
257 if (is_muted) {
258 parent_node.replaceClass('muted-false', 'muted-true');
259 link.set('innerHTML', "Unmute bug mail");
260+ link.replaceClass('mute', 'unmute');
261 } else {
262 parent_node.replaceClass('muted-true', 'muted-false');
263 link.set('innerHTML', "Mute bug mail");
264+ link.replaceClass('unmute', 'mute');
265 }
266 }
267
268@@ -788,13 +793,6 @@
269 if (namespace.use_advanced_subscriptions) {
270 update_mute_after_subscription_change();
271 }
272-
273- // Only when the link is added to the page, indicate success.
274- Y.on('contentready', function() {
275- var flash_node = Y.one('.' + subscriber.get('css_name'));
276- var anim = Y.lazr.anim.green_flash({ node: flash_node });
277- anim.run();
278- }, '.' + subscriber.get('css_name'));
279 },
280
281 failure: error_handler.getFailureHandler()
282@@ -948,10 +946,10 @@
283 var html = Y.Node.create('<div><a></a></div>');
284 html.addClass(terms.css_name);
285
286- if (subscription.is_direct_subscription()) {
287+ if (subscription.has_duplicate_subscriptions()) {
288+ html.set('id', 'dupe-' + terms.css_name);
289+ } else {
290 html.set('id', 'direct-' + terms.css_name);
291- } else {
292- html.set('id', 'dupe-' + terms.css_name);
293 }
294
295 html.one('a')
296@@ -1184,46 +1182,52 @@
297 var subscription_url =
298 lp_bug_entry.get('self_link') + '/+subscription/' +
299 person_name;
300- config = {
301- on: {
302- success: function(lp_subscription) {
303- subscription.enable_spinner('Updating subscription...');
304- lp_subscription.set(
305+ var update_subscription = function(lp_subscription) {
306+ subscription.enable_spinner('Updating subscription...');
307+ lp_subscription.set(
308+ 'bug_notification_level',
309+ form_data['field.bug_notification_level'][0]);
310+ save_config = {
311+ on: {
312+ success: function(e) {
313+ subscription.disable_spinner(
314+ 'Edit subscription');
315+ link_parent.addClass('subscribed-true');
316+ link_parent.removeClass('subscribed-false');
317+ var anim = Y.lazr.anim.green_flash({
318+ node: link_parent
319+ });
320+ anim.run();
321+ },
322+ failure: function(e) {
323+ subscription.disable_spinner(
324+ 'Edit subscription');
325+ var anim = Y.lazr.anim.red_flash({
326+ node: link_parent
327+ });
328+ anim.run();
329+ }
330+ }
331+ };
332+ lp_subscription.lp_save(save_config);
333+ };
334+ if (is_muted) {
335+ toggle_mute(function(lp_subscription) {
336+ if (Y.Lang.isValue(lp_subscription)) {
337+ update_subscription(lp_subscription);
338+ } else {
339+ subscription.set(
340 'bug_notification_level',
341- form_data['field.bug_notification_level'][0]);
342- save_config = {
343- on: {
344- success: function(e) {
345- subscription.disable_spinner(
346- 'Edit subscription');
347- link_parent.addClass('subscribed-true');
348- link_parent.removeClass('subscribed-false');
349- var anim = Y.lazr.anim.green_flash({
350- node: link_parent
351- });
352- anim.run();
353- if (is_muted) {
354- // We're going to assume that the user
355- // wants to unmute also, since they
356- // bothered to change their subscription.
357- toggle_mute();
358- }
359- },
360- failure: function(e) {
361- subscription.disable_spinner(
362- 'Edit subscription');
363- var anim = Y.lazr.anim.red_flash({
364- node: link_parent
365- });
366- anim.run();
367- }
368- }
369- };
370- lp_subscription.lp_save(save_config);
371+ form_data['field.bug_notification_level']);
372+ subscribe_current_user(subscription);
373 }
374- }
375- };
376- lp_client.get(subscription_url, config);
377+ });
378+ } else {
379+ lp_client.get(
380+ subscription_url,
381+ {on: {success: update_subscription}}
382+ );
383+ }
384
385 } else if (link_parent.hasClass('subscribed-false') &&
386 link_parent.hasClass('dup-subscribed-false') &&
387
388=== modified file 'lib/lp/bugs/javascript/subscription.js'
389--- lib/lp/bugs/javascript/subscription.js 2011-05-24 15:16:49 +0000
390+++ lib/lp/bugs/javascript/subscription.js 2011-06-02 16:23:03 +0000
391@@ -29,7 +29,7 @@
392 NOT_PERSONALLY_SUBSCRIBED: (
393 "You are not directly subscribed to this bug, " +
394 "but you have other subscriptions."),
395- MUTED_SUBSCRIPTION: "You have muted all email from this bug."
396+ MUTED_SUBSCRIPTION: "You have muted all your direct email from this bug."
397 };
398 namespace._reasons = reasons;
399
400@@ -717,9 +717,6 @@
401 // The user has a muted direct subscription.
402 reason = reasons.MUTED_SUBSCRIPTION;
403 increases.push(action_ids.unmute);
404- increases.push(action_ids.subscribe_all);
405- increases.push(action_ids.subscribe_metadata);
406- increases.push(action_ids.subscribe_closed);
407 } else if (info.direct.personal.length > 0) {
408 // The user has a direct personal subscription.
409 if (info.direct.personal.length > 1) {
410@@ -775,6 +772,7 @@
411 reductions.push(action_ids.mute);
412 reductions.push(action_ids.subscribe_only_metadata);
413 reductions.push(action_ids.subscribe_only_closed);
414+ increases.push(action_ids.subscribe_all);
415 }
416 return {reason: reason, reductions: reductions, increases: increases};
417 }
418@@ -879,7 +877,7 @@
419 .append(
420 make_action_link(
421 'mute all emails from this bug',
422- 'no', 'mute', {}));
423+ 'mute', 'mute', {}));
424 }
425 namespace._mute_action = mute_action;
426
427@@ -890,8 +888,8 @@
428 return make_action(action_ids.unmute)
429 .append(
430 make_action_link(
431- 'receive emails about this bug from other subscriptions',
432- 'yes', 'unmute', {}));
433+ 'unmute emails from this bug',
434+ 'unmute', 'unmute', {}));
435 }
436 namespace._unmute_action = unmute_action;
437
438@@ -1064,15 +1062,16 @@
439 info.direct.count += 1;
440 info.count += 1;
441 }
442- info.muted = (
443- sub.bug_notification_level ===
444- 'Nothing');
445 } else {
446 if (Y.Lang.isValue(old)) {
447 info.direct.personal.pop();
448 info.direct.count -= 1;
449 info.count -= 1;
450 }
451+ }
452+ if (method_name === 'mute') {
453+ info.muted = true;
454+ } else if (method_name === 'unmute') {
455 info.muted = false;
456 }
457 reveal_direct_description_actions(
458
459=== modified file 'lib/lp/bugs/javascript/tests/test_subscription.js'
460--- lib/lp/bugs/javascript/tests/test_subscription.js 2011-04-25 13:33:31 +0000
461+++ lib/lp/bugs/javascript/tests/test_subscription.js 2011-06-02 16:23:03 +0000
462@@ -1020,7 +1020,7 @@
463 'select-only-direct-subscription-lifecycle'],
464 direct_info.reductions);
465 Y.ArrayAssert.itemsAreEqual(
466- [],
467+ ['select-direct-subscription-discussion'],
468 direct_info.increases);
469 },
470
471@@ -1042,7 +1042,7 @@
472 'select-only-direct-subscription-lifecycle'],
473 direct_info.reductions);
474 Y.ArrayAssert.itemsAreEqual(
475- [],
476+ ['select-direct-subscription-discussion'],
477 direct_info.increases);
478 },
479
480@@ -1061,10 +1061,7 @@
481 [],
482 direct_info.reductions);
483 Y.ArrayAssert.itemsAreEqual(
484- ['unmute-direct-subscription',
485- 'select-direct-subscription-discussion',
486- 'select-direct-subscription-metadata',
487- 'select-direct-subscription-lifecycle'],
488+ ['unmute-direct-subscription'],
489 direct_info.increases);
490 },
491
492@@ -1753,14 +1750,14 @@
493 this.assert_action_matches_expectations(
494 module._mute_action, module._action_ids.mute,
495 'mute all emails from this bug',
496- 'no', 'mute', {}, true, true);
497+ 'mute', 'mute', {}, true, true);
498 },
499
500 test_unmute_action: function() {
501 this.assert_action_matches_expectations(
502 module._unmute_action, module._action_ids.unmute,
503- 'receive emails about this bug from other subscriptions',
504- 'yes', 'unmute', {}, true, false);
505+ 'unmute emails from this bug',
506+ 'unmute', 'unmute', {}, true, false);
507 },
508
509 test_subscribe_all_action: function() {
510
511=== modified file 'lib/lp/bugs/templates/bug-portlet-subscription.pt'
512--- lib/lp/bugs/templates/bug-portlet-subscription.pt 2011-05-20 21:09:40 +0000
513+++ lib/lp/bugs/templates/bug-portlet-subscription.pt 2011-06-02 16:23:03 +0000
514@@ -14,8 +14,9 @@
515 <div id="sub-unsub-spinner">Subscribing...</div>
516 <div tal:condition="request/features/malone.advanced-structural-subscriptions.enabled"
517 tal:content="structure context_menu/editsubscriptions/render" />
518- <tal:show-mute condition="
519- request/features/malone.advanced-subscriptions.enabled">
520+ <tal:show-mute
521+ define="enabled request/features/malone.advanced-subscriptions.enabled"
522+ condition="python: view.user and enabled">
523 <div tal:attributes="class view/current_user_mute_class"
524 id="mute-link-container">
525 <span tal:replace="structure context_menu/mute_subscription/render"
526
527=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
528--- lib/lp/registry/javascript/structural-subscription.js 2011-05-18 18:50:39 +0000
529+++ lib/lp/registry/javascript/structural-subscription.js 2011-06-02 16:23:03 +0000
530@@ -19,8 +19,8 @@
531 ADVANCED_FILTER = 'advanced-filter',
532 MATCH_ALL = 'match-all',
533 MATCH_ANY = 'match-any',
534- MUTE_ICON_CLASS = 'no',
535- UNMUTE_ICON_CLASS = 'yes'
536+ MUTE_ICON_CLASS = 'mute',
537+ UNMUTE_ICON_CLASS = 'unmute'
538 ;
539
540 var cancel_button_html =
541@@ -328,9 +328,9 @@
542 typeof document.createElement('span').style.textOverflow === 'string';
543 var is_gecko = navigator.product === 'Gecko';
544 // If we're running on a Gecko-based browser (like Firefox) and it doesn't
545-// have text-overflow then use the ellipsis hack.
546-var using_ellipsis_hack = is_gecko && !ellipsis_supported;
547-
548+// have text-overflow then use the ellipsis hack. We put it on the namespace
549+// so tests can manipulate it.
550+namespace.using_ellipsis_hack = is_gecko && !ellipsis_supported;
551 /**
552 * Populate the overlay element with the contents of the add/edit form.
553 */
554@@ -378,7 +378,7 @@
555 if (side_portlets) {
556 Y.one('#subscription-overlay-title').scrollIntoView();
557 }
558- if (using_ellipsis_hack) {
559+ if (namespace.using_ellipsis_hack) {
560 // Look away.
561 var header_text = header.get('text');
562 var i;
563
564=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
565--- lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-05-18 18:50:39 +0000
566+++ lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-06-02 16:23:03 +0000
567@@ -422,11 +422,14 @@
568
569 this.content_node = create_test_node();
570 Y.one('body').appendChild(this.content_node);
571+ this.using_ellipsis_hack = module.using_ellipsis_hack;
572+ module.using_ellipsis_hack = true;
573 },
574
575 tearDown: function() {
576 remove_test_node();
577 delete this.content_node;
578+ module.using_ellipsis_hack = this.using_ellipsis_hack;
579 },
580
581 test_title_ellipsisification: function() {
582@@ -1684,7 +1687,7 @@
583 Assert.areEqual(mute_label_node.getStyle('display'), 'none');
584 var mute_link = filter_node.one('a.mute-subscription');
585 Assert.isNotNull(mute_link);
586- Assert.isTrue(mute_link.hasClass('no'));
587+ Assert.isTrue(mute_link.hasClass('mute'));
588 },
589
590 test_muted_rendering: function() {
591@@ -1700,7 +1703,7 @@
592 Assert.areEqual(mute_label_node.getStyle('display'), 'inline');
593 var mute_link = filter_node.one('a.mute-subscription');
594 Assert.isNotNull(mute_link);
595- Assert.isTrue(mute_link.hasClass('yes'));
596+ Assert.isTrue(mute_link.hasClass('unmute'));
597 },
598
599 test_not_muted_toggle_muted: function() {
600@@ -1720,7 +1723,7 @@
601 Assert.areEqual(
602 this.lp_client.received[0][1][1], 'mute');
603 Assert.areEqual(mute_label_node.getStyle('display'), 'inline');
604- Assert.isTrue(mute_link.hasClass('yes'));
605+ Assert.isTrue(mute_link.hasClass('unmute'));
606 },
607
608 test_muted_toggle_not_muted: function() {
609@@ -1741,7 +1744,7 @@
610 Assert.areEqual(
611 this.lp_client.received[0][1][1], 'unmute');
612 Assert.areEqual(mute_label_node.getStyle('display'), 'none');
613- Assert.isTrue(mute_link.hasClass('no'));
614+ Assert.isTrue(mute_link.hasClass('mute'));
615 },
616
617 test_mute_spinner: function () {
618@@ -1756,9 +1759,9 @@
619 this.lp_client.named_post.halt = true;
620 mute_link.simulate('click');
621 Assert.isTrue(mute_link.hasClass('spinner'));
622- Assert.isFalse(mute_link.hasClass('no'));
623+ Assert.isFalse(mute_link.hasClass('mute'));
624 this.lp_client.named_post.resume();
625- Assert.isTrue(mute_link.hasClass('yes'));
626+ Assert.isTrue(mute_link.hasClass('unmute'));
627 Assert.isFalse(mute_link.hasClass('spinner'));
628 },
629
630@@ -1775,9 +1778,9 @@
631 this.lp_client.named_post.halt = true;
632 mute_link.simulate('click');
633 Assert.isTrue(mute_link.hasClass('spinner'));
634- Assert.isFalse(mute_link.hasClass('no'));
635+ Assert.isFalse(mute_link.hasClass('mute'));
636 this.lp_client.named_post.resume();
637- Assert.isTrue(mute_link.hasClass('no'));
638+ Assert.isTrue(mute_link.hasClass('mute'));
639 Assert.isFalse(mute_link.hasClass('spinner'));
640 }
641

Subscribers

People subscribed via source and target branches

to status/vote changes: