launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02338
[Merge] lp:~gmb/launchpad/prepare-for-alpha-features-bug-699719 into lp:launchpad
Graham Binns has proposed merging lp:~gmb/launchpad/prepare-for-alpha-features-bug-699719 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~gmb/launchpad/prepare-for-alpha-features-bug-699719/+merge/46254
This branch paves the way for enabling the new subscriber portlet using
JavaScript.
In order to do this I've moved the setting-up of handlers for the
portlet events into a function which is called at the start of
setup_bugtask_index(). I've also added a variable,
use_advanced_subscriptions, which we can set from the page itself. This
gives us a crude way of enabling malone-alpha features in JavaScript
without too much mucking about in the template.
--
https://code.launchpad.net/~gmb/launchpad/prepare-for-alpha-features-bug-699719/+merge/46254
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/prepare-for-alpha-features-bug-699719 into lp:launchpad.
=== modified file 'lib/lp/bugs/javascript/bugtask_index.js'
--- lib/lp/bugs/javascript/bugtask_index.js 2010-12-20 15:34:16 +0000
+++ lib/lp/bugs/javascript/bugtask_index.js 2011-01-14 12:53:57 +0000
@@ -42,6 +42,13 @@
// The set of subscriber CSS IDs as a JSON struct.
var subscriber_ids;
+// A boolean telling us whether advanced subscription features are to be
+// used or not.
+// XXX 2011-01-14 gmb bug=702859:
+// We need to expose feature flags via the API to avoid this kind of
+// thing.
+var use_advanced_subscriptions = false;
+
/*
* An object representing the bugtask subscribers portlet.
*
@@ -53,92 +60,103 @@
var PortletTarget = function() {};
Y.augment(PortletTarget, Y.Event.Target);
namespace.portlet = new PortletTarget();
-namespace.portlet.subscribe('bugs:portletloaded', function() {
- load_subscriber_ids();
-});
-namespace.portlet.subscribe('bugs:dupeportletloaded', function() {
- setup_unsubscribe_icon_handlers();
-});
-/*
- * If the subscribers portlet fails to load, clear any
- * click handlers, so the normal subscribe page can be reached.
- */
-namespace.portlet.subscribe('bugs:portletloadfailed', function(handlers) {
- if (Y.Lang.isArray(handlers)) {
- var click_handler = handlers[0];
- click_handler.detach();
- }
-});
-/* If the dupe subscribers portlet fails to load,
- * be sure to try to handle any unsub icons that may
- * exist for others.
- */
-namespace.portlet.subscribe('bugs:dupeportletloadfailed', function(handlers) {
- setup_unsubscribe_icon_handlers();
-});
-
-/* If loading the subscriber IDs JSON has succeeded, set up the
- * subscription link handlers and load the subscribers from dupes.
- */
-namespace.portlet.subscribe('bugs:portletsubscriberidsloaded', function() {
- setup_subscription_link_handlers();
- load_subscribers_from_duplicates();
-});
-
-/* If loading the subscriber IDs JSON fails we still need to load the
- * subscribers from duplicates but we don't set up the subscription link
- * handlers.
- */
-namespace.portlet.subscribe('bugs:portletsubscriberidsfailed', function() {
- load_subscribers_from_duplicates();
-});
-
-/*
- * Subscribing someone else requires loading a grayed out
- * username into the DOM until the subscribe action completes.
- * There are a couple XHR requests in check_can_be_unsubscribed
- * before the subscribe work can be done, so fire a custom event
- * bugs:nameloaded and do the work here when the event fires.
- */
-namespace.portlet.subscribe('bugs:nameloaded', function(subscription) {
- var error_handler = new LP.client.ErrorHandler();
- error_handler.clearProgressUI = function() {
- var temp_link = Y.one('#temp-username');
- if (temp_link) {
- var temp_parent = temp_link.get('parentNode');
- temp_parent.removeChild(temp_link);
+
+function setup_portlet_handlers() {
+ namespace.portlet.subscribe('bugs:portletloaded', function() {
+ load_subscriber_ids();
+ });
+ namespace.portlet.subscribe('bugs:dupeportletloaded', function() {
+ setup_unsubscribe_icon_handlers();
+ });
+ /*
+ * If the subscribers portlet fails to load, clear any
+ * click handlers, so the normal subscribe page can be reached.
+ */
+ namespace.portlet.subscribe('bugs:portletloadfailed', function(handlers) {
+ if (Y.Lang.isArray(handlers)) {
+ var click_handler = handlers[0];
+ click_handler.detach();
}
- };
- error_handler.showError = function(error_msg) {
- Y.lp.app.errors.display_error(Y.one('.menu-link-addsubscriber'), error_msg);
- };
-
- var config = {
- on: {
- success: function() {
- var temp_link = Y.one('#temp-username');
- var temp_spinner = Y.one('#temp-name-spinner');
- temp_link.removeChild(temp_spinner);
- var anim = Y.lazr.anim.green_flash({ node: temp_link });
- anim.on('end', function() {
- add_user_name_link(subscription);
- var temp_parent = temp_link.get('parentNode');
- temp_parent.removeChild(temp_link);
- });
- anim.run();
+ });
+ /* If the dupe subscribers portlet fails to load,
+ * be sure to try to handle any unsub icons that may
+ * exist for others.
+ */
+ namespace.portlet.subscribe(
+ 'bugs:dupeportletloadfailed',
+ function(handlers) {
+ setup_unsubscribe_icon_handlers();
+ });
+
+ /* If loading the subscriber IDs JSON has succeeded, set up the
+ * subscription link handlers and load the subscribers from dupes.
+ */
+ namespace.portlet.subscribe(
+ 'bugs:portletsubscriberidsloaded',
+ function() {
+ setup_subscription_link_handlers();
+ load_subscribers_from_duplicates();
+ });
+
+ /* If loading the subscriber IDs JSON fails we still need to load the
+ * subscribers from duplicates but we don't set up the subscription link
+ * handlers.
+ */
+ namespace.portlet.subscribe(
+ 'bugs:portletsubscriberidsfailed',
+ function() {
+ load_subscribers_from_duplicates();
+ });
+
+ /*
+ * Subscribing someone else requires loading a grayed out
+ * username into the DOM until the subscribe action completes.
+ * There are a couple XHR requests in check_can_be_unsubscribed
+ * before the subscribe work can be done, so fire a custom event
+ * bugs:nameloaded and do the work here when the event fires.
+ */
+ namespace.portlet.subscribe('bugs:nameloaded', function(subscription) {
+ var error_handler = new LP.client.ErrorHandler();
+ error_handler.clearProgressUI = function() {
+ var temp_link = Y.one('#temp-username');
+ if (temp_link) {
+ var temp_parent = temp_link.get('parentNode');
+ temp_parent.removeChild(temp_link);
+ }
+ };
+ error_handler.showError = function(error_msg) {
+ Y.lp.app.errors.display_error(
+ Y.one('.menu-link-addsubscriber'), error_msg);
+ };
+
+ var config = {
+ on: {
+ success: function() {
+ var temp_link = Y.one('#temp-username');
+ var temp_spinner = Y.one('#temp-name-spinner');
+ temp_link.removeChild(temp_spinner);
+ var anim = Y.lazr.anim.green_flash({ node: temp_link });
+ anim.on('end', function() {
+ add_user_name_link(subscription);
+ var temp_parent = temp_link.get('parentNode');
+ temp_parent.removeChild(temp_link);
+ });
+ anim.run();
+ },
+ failure: error_handler.getFailureHandler()
},
- failure: error_handler.getFailureHandler()
- },
- parameters: {
- person: LP.client.get_absolute_uri(
- subscription.get('person').get('escaped_uri')),
- suppress_notify: false
- }
- };
- lp_client.named_post(bug_repr.self_link, 'subscribe', config);
-});
+ parameters: {
+ person: LP.client.get_absolute_uri(
+ subscription.get('person').get('escaped_uri')),
+ suppress_notify: false
+ }
+ };
+ lp_client.named_post(bug_repr.self_link, 'subscribe', config);
+ });
+}
namespace.setup_bugtask_index = function() {
+ setup_portlet_handlers();
/*
* Check the page for links related to overlay forms and request the HTML
* for these forms.