Merge lp:~henninge/launchpad/bug-753387-ajax-bug-subscription into lp:launchpad

Proposed by Henning Eggers
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 13118
Proposed branch: lp:~henninge/launchpad/bug-753387-ajax-bug-subscription
Merge into: lp:launchpad
Diff against target: 32 lines (+9/-6)
1 file modified
lib/lp/bugs/javascript/bugtask_index_portlets.js (+9/-6)
To merge this branch: bzr merge lp:~henninge/launchpad/bug-753387-ajax-bug-subscription
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+62256@code.launchpad.net

Commit message

[r=danilo][bug=753387] Fix js bug when subscribing w/o structural bug subscriptions feature.

Description of the change

= Summary =

Even without the new "mute" feature enabled (part of structural bug
subscriptions), subscribing and unscribing tried to update the "mute
subscription" node. This failed because that node does not exist if
the feature is not enabled.

== Proposed fix ==

Check if the node exists before doing stuff with it.

== Pre-implementation notes ==

None, all my own thinking.

== Implementation details ==

The check had only to be added in two places although the function that
eventually fails (update_mute_after_subscription_change) is called more
often. Those other call sites are only reached when the feature is
enabled and therefore when the node is actually on the page.
The two affected call sites can easily be spotted because they are the
only ones that call get_mute_subscription directly before.

== Tests ==

None, this is transitional anyway.

== Demo and Q/A ==

Open any bug when the feature is not enabled, open a javascript
console. Click on "Subscribe" and watch that you *don't* see an
error message on the console.
The second callsite is in "Subscribe someone else" but is only
triggered when the user has permissions to also unsubscribe that
other person. I could not (easily) figure out how to get into that
position.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/javascript/bugtask_index_portlets.js

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

I wonder what would be the correct way to trigger a removal of the conditions once the feature flag is removed. Any hints? Add an XXX?

Revision history for this message
Данило Шеган (danilo) wrote :

Looks good. As discussed on IRC, I'd only move the mute check inside update_mute_after_subscription_change, but you did say you considered it. So, your call if you want to do that.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/javascript/bugtask_index_portlets.js'
2--- lib/lp/bugs/javascript/bugtask_index_portlets.js 2011-05-18 18:34:19 +0000
3+++ lib/lp/bugs/javascript/bugtask_index_portlets.js 2011-05-25 08:49:27 +0000
4@@ -768,8 +768,10 @@
5 }
6
7 add_user_name_link(subscription);
8- var mute_subscription = get_mute_subscription();
9- update_mute_after_subscription_change(mute_subscription);
10+ if (namespace.use_advanced_subscriptions) {
11+ var mute_subscription = get_mute_subscription();
12+ update_mute_after_subscription_change(mute_subscription);
13+ }
14
15 // Only when the link is added to the page, indicate success.
16 Y.on('contentready', function() {
17@@ -1392,10 +1394,11 @@
18 if (team_member) {
19 subscription.set('can_be_unsubscribed', true);
20 add_temp_user_name(subscription);
21- var mute_subscription;
22- mute_subscription = get_mute_subscription();
23- update_mute_after_subscription_change(
24- mute_subscription);
25+ if (namespace.use_advanced_subscriptions) {
26+ var mute_subscr = get_mute_subscription();
27+ update_mute_after_subscription_change(
28+ mute_subscr);
29+ }
30 } else {
31 subscription.set(
32 'can_be_unsubscribed', false);