← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~benji/launchpad/bug-753152-this-time-for-sure into lp:launchpad/db-devel

 

Benji York has proposed merging lp:~benji/launchpad/bug-753152-this-time-for-sure into lp:launchpad/db-devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-753152-this-time-for-sure/+merge/57672

This branch (really) addresses bug 753152 by adding a help link explaining what
enable/disable link does, and more importantly what it does not.
-- 
https://code.launchpad.net/~benji/launchpad/bug-753152-this-time-for-sure/+merge/57672
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-753152-this-time-for-sure into lp:launchpad/db-devel.
=== added file 'lib/lp/bugs/help/structural-subscription-mute.html'
--- lib/lp/bugs/help/structural-subscription-mute.html	1970-01-01 00:00:00 +0000
+++ lib/lp/bugs/help/structural-subscription-mute.html	2011-04-14 12:47:27 +0000
@@ -0,0 +1,26 @@
+<html>
+  <head>
+    <title>What happens when I disable delivery?</title>
+    <link rel="stylesheet" type="text/css"
+          href="/+icing/yui/cssreset/reset.css" />
+    <link rel="stylesheet" type="text/css"
+          href="/+icing/yui/cssfonts/fonts.css" />
+    <link rel="stylesheet" type="text/css"
+          href="/+icing/yui/cssbase/base.css" />
+  </head>
+  <body>
+    <h1>What happens when I disable delivery?</h1>
+
+    <p>
+      Sometimes you will be subscribed to a bug target (like a project) via a
+      team subscription, but you may not want to receive the notifications.  If
+      so, you can disable the delivery of the messages to yourself without
+      affecting the other team members.
+    </p>
+    <p>
+      However, if a team delivers its bug messages via a mailing list or some
+      other preferred email, disabling email delivery will not be honored
+      because doing so would prevent the other team members from receiving the
+      notifications.
+  </body>
+</html>

=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
--- lib/lp/registry/javascript/structural-subscription.js	2011-04-12 08:08:42 +0000
+++ lib/lp/registry/javascript/structural-subscription.js	2011-04-14 12:47:27 +0000
@@ -1234,12 +1234,12 @@
     var label = node.one('em.mute-label');
     var description = node.one('.filter-description');
     if (muted) {
-        control.set('text', 'Receive emails from this subscription');
+        control.set('text', 'Enable emails from this subscription');
         control.replaceClass(MUTE_ICON_CLASS, UNMUTE_ICON_CLASS);
         label.setStyle('display', null);
         description.setStyle('color', '#bbb');
     } else {
-        control.set('text', 'Do not receive emails from this subscription');
+        control.set('text', 'Disable emails from this subscription');
         control.replaceClass(UNMUTE_ICON_CLASS, MUTE_ICON_CLASS);
         label.setStyle('display', 'none');
         description.setStyle('color', null);
@@ -1268,32 +1268,47 @@
     var can_edit = (!filter_info.subscriber_is_team ||
                     filter_info.user_is_team_admin);
 
-    // Whitespace is stripped from the left and right of the string
-    // when you make a node, so we have to build the string with the
-    // intermediate whitespace and then create the node at the end.
-    var control_template = '';
+    var control = filter_node.appendChild(
+        Y.Node.create('<span style="float: right"></span>'))
 
     if (filter_info.can_mute) {
-        control_template += (
-            '<a href="#" class="sprite js-action mute-subscription"></a>');
-        if (can_edit) {
-            control_template += ' or ';
-        }
+        var link = control.appendChild(Y.Node.create(
+            '<a href="#" class="sprite js-action mute-subscription"></a>'))
+        var help = control.appendChild(Y.Node.create(
+            '<a target="help" class="sprite maybe mute-help"'+
+            '    style="visibility: hidden;"'+
+            '    href="/+help/structural-subscription-mute.html">'+
+            '  <span class="invisible-link">Delivery help</span>'+
+            '</a>'));
+        // We store a reference to the timeout that will hide the help link so
+        // we can cancel it if needed.
+        var hide_help_timeout;
+        function show_help() {
+            help.setStyle('visibility', 'visible');
+            // Every time we trigger the display of the help link we need to
+            // cancel any pending hiding of the help link so it doesn't
+            // dissapear on us.  If there isn't one pending, this is a NOP.
+            clearTimeout(hide_help_timeout);
+        }
+        function hide_help() {
+            hide_help_timeout = setTimeout(function () {
+                help.setStyle('visibility', 'hidden');
+            }, 2000);
+        }
+        link.on('hover', show_help, hide_help);
+        help.on('hover', show_help, hide_help);
     }
     if (can_edit) {
         // User can edit the subscription.
-        control_template += (
-            '<a href="#" class="sprite modify edit js-action '+
-                '    edit-subscription">Edit this subscription</a> or '+
-                '<a href="#" class="sprite modify remove js-action '+
-                '    delete-subscription">Unsubscribe</a>');
+        control.append(Y.Node.create(
+            '<a href="#" style="margin-right: 2em;"'+
+            '    class="sprite modify edit js-action edit-subscription">'+
+            '  Edit this subscription</a>'+
+            '<a href="#" class="sprite modify remove js-action '+
+            '    delete-subscription">Unsubscribe</a>'));
     }
 
     filter_node.appendChild(
-        Y.Node.create(
-            '<span style="float: right"></span>'))
-        .appendChild(Y.Node.create(control_template));
-    filter_node.appendChild(
         Y.Node.create('<div style="padding-left: 1em" '+
                       'class="filter-description"></div>'));
 

=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
--- lib/lp/registry/javascript/tests/test_structural_subscription.js	2011-04-12 08:08:42 +0000
+++ lib/lp/registry/javascript/tests/test_structural_subscription.js	2011-04-14 12:47:27 +0000
@@ -1495,6 +1495,65 @@
 
     }));
 
+    suite.add(new Y.Test.Case({
+        name: 'Structural Subscription: enable/disable help link',
+
+        _should: {error: {}},
+
+        setUp: function() {
+            this.original_lp = monkeypatch_LP();
+
+            LP.cache.subscription_info = [{
+                target_url: 'http://example.com',
+                target_title:'Example project',
+                filters: [{
+                    filter: {
+                        description: 'DESCRIPTION',
+                        statuses: [],
+                        importances: [],
+                        tags: [],
+                        find_all_tags: true,
+                        bug_notification_level: 'Discussion',
+                        self_link: 'http://example.com/a_filter'
+                        },
+                    can_mute: true,
+                    is_muted: false,
+                    subscriber_is_team: true,
+                    subscriber_url: 'http://example.com/subscriber',
+                    subscriber_title: 'Thidwick',
+                    user_is_team_admin: false
+                }]
+            }];
+
+
+            this.configuration = {
+                content_box: content_box_id,
+                lp_client: make_lp_client_stub()
+            };
+            this.content_node = create_test_node(true);
+            Y.one('body').appendChild(this.content_node);
+        },
+
+        tearDown: function() {
+            window.LP = this.original_lp;
+            remove_test_node();
+            delete this.content_node;
+        },
+
+        test_help_link_hover: function() {
+            module.setup_bug_subscriptions(this.configuration);
+
+            // Initially the help link is not visible.
+            var help = Y.one('a.mute-help')
+            Assert.isFalse(help.getStyle('visibility') === 'visible');
+
+            // If we hover over the enable/disable (mute) link it becomes visible.
+            Y.one('a.mute-subscription').simulate('mouseover');
+            Assert.areEqual('visible', help.getStyle('visibility'));
+        }
+
+    }));
+
     // Lock, stock, and two smoking barrels.
     var handle_complete = function(data) {
         var status_node = Y.Node.create(