Merge lp:~abentley/launchpad/hide-numbers into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/hide-numbers
Merge into: lp:launchpad
Diff against target: 114 lines
4 files modified
Makefile (+6/-1)
configs/development/launchpad-lazr.conf (+4/-0)
lib/canonical/launchpad/javascript/code/codereview.js (+34/-1)
lib/lp/code/templates/branchmergeproposal-index.pt (+10/-4)
To merge this branch: bzr merge lp:~abentley/launchpad/hide-numbers
Reviewer Review Type Date Requested Status
Curtis Hovey (community) ui Approve
Paul Hummer (community) ui Approve
Brad Crittenden (community) Approve
Review via email: mp+13982@code.launchpad.net

Commit message

Allow hiding diff line numbers.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

= Summary =
Partial fix for #382561: Provide the ability to show and hide line
numbers in the preview diff, using a checkbox.

Note that a fully-functional workaround for #382561 is to use the
"Download diff" link.

== Proposed fix ==

== Pre-implementation notes ==
Pre-implementation was with Thumper

== Implementation details ==
The config and Makefile changes were done so that it was possible to
generate a diff in the developer environment.

The checkbox is implemented as a Widget called NumberToggle.

== Tests ==
None

== Demo and Q/A ==
 Create a merge proposal with a diff. Click the checkbox (or the
phrase) "Show line numbers".

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/code/templates/branchmergeproposal-index.pt
  lib/canonical/launchpad/javascript/code/codereview.js
  Makefile
  configs/development/launchpad-lazr.conf

== JSLint notices ==
No handlers could be found for logger "bzr"
jslint: Lint found in
'/home/abentley/launchpad/hide-numbers/lib/canonical/launchpad/javascript/bugs/bugtask-index.js':
Line 584 character 31: ['api_uri'] is better written in dot notation.
        var branch_url = data['api_uri'];

^^^ I didn't change this file!

jslint: No problem found in
'/home/abentley/launchpad/hide-numbers/lib/canonical/launchpad/javascript/code/codereview.js'.

jslint: 2 files to lint.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrl+fcACgkQ0F+nu1YWqI2KtACePSXRjpjFE1lfIwppl6QLmBe2
gmoAnRNlwDgwMDWrxXsiGRCPimxEwgHp
=5eM5
-----END PGP SIGNATURE-----

Revision history for this message
Brad Crittenden (bac) wrote :

Looks good Aaron.

Please change line 8 so the comment has a period.

review: Approve
Revision history for this message
Paul Hummer (rockstar) :
review: Approve (ui)
Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Aaron.

I create two branches in dev, then proposed a merge. I ran make sync_branches. The toggle works well, but I an unhappy with the spacing between it and the download link. We use <ul class="horizontal"> in many places to normalise the space between user actions on a page (1.5em). I am not sure that this can be reused in the <div>. Can you experiment with the markup/CSS to make the spacing consistent with the rest of Launchpad?

review: Needs Information (ui)
Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Curtis Hovey wrote:
> We use <ul class="horizontal"> in many places to normalise the
> space between user actions on a page (1.5em).
> Can you experiment with the markup/CSS to make the
> spacing consistent with the rest of Launchpad?

I've done this, and attached an incremental diff. I agree this is a bit
nicer.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrodzUACgkQ0F+nu1YWqI13qACfR6567uVNgrnaUUD40lxXMlXl
euEAn2CeMazyoVCY9PSMRe53YN57PMeQ
=BdH5
-----END PGP SIGNATURE-----

1=== modified file 'lib/canonical/launchpad/javascript/code/codereview.js'
2--- lib/canonical/launchpad/javascript/code/codereview.js 2009-10-26 19:16:19 +0000
3+++ lib/canonical/launchpad/javascript/code/codereview.js 2009-10-28 16:49:59 +0000
4@@ -144,11 +144,11 @@
5 };
6 Y.extend(NumberToggle, Y.Widget, {
7 renderUI: function() {
8- var ui = Y.Node.create('<label>' +
9- ' <input type="checkbox" checked="checked" id="show-no"/>' +
10- '&nbsp;Show line numbers</label>');
11- div = Y.get('#review-diff div div');
12- div.appendChild(ui);
13+ var ui = Y.Node.create('<li><label>' +
14+ '<input type="checkbox" checked="checked" id="show-no"/>' +
15+ '&nbsp;Show line numbers</label></li>');
16+ var ul = Y.get('#review-diff div div ul.horizontal');
17+ ul.appendChild(ui);
18 },
19 bindUI: function(){
20 Y.get('#show-no').on('click', update_nos);
21
22=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
23--- lib/lp/code/templates/branchmergeproposal-index.pt 2009-10-28 16:06:10 +0000
24+++ lib/lp/code/templates/branchmergeproposal-index.pt 2009-10-28 16:49:59 +0000
25@@ -145,10 +145,14 @@
26 tal:define="attachment view/preview_diff/diff_text">
27 <tal:real-diff condition="attachment">
28 <div class="boardCommentDetails filename">
29- <a tal:attributes="href attachment/getURL">
30- <img src="/@@/download"/>
31- Download diff
32- </a>
33+ <ul class="horizontal">
34+ <li>
35+ <a tal:attributes="href attachment/getURL">
36+ <img src="/@@/download"/>
37+ Download diff
38+ </a>
39+ </li>
40+ </ul>
41 </div>
42 <div class="boardCommentBody attachmentBody">
43 <tal:diff replace="structure view/preview_diff_text/fmt:diff" />
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thanks for exploring this. I too think it looks nicer.

review: Approve (ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2009-10-28 11:05:01 +0000
3+++ Makefile 2009-10-28 16:53:12 +0000
4@@ -170,6 +170,10 @@
5 ftest_inplace: inplace
6 bin/test -f $(TESTFLAGS) $(TESTOPTS)
7
8+mpcreationjobs:
9+ # Handle merge proposal creations.
10+ $(PY) cronscripts/mpcreationjobs.py
11+
12 run: inplace stop
13 $(RM) thread*.request
14 bin/run -r librarian,google-webservice -i $(LPCONFIG)
15@@ -206,7 +210,8 @@
16 # Scan branches from the filesystem into the database.
17 $(PY) cronscripts/branch-scanner.py
18
19-sync_branches: pull_branches scan_branches
20+
21+sync_branches: pull_branches scan_branches mpcreationjobs
22
23 $(BZR_VERSION_INFO):
24 scripts/update-bzr-version-info.sh
25
26=== modified file 'configs/development/launchpad-lazr.conf'
27--- configs/development/launchpad-lazr.conf 2009-10-20 11:29:26 +0000
28+++ configs/development/launchpad-lazr.conf 2009-10-28 16:53:12 +0000
29@@ -182,6 +182,10 @@
30 soft_max_size: 40000
31 hard_max_size: 1000000
32
33+[mpcreationjobs]
34+error_dir: /var/tmp/codehosting.test
35+oops_prefix: DMPCR
36+
37 [personalpackagearchive]
38 root: /var/tmp/ppa/
39 private_root: /var/tmp/ppa
40
41=== modified file 'lib/canonical/launchpad/javascript/code/codereview.js'
42--- lib/canonical/launchpad/javascript/code/codereview.js 2009-08-03 20:11:00 +0000
43+++ lib/canonical/launchpad/javascript/code/codereview.js 2009-10-28 16:53:12 +0000
44@@ -124,4 +124,37 @@
45 }
46
47
48-}, '0.1', {requires: ['base', 'lazr.anim', 'lazr.formoverlay', 'lp.picker']});
49+var NumberToggle = function () {
50+ NumberToggle.superclass.constructor.apply(this, arguments);
51+};
52+
53+
54+var update_nos = function(){
55+ var new_display = 'none';
56+ if (this.get('checked')) {
57+ new_display = 'block';
58+ }
59+ Y.all('td.line-no').setStyle('display', new_display);
60+};
61+
62+
63+NumberToggle.NAME = 'numbertoggle';
64+
65+NumberToggle.ATTRS = {
66+};
67+Y.extend(NumberToggle, Y.Widget, {
68+ renderUI: function() {
69+ var ui = Y.Node.create('<li><label>' +
70+ '<input type="checkbox" checked="checked" id="show-no"/>' +
71+ '&nbsp;Show line numbers</label></li>');
72+ var ul = Y.get('#review-diff div div ul.horizontal');
73+ ul.appendChild(ui);
74+ },
75+ bindUI: function(){
76+ Y.get('#show-no').on('click', update_nos);
77+ }
78+});
79+
80+Y.codereview.NumberToggle = NumberToggle;
81+
82+}, '0.1', {requires: ['base', 'widget', 'lazr.anim', 'lazr.formoverlay', 'lp.picker']});
83
84=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
85--- lib/lp/code/templates/branchmergeproposal-index.pt 2009-10-23 02:41:08 +0000
86+++ lib/lp/code/templates/branchmergeproposal-index.pt 2009-10-28 16:53:12 +0000
87@@ -145,10 +145,14 @@
88 tal:define="attachment view/preview_diff/diff_text">
89 <tal:real-diff condition="attachment">
90 <div class="boardCommentDetails filename">
91- <a tal:attributes="href attachment/getURL">
92- <img src="/@@/download"/>
93- Download diff
94- </a>
95+ <ul class="horizontal">
96+ <li>
97+ <a tal:attributes="href attachment/getURL">
98+ <img src="/@@/download"/>
99+ Download diff
100+ </a>
101+ </li>
102+ </ul>
103 </div>
104 <div class="boardCommentBody attachmentBody">
105 <tal:diff replace="structure view/preview_diff_text/fmt:diff" />
106@@ -181,6 +185,8 @@
107 Y.code.codereview.connect_links();
108 });
109
110+ (new Y.codereview.NumberToggle()).render();
111+
112 });
113 -->
114 <tal:script replace="structure string:&lt;/script&gt;" />