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

Proposed by Brian Murray on 2012-06-06
Status: Merged
Approved by: j.c.sackett on 2012-06-07
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) 2012-06-06 Approve on 2012-06-07
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.
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
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
1=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
2--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-11-18 16:20:50 +0000
3+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2012-06-08 16:11:26 +0000
4@@ -192,10 +192,11 @@
5 }
6 if (this._updateSubscribersList(subscriber)) {
7 if (subscriber.can_edit === true) {
8- this.subscribers_list.addSubscriber(subscriber, level, {
9+ this.subscribers_list.addSubscriber(subscriber, level,
10+ false, {
11 unsubscribe_callback: unsubscribe_callback});
12 } else {
13- this.subscribers_list.addSubscriber(subscriber, level);
14+ this.subscribers_list.addSubscriber(subscriber, level, false);
15 }
16 }
17 };
18@@ -478,7 +479,7 @@
19 var is_me = this._subscriber_is_me(subscriber);
20 var update_subscribers_list = this._updateSubscribersList(subscriber);
21 if (update_subscribers_list) {
22- this.subscribers_list.addSubscriber(subscriber, level);
23+ this.subscribers_list.addSubscriber(subscriber, level, true);
24 this.subscribers_list.indicateSubscriberActivity(subscriber);
25 }
26 var loader = this;
27@@ -967,9 +968,10 @@
28 * @param level {String} Level of the subscription.
29 * @param config {Object} Object containing potential 'unsubscribe' callback
30 * in the `unsubscribe_callback` attribute.
31+ * @param add_new {Boolean} True if the subscriber was newly added
32 */
33 SubscribersList.prototype.addSubscriber = function(subscriber, level,
34- config) {
35+ add_new, config) {
36 this._checkSubscriptionLevel(level);
37 subscriber = this._validateSubscriber(subscriber);
38
39@@ -982,8 +984,13 @@
40 if (subscriber_node === null) {
41 subscriber_node = this._createSubscriberNode(subscriber);
42 subscriber_node.set('id', subscriber_id);
43- // Insert the subscriber at the start of the list.
44- list_node.prepend(subscriber_node);
45+ if (add_new === true) {
46+ // Add new subscriber to the start of the list.
47+ list_node.prepend(subscriber_node);
48+ } else {
49+ // Add the subscriber at the end of the list.
50+ list_node.append(subscriber_node);
51+ }
52 // Add the unsubscribe action if needed.
53 if (Y.Lang.isValue(config) &&
54 Y.Lang.isFunction(config.unsubscribe_callback)) {
55
56=== modified file 'lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js'
57--- lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2012-04-06 17:28:25 +0000
58+++ lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2012-06-08 16:11:26 +0000
59@@ -1015,7 +1015,7 @@
60
61 test_addSubscriber_ordering: function() {
62 // With multiple subscribers being added to the same section,
63- // the last one is listed first.
64+ // the last one is listed last.
65 var subscribers_list = setUpSubscribersList(this.root);
66 var node1 = subscribers_list.addSubscriber(
67 { name: 'user1' }, 'Level3');
68@@ -1032,7 +1032,7 @@
69 returned_nodes.push(all_subscribers.item(index));
70 }
71 Y.ArrayAssert.itemsAreSame(
72- [node2, node1],
73+ [node1, node2],
74 returned_nodes);
75 },
76
77@@ -1052,7 +1052,7 @@
78 Y.Assert.areSame(subscriber, unsub_subscriber);
79 Y.Assert.areSame(callback, unsub_callback);
80 };
81- subscribers_list.addSubscriber(subscriber, 'Level3',
82+ subscribers_list.addSubscriber(subscriber, 'Level3', false,
83 { unsubscribe_callback: callback });
84 // Setting up a callback was performed.
85 Y.Assert.isTrue(callback_setup);
86@@ -1627,7 +1627,7 @@
87 // Save the old method for restoring later.
88 var old_addSub = module.SubscribersList.prototype.addSubscriber;
89 module.SubscribersList.prototype.addSubscriber = function(
90- passed_subscriber, passed_level) {
91+ passed_subscriber, passed_level, passed_new) {
92 call_passed_through = true;
93 Y.Assert.areSame(subscriber, passed_subscriber);
94 Y.Assert.areSame(level, passed_level);
95@@ -1649,7 +1649,7 @@
96 // Save the old method for restoring later.
97 var old_addSub = module.SubscribersList.prototype.addSubscriber;
98 module.SubscribersList.prototype.addSubscriber = function(
99- passed_subscriber, passed_level, passed_config) {
100+ passed_subscriber, passed_level, passed_new, passed_config) {
101 Y.Assert.areSame('Default', passed_level);
102 Y.Assert.isUndefined(passed_config);
103 };
104@@ -1682,7 +1682,7 @@
105 // Assert in addSubscriber that it's being passed the new
106 // callback in the config parameter.
107 module.SubscribersList.prototype.addSubscriber = function(
108- passed_subscriber, passed_level, passed_config) {
109+ passed_subscriber, passed_level, passed_new, passed_config) {
110 Y.Assert.areSame(unsubscribe_callback,
111 passed_config.unsubscribe_callback);
112 };