launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02438
[Merge] lp:~gmb/launchpad/hooky-hooky-bug-699719 into lp:launchpad
Graham Binns has proposed merging lp:~gmb/launchpad/hooky-hooky-bug-699719 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#699719 Update the subscription JS to use the new subscription widget
https://bugs.launchpad.net/bugs/699719
For more details, see:
https://code.launchpad.net/~gmb/launchpad/hooky-hooky-bug-699719/+merge/47803
This adds code to bugtask-index.js to make a new overlay appear when
advanced subscriptions are enabled (though this code will not yet work
unless you deliberately trigger it, since further work is needed on it;
I'll file separate bugs about this).
Changes made:
== lib/lp/bugs/browser/bugsubscription.py ==
- I've updated the Bug:+subscribe form so that the constructed
vocabulary for the bug_notification_level field uses each
BugNotificationLevel's title attribute rather than its name attribute
for the vocabulary tokens. This makes bug_notification_level behave
in the same way as all other vocabulary-driven fields in Launchpad
and saves us some Javascript heartache.
== lib/lp/bugs/javascript/bugtask_index.js ==
- I've updated the onClick handler for the Subscribe link, which is
created in setup_subscription_link_handlers(), so that it now creates
a FormOverlay populated with the form from Bug:+subscribe/++form++.
This overlay can then be used to subscribe at a given
BugNotificationLevel (but not to edit an existing subscription, which
is why it's not activated yet).
== lib/lp/bugs/javascript/subscriber.js ==
- I've added a bug_notification_level field to the Subscription class
to enable us to pass bug_notification_level when we call
bug.subscribe via the API.
--
https://code.launchpad.net/~gmb/launchpad/hooky-hooky-bug-699719/+merge/47803
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/hooky-hooky-bug-699719 into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugsubscription.py'
--- lib/lp/bugs/browser/bugsubscription.py 2011-01-21 20:23:43 +0000
+++ lib/lp/bugs/browser/bugsubscription.py 2011-01-28 13:21:18 +0000
@@ -109,7 +109,7 @@
# form. The BugNotificationLevel descriptions are too generic.
bug_notification_level_terms = [
SimpleTerm(
- level, level.name,
+ level, level.title,
self._bug_notification_level_descriptions[level])
# We reorder the items so that COMMENTS comes first. We also
# drop the NOTHING option since it just makes the UI
=== modified file 'lib/lp/bugs/javascript/bugtask_index.js'
--- lib/lp/bugs/javascript/bugtask_index.js 2011-01-21 05:10:55 +0000
+++ lib/lp/bugs/javascript/bugtask_index.js 2011-01-28 13:21:18 +0000
@@ -332,7 +332,33 @@
// the current user.
if (parent.hasClass('subscribed-false') &&
parent.hasClass('dup-subscribed-false')) {
- subscribe_current_user(subscription);
+ if (namespace.use_advanced_subscriptions) {
+ var subscription_link_url = subscription.get(
+ 'link').get('href') + '/++form++';
+ var subscription_overlay = new Y.lazr.FormOverlay({
+ headerContent: '<h2>Subscribe to bug</h2>',
+ form_submit_button:
+ Y.Node.create(submit_button_html),
+ form_cancel_button:
+ Y.Node.create(cancel_button_html),
+ centered: true,
+ visible: false
+ });
+ subscription_overlay.set(
+ 'form_submit_callback', function(form_data) {
+ subscription.set(
+ 'bug_notification_level',
+ form_data['field.bug_notification_level']);
+ subscribe_current_user(subscription);
+ subscription_overlay.hide();
+ });
+ subscription_overlay.loadFormContentAndRender(
+ subscription_link_url);
+ subscription_overlay.render('#privacy-form-container');
+ subscription_overlay.show();
+ } else {
+ subscribe_current_user(subscription);
+ }
}
else {
unsubscribe_current_user(subscription);
@@ -1209,6 +1235,12 @@
subscription.enable_spinner('Subscribing...');
var subscription_link = subscription.get('link');
var subscriber = subscription.get('subscriber');
+ var bug_notification_level = subscription.get('bug_notification_level');
+ if (!Y.Lang.isValue(bug_notification_level)) {
+ // If bug_notification_level is undefined for some reason, we
+ // just use the default, which is 'Comments'.
+ bug_notification_level = 'Discussion';
+ }
var error_handler = new LP.client.ErrorHandler();
error_handler.clearProgressUI = function () {
@@ -1251,7 +1283,8 @@
parameters: {
person: LP.client.get_absolute_uri(subscriber.get('escaped_uri')),
- suppress_notify: false
+ suppress_notify: false,
+ level: bug_notification_level
}
};
lp_client.named_post(bug_repr.self_link, 'subscribe', config);
=== modified file 'lib/lp/bugs/javascript/subscriber.js'
--- lib/lp/bugs/javascript/subscriber.js 2010-07-11 00:32:53 +0000
+++ lib/lp/bugs/javascript/subscriber.js 2011-01-28 13:21:18 +0000
@@ -52,6 +52,10 @@
'spinner': {
vallue: null
+ },
+
+ 'bug_notification_level': {
+ value: 'Discussion'
}
};