Merge lp:~brian-murray/launchpad/bug-912137 into lp:launchpad

Proposed by Brian Murray
Status: Merged
Approved by: j.c.sackett
Approved revision: no longer in the source branch.
Merged at revision: 15385
Proposed branch: lp:~brian-murray/launchpad/bug-912137
Merge into: lp:launchpad
Diff against target: 112 lines (+19/-12)
2 files modified
lib/lp/app/javascript/subscribers/subscribers_list.js (+13/-6)
lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js (+6/-6)
To merge this branch: bzr merge lp:~brian-murray/launchpad/bug-912137
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+109045@code.launchpad.net

Commit message

Fixes sort ordering of subscribers in the subscriber portlet

Description of the change

Summary

If you look at a bug like bug 764701 you'll notice the subscribers are sorted in a reverse order of what you would expect. This makes it a bit harder to determine whether or not a specific team or person is subscribed to any bug report. This was reported in bug 912137.

Proposed fix

Instead of inserting subscribers at the start of the list, in subscribers_list.js, we should add them at the end of it.

Tests

bin/test -vv -t test_subscribers_list

Demo and Q/A

I also tested this using the sample data and viewing bug #9 which has two subscribers and confirmed that they were in a normal order.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Brian--

Thanks for this--it's good, it just needs one fix.

As we discussed on IRC, this has the side effect of new subscribers added via the UI being added to the bottom of the list. Because subscriber lists can quite long, new ones should be added to the top so the user can see that they were in fact added.

You could update addSubscriber to accept a parameter that indicates whether it's adding subscribers from a list of existing ones--which should be appended, or is adding a brand new subscriber which should be prepended. If you default this argument to indicate appending, then you should just need to update the call site that is bound to the `Subscribe someone else` button.

review: Needs Fixing
Revision history for this message
j.c.sackett (jcsackett) wrote :

Thanks for addressing the points above!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-11-18 16:20:50 +0000
+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2012-06-08 16:11:26 +0000
@@ -192,10 +192,11 @@
192 }192 }
193 if (this._updateSubscribersList(subscriber)) {193 if (this._updateSubscribersList(subscriber)) {
194 if (subscriber.can_edit === true) {194 if (subscriber.can_edit === true) {
195 this.subscribers_list.addSubscriber(subscriber, level, {195 this.subscribers_list.addSubscriber(subscriber, level,
196 false, {
196 unsubscribe_callback: unsubscribe_callback});197 unsubscribe_callback: unsubscribe_callback});
197 } else {198 } else {
198 this.subscribers_list.addSubscriber(subscriber, level);199 this.subscribers_list.addSubscriber(subscriber, level, false);
199 }200 }
200 }201 }
201};202};
@@ -478,7 +479,7 @@
478 var is_me = this._subscriber_is_me(subscriber);479 var is_me = this._subscriber_is_me(subscriber);
479 var update_subscribers_list = this._updateSubscribersList(subscriber);480 var update_subscribers_list = this._updateSubscribersList(subscriber);
480 if (update_subscribers_list) {481 if (update_subscribers_list) {
481 this.subscribers_list.addSubscriber(subscriber, level);482 this.subscribers_list.addSubscriber(subscriber, level, true);
482 this.subscribers_list.indicateSubscriberActivity(subscriber);483 this.subscribers_list.indicateSubscriberActivity(subscriber);
483 }484 }
484 var loader = this;485 var loader = this;
@@ -967,9 +968,10 @@
967 * @param level {String} Level of the subscription.968 * @param level {String} Level of the subscription.
968 * @param config {Object} Object containing potential 'unsubscribe' callback969 * @param config {Object} Object containing potential 'unsubscribe' callback
969 * in the `unsubscribe_callback` attribute.970 * in the `unsubscribe_callback` attribute.
971 * @param add_new {Boolean} True if the subscriber was newly added
970 */972 */
971SubscribersList.prototype.addSubscriber = function(subscriber, level,973SubscribersList.prototype.addSubscriber = function(subscriber, level,
972 config) {974 add_new, config) {
973 this._checkSubscriptionLevel(level);975 this._checkSubscriptionLevel(level);
974 subscriber = this._validateSubscriber(subscriber);976 subscriber = this._validateSubscriber(subscriber);
975977
@@ -982,8 +984,13 @@
982 if (subscriber_node === null) {984 if (subscriber_node === null) {
983 subscriber_node = this._createSubscriberNode(subscriber);985 subscriber_node = this._createSubscriberNode(subscriber);
984 subscriber_node.set('id', subscriber_id);986 subscriber_node.set('id', subscriber_id);
985 // Insert the subscriber at the start of the list.987 if (add_new === true) {
986 list_node.prepend(subscriber_node);988 // Add new subscriber to the start of the list.
989 list_node.prepend(subscriber_node);
990 } else {
991 // Add the subscriber at the end of the list.
992 list_node.append(subscriber_node);
993 }
987 // Add the unsubscribe action if needed.994 // Add the unsubscribe action if needed.
988 if (Y.Lang.isValue(config) &&995 if (Y.Lang.isValue(config) &&
989 Y.Lang.isFunction(config.unsubscribe_callback)) {996 Y.Lang.isFunction(config.unsubscribe_callback)) {
990997
=== modified file 'lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js'
--- lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2012-04-06 17:28:25 +0000
+++ lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2012-06-08 16:11:26 +0000
@@ -1015,7 +1015,7 @@
10151015
1016 test_addSubscriber_ordering: function() {1016 test_addSubscriber_ordering: function() {
1017 // With multiple subscribers being added to the same section,1017 // With multiple subscribers being added to the same section,
1018 // the last one is listed first.1018 // the last one is listed last.
1019 var subscribers_list = setUpSubscribersList(this.root);1019 var subscribers_list = setUpSubscribersList(this.root);
1020 var node1 = subscribers_list.addSubscriber(1020 var node1 = subscribers_list.addSubscriber(
1021 { name: 'user1' }, 'Level3');1021 { name: 'user1' }, 'Level3');
@@ -1032,7 +1032,7 @@
1032 returned_nodes.push(all_subscribers.item(index));1032 returned_nodes.push(all_subscribers.item(index));
1033 }1033 }
1034 Y.ArrayAssert.itemsAreSame(1034 Y.ArrayAssert.itemsAreSame(
1035 [node2, node1],1035 [node1, node2],
1036 returned_nodes);1036 returned_nodes);
1037 },1037 },
10381038
@@ -1052,7 +1052,7 @@
1052 Y.Assert.areSame(subscriber, unsub_subscriber);1052 Y.Assert.areSame(subscriber, unsub_subscriber);
1053 Y.Assert.areSame(callback, unsub_callback);1053 Y.Assert.areSame(callback, unsub_callback);
1054 };1054 };
1055 subscribers_list.addSubscriber(subscriber, 'Level3',1055 subscribers_list.addSubscriber(subscriber, 'Level3', false,
1056 { unsubscribe_callback: callback });1056 { unsubscribe_callback: callback });
1057 // Setting up a callback was performed.1057 // Setting up a callback was performed.
1058 Y.Assert.isTrue(callback_setup);1058 Y.Assert.isTrue(callback_setup);
@@ -1627,7 +1627,7 @@
1627 // Save the old method for restoring later.1627 // Save the old method for restoring later.
1628 var old_addSub = module.SubscribersList.prototype.addSubscriber;1628 var old_addSub = module.SubscribersList.prototype.addSubscriber;
1629 module.SubscribersList.prototype.addSubscriber = function(1629 module.SubscribersList.prototype.addSubscriber = function(
1630 passed_subscriber, passed_level) {1630 passed_subscriber, passed_level, passed_new) {
1631 call_passed_through = true;1631 call_passed_through = true;
1632 Y.Assert.areSame(subscriber, passed_subscriber);1632 Y.Assert.areSame(subscriber, passed_subscriber);
1633 Y.Assert.areSame(level, passed_level);1633 Y.Assert.areSame(level, passed_level);
@@ -1649,7 +1649,7 @@
1649 // Save the old method for restoring later.1649 // Save the old method for restoring later.
1650 var old_addSub = module.SubscribersList.prototype.addSubscriber;1650 var old_addSub = module.SubscribersList.prototype.addSubscriber;
1651 module.SubscribersList.prototype.addSubscriber = function(1651 module.SubscribersList.prototype.addSubscriber = function(
1652 passed_subscriber, passed_level, passed_config) {1652 passed_subscriber, passed_level, passed_new, passed_config) {
1653 Y.Assert.areSame('Default', passed_level);1653 Y.Assert.areSame('Default', passed_level);
1654 Y.Assert.isUndefined(passed_config);1654 Y.Assert.isUndefined(passed_config);
1655 };1655 };
@@ -1682,7 +1682,7 @@
1682 // Assert in addSubscriber that it's being passed the new1682 // Assert in addSubscriber that it's being passed the new
1683 // callback in the config parameter.1683 // callback in the config parameter.
1684 module.SubscribersList.prototype.addSubscriber = function(1684 module.SubscribersList.prototype.addSubscriber = function(
1685 passed_subscriber, passed_level, passed_config) {1685 passed_subscriber, passed_level, passed_new, passed_config) {
1686 Y.Assert.areSame(unsubscribe_callback,1686 Y.Assert.areSame(unsubscribe_callback,
1687 passed_config.unsubscribe_callback);1687 passed_config.unsubscribe_callback);
1688 };1688 };