Merge lp:~rharding/launchpad/reportbug into lp:launchpad

Proposed by Richard Harding on 2012-07-18
Status: Merged
Approved by: Richard Harding on 2012-07-18
Approved revision: no longer in the source branch.
Merged at revision: 15657
Proposed branch: lp:~rharding/launchpad/reportbug
Merge into: lp:launchpad
Diff against target: 152 lines (+21/-29)
6 files modified
lib/lp/app/javascript/listing_navigator.js (+4/-18)
lib/lp/app/javascript/tests/test_listing_navigator.js (+1/-1)
lib/lp/bugs/javascript/buglisting.js (+6/-3)
lib/lp/bugs/javascript/tests/test_buglisting.js (+2/-2)
lib/lp/registry/javascript/sharing/shareetable.js (+8/-4)
lib/lp/registry/javascript/sharing/tests/test_shareetable.js (+0/-1)
To merge this branch: bzr merge lp:~rharding/launchpad/reportbug
Reviewer Review Type Date Requested Status
Raphaël Badin (community) 2012-07-18 Approve on 2012-07-18
Francesco Banconi (community) code* 2012-07-18 Approve on 2012-07-18
Review via email: mp+115562@code.launchpad.net

Commit Message

Update the buglisting updated navigation to scope css selctors.

Description of the Change

= Summary =

I missed a point where the linked navigation gets updated by later events and
would render the report a bug link inert again.

So this is a follow up from:
https://code.launchpad.net/~rharding/launchpad/1024866_buglink/+merge/115117

== Implementation Notes ==

I noticed that we should be using the container of the ListingNavigator object
instance and moved the methods to using that to constrain the targeting.

Since linkify_navigation isn't on the instance, but a module method, we have
to pass in the instance info we need in the form of the container node.

== Tests ==

lib/lp/bugs/javascript/tests/test_listing_navigator.js
lib/lp/registry/javascript/sharing/tests/test_shareetable.html
lib/lp/registry/javascript/sharing/tests/test_pillarsharingview.html

To post a comment you must log in.
Francesco Banconi (frankban) wrote :

Looks good, thanks Richard.

review: Approve (code*)
Raphaël Badin (rvb) wrote :

Looks good.

[0]

101 - '<a class="previous" href="http://example.org/">PreVious</span>' +
102 - '<div id="client-listing"></div>' +
103 + '<a class="previous" href="http://example.org/">PreVious</a>' +
104 + '<div id="client-listing"></div>' +

I've spotted the fix (s/span/a/) but the indentation seems off.

[1]

119 - Y.lp.app.listing_navigator.linkify_navigation('#sharee-table-listing');
120 + Y.lp.app.listing_navigator.linkify_navigation(target);

You explained to me on IRC why this doesn't require a test code change so FTR:

│18:39:46 rick_h_ | rvba: no, the sharee test code didn't test the navigation html at all relying on the underlying code to test/do it
│18:40:26 rick_h_ | rvba: thought about adding a test, but wasn't sure if it was worth the LoC to test what's tested already.

review: Approve
Richard Harding (rharding) wrote :

> Looks good.
>
> [0]
>
> 101 - '<a class="previous"
> href="http://example.org/">PreVious</span>' +
> 102 - '<div id="client-listing"></div>' +
> 103 + '<a class="previous"
> href="http://example.org/">PreVious</a>' +
> 104 + '<div id="client-listing"></div>' +
>
> I've spotted the fix (s/span/a/) but the indentation seems off.

The indentation was done just to indicate that there's a nested html structure there. The bug here is not limiting to the parent node scope and just tried to bring out that there's a parent there.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/listing_navigator.js'
2--- lib/lp/app/javascript/listing_navigator.js 2012-07-16 12:15:49 +0000
3+++ lib/lp/app/javascript/listing_navigator.js 2012-07-18 15:40:26 +0000
4@@ -30,21 +30,6 @@
5
6
7 /**
8- * Generate selector helpers so that we only find nodes within our own
9- * UI.
10- */
11-module.one = function (parent, selector) {
12- var updated_selector = parent + " " + selector;
13- return Y.one(updated_selector);
14-};
15-
16-module.all = function (parent, selector) {
17- var updated_selector = parent + " " + selector;
18- return Y.all(updated_selector);
19-};
20-
21-
22-/**
23 * Constructor.
24 *
25 * A simplistic model of the current batch.
26@@ -199,9 +184,10 @@
27 * Call the callback when a node matching the selector is clicked.
28 *
29 * The node is also marked up appropriately.
30+ * Scoped at the parentNode of the target.
31 */
32 clickAction: function(selector, callback) {
33- var nodes = Y.all(selector);
34+ var nodes = this.get('target').get('parentNode').all(selector);
35 nodes.on('click', function(e) {
36 e.preventDefault();
37 callback.call(this);
38@@ -536,9 +522,9 @@
39 * Rewrite all nodes with navigation classes so that they are hyperlinks.
40 * Content is retained.
41 */
42-module.linkify_navigation = function(parent_selector) {
43+module.linkify_navigation = function(container_node) {
44 Y.each(['previous', 'next', 'first', 'last'], function(class_name) {
45- module.all(parent_selector, '.' + class_name).each(function(node) {
46+ container_node.all('.' + class_name).each(function(node) {
47 new_node = Y.Node.create('<a href="#"></a>');
48 new_node.addClass(class_name);
49 new_node.setContent(node.getContent());
50
51=== modified file 'lib/lp/app/javascript/tests/test_listing_navigator.js'
52--- lib/lp/app/javascript/tests/test_listing_navigator.js 2012-07-16 11:50:02 +0000
53+++ lib/lp/app/javascript/tests/test_listing_navigator.js 2012-07-18 15:40:26 +0000
54@@ -188,7 +188,7 @@
55 '<span class="first">FiRST</span>' +
56 '<span class="last">lAst</span>' +
57 '</div>');
58- module.linkify_navigation('#bugs-table-listing');
59+ module.linkify_navigation(Y.one('#bugs-table-listing'));
60 function checkNav(selector, content) {
61 var nodelist = Y.all(selector);
62 nodelist.each(function (node) {
63
64=== modified file 'lib/lp/bugs/javascript/buglisting.js'
65--- lib/lp/bugs/javascript/buglisting.js 2012-07-16 11:50:02 +0000
66+++ lib/lp/bugs/javascript/buglisting.js 2012-07-18 15:40:26 +0000
67@@ -173,10 +173,11 @@
68 if (Y.Lang.isNull(target)){
69 return null;
70 }
71+ var container = target.get('parentNode');
72 var navigation_indices = Y.all('.batch-navigation-index');
73 var pre_fetch = Y.lp.app.listing_navigator.get_feature_flag(
74 'bugs.dynamic_bug_listings.pre_fetch');
75- Y.lp.app.listing_navigator.linkify_navigation('#bugs-table-listing');
76+ Y.lp.app.listing_navigator.linkify_navigation(container);
77 var navigator = new module.BugListingNavigator({
78 current_url: window.location,
79 cache: LP.cache,
80@@ -185,8 +186,10 @@
81 navigation_indices: navigation_indices,
82 pre_fetch: Boolean(pre_fetch)
83 });
84- navigator.set('backwards_navigation', Y.all('.first,.previous'));
85- navigator.set('forwards_navigation', Y.all('.last,.next'));
86+ navigator.set('backwards_navigation',
87+ container.all('.first,.previous'));
88+ navigator.set('forwards_navigation',
89+ container.all('.last,.next'));
90 navigator.clickAction('.first', navigator.first_batch);
91 navigator.clickAction('.next', navigator.next_batch);
92 navigator.clickAction('.previous', navigator.prev_batch);
93
94=== modified file 'lib/lp/bugs/javascript/tests/test_buglisting.js'
95--- lib/lp/bugs/javascript/tests/test_buglisting.js 2012-07-16 17:57:01 +0000
96+++ lib/lp/bugs/javascript/tests/test_buglisting.js 2012-07-18 15:40:26 +0000
97@@ -104,8 +104,8 @@
98 test_from_page_with_client: function() {
99 Y.one('#fixture').setContent(
100 '<div id="bugs-table-listing">' +
101- '<a class="previous" href="http://example.org/">PreVious</span>' +
102- '<div id="client-listing"></div>' +
103+ '<a class="previous" href="http://example.org/">PreVious</a>' +
104+ '<div id="client-listing"></div>' +
105 '</div>');
106 Y.Assert.areSame('http://example.org/', this.getPreviousLink());
107 module.BugListingNavigator.from_page();
108
109=== modified file 'lib/lp/registry/javascript/sharing/shareetable.js'
110--- lib/lp/registry/javascript/sharing/shareetable.js 2012-07-16 11:50:02 +0000
111+++ lib/lp/registry/javascript/sharing/shareetable.js 2012-07-18 15:40:26 +0000
112@@ -99,20 +99,24 @@
113 },
114
115 make_navigator: function() {
116+ var target = Y.one('#sharee-table');
117+ var container = target.get('parentNode');
118 var navigation_indices = Y.all('.batch-navigation-index');
119- Y.lp.app.listing_navigator.linkify_navigation('#sharee-table-listing');
120+ Y.lp.app.listing_navigator.linkify_navigation(target);
121 var ns = Y.lp.registry.sharing.shareelisting_navigator;
122 var cache = LP.cache;
123 cache.total = this.get('sharees').length;
124 var navigator = new ns.ShareeListingNavigator({
125 current_url: window.location,
126 cache: cache,
127- target: Y.one('#sharee-table'),
128+ target: target,
129 navigation_indices: navigation_indices,
130 batch_info_template: '<div></div>'
131 });
132- navigator.set('backwards_navigation', Y.all('.first,.previous'));
133- navigator.set('forwards_navigation', Y.all('.last,.next'));
134+ navigator.set('backwards_navigation',
135+ container.all('.first,.previous'));
136+ navigator.set('forwards_navigation',
137+ container.all('.last,.next'));
138 navigator.clickAction('.first', navigator.first_batch);
139 navigator.clickAction('.next', navigator.next_batch);
140 navigator.clickAction('.previous', navigator.prev_batch);
141
142=== modified file 'lib/lp/registry/javascript/sharing/tests/test_shareetable.js'
143--- lib/lp/registry/javascript/sharing/tests/test_shareetable.js 2012-07-07 14:00:30 +0000
144+++ lib/lp/registry/javascript/sharing/tests/test_shareetable.js 2012-07-18 15:40:26 +0000
145@@ -41,7 +41,6 @@
146 var sharee_table = Y.Node.create(
147 Y.one('#sharee-table-template').getContent());
148 this.fixture.appendChild(sharee_table);
149-
150 },
151
152 tearDown: function () {