← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/fix-mp-js-buglink into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-mp-js-buglink into lp:launchpad.

Commit message:
Fix interaction between MPs and branch.bugspeclinks.js, and reinstate the JS fix from r18347.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-mp-js-buglink/+merge/322720
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-mp-js-buglink into lp:launchpad.
=== modified file 'lib/canonical/launchpad/icing/style.css'
--- lib/canonical/launchpad/icing/style.css	2015-09-09 12:21:30 +0000
+++ lib/canonical/launchpad/icing/style.css	2017-04-18 23:56:38 +0000
@@ -733,10 +733,10 @@
 
 /* === Bugs === */
 
-tr.bug-branch-summary td {
+tr.buglink-summary td {
     padding: 0px 6px;
     }
-tr.bug-branch-summary td.first {
+tr.buglink-summary td.first {
     padding-left: 0px;
     }
 

=== modified file 'lib/lp/bugs/templates/bug-branch.pt'
--- lib/lp/bugs/templates/bug-branch.pt	2016-07-29 16:53:13 +0000
+++ lib/lp/bugs/templates/bug-branch.pt	2017-04-18 23:56:38 +0000
@@ -9,7 +9,7 @@
    Git.
  </tal:comment>
 
- <div class="bug-branch-summary"
+ <div class="buglink-summary"
       tal:define="bug_branch context;
                   branch bug_branch/branch;
                   bug bug_branch/bug;

=== modified file 'lib/lp/bugs/templates/bugtask-index.pt'
--- lib/lp/bugs/templates/bugtask-index.pt	2016-07-29 16:42:14 +0000
+++ lib/lp/bugs/templates/bugtask-index.pt	2017-04-18 23:56:38 +0000
@@ -34,7 +34,7 @@
         #add-comment-form textarea { width: 100%; }
         #add-comment-form { max-width: 60em; padding-bottom: 4em; }
         #add-comment-form .actions {float: right;}
-        .bug-branch-summary dd { font-size: 10px; }
+        .buglink-summary dd { font-size: 10px; }
         a#privacy-link:link:hover, a#privacy-link:visited:hover {text-decoration:none;}
       </style>
       <style type="text/css">

=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml	2016-12-02 12:04:11 +0000
+++ lib/lp/code/browser/configure.zcml	2017-04-18 23:56:38 +0000
@@ -1,4 +1,4 @@
-<!-- Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+<!-- Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
      GNU Affero General Public License version 3 (see the file LICENSE).
 -->
 
@@ -193,6 +193,9 @@
         <browser:page
             name="+pagelet-summary"
             template="../templates/branchmergeproposal-pagelet-summary.pt"/>
+        <browser:page
+            name="++bug-links"
+            template="../templates/branchmergeproposal-bug-links.pt"/>
     </browser:pages>
     <browser:pages
         for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposal"

=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
--- lib/lp/code/browser/tests/test_branchmergeproposal.py	2016-09-07 11:12:58 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposal.py	2017-04-18 23:56:38 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for BranchMergeProposals."""
@@ -2043,7 +2043,7 @@
         self.assertEqual(
             expected_text,
             [extract_text(tag) for tag in find_tags_by_class(
-                 browser.contents, "bug-mp-summary")])
+                 browser.contents, "buglink-summary")])
 
     def test_link(self):
         # A user can enter a bug number to link from an MP to a bug.
@@ -2092,7 +2092,7 @@
                 flags=doctest.ELLIPSIS))
         self.assertThat(
             [extract_text(tag) for tag in find_tags_by_class(
-                 browser.contents, "bug-mp-summary")],
+                 browser.contents, "buglink-summary")],
             MatchesListwise(matchers))
 
     def test_bug_page_shows_link(self):

=== modified file 'lib/lp/code/javascript/branch.bugspeclinks.js'
--- lib/lp/code/javascript/branch.bugspeclinks.js	2016-06-25 08:05:06 +0000
+++ lib/lp/code/javascript/branch.bugspeclinks.js	2017-04-18 23:56:38 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2012-2016 Canonical Ltd.  This software is licensed under the
+/* Copyright 2012-2017 Canonical Ltd.  This software is licensed under the
  * GNU Affero General Public License version 3 (see the file LICENSE).
  *
  * Provide functionality for picking a bug.
@@ -99,7 +99,7 @@
             var bug_link =
                 Y.lp.client.get_absolute_uri("/api/devel/bugs/" + bug_id);
             that._unlink_bug_from_branch(bug_id, bug_link);
-        }, '#buglinks.actions .delete-buglink');
+        }, '#buglinks .delete-buglink');
     },
 
     /*
@@ -247,8 +247,7 @@
         var finish_update = function() {
             parent_element.removeChild(element);
             // Check to see if that was the only bug linked.
-            var buglinks = Y.all(".bug-branch-summary");
-            if (!buglinks.size()) {
+            if (!Y.all('.buglink-summary').size()) {
                 Y.one('#linkbug')
                     .setContent('Link to a bug report');
             }

=== modified file 'lib/lp/code/javascript/tests/test_bugspeclinks.html'
--- lib/lp/code/javascript/tests/test_bugspeclinks.html	2012-10-26 09:54:28 +0000
+++ lib/lp/code/javascript/tests/test_bugspeclinks.html	2017-04-18 23:56:38 +0000
@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <!--
-Copyright 2012 Canonical Ltd.  This software is licensed under the
+Copyright 2012-2017 Canonical Ltd.  This software is licensed under the
 GNU Affero General Public License version 3 (see the file LICENSE).
 -->
 
@@ -61,13 +61,15 @@
         <div id="fixture">
         </div>
         <script type="text/x-template" id="bugspec-links">
-            <div id="buglinks" class="actions">
+            <div id="buglinks">
                 <a href="#" id="linkbug" class="pick-bug js-action">
                     Link to bug report</a>
                 <div id="buglink-list">
-                    <a id="delete-buglink-6"
-                       href="+bug/6/+delete"
-                       class="delete-buglink" title="Remove link"></a>
+                    <tr id="buglink-6" class="buglink-summary">
+                        <a id="delete-buglink-6"
+                           href="+bug/6/+delete"
+                           class="delete-buglink" title="Remove link" />
+                    </tr>
                 </div>
             </div>
         </script>

=== modified file 'lib/lp/code/javascript/tests/test_bugspeclinks.js'
--- lib/lp/code/javascript/tests/test_bugspeclinks.js	2016-06-25 08:05:06 +0000
+++ lib/lp/code/javascript/tests/test_bugspeclinks.js	2017-04-18 23:56:38 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2012-2016 Canonical Ltd.  This software is licensed under the
+/* Copyright 2012-2017 Canonical Ltd.  This software is licensed under the
  * GNU Affero General Public License version 3 (see the file LICENSE). */
 
 YUI.add('lp.code.branch.bugspeclinks.test', function (Y) {
@@ -242,12 +242,31 @@
         test_unlink_bug_success: function() {
             this.widget = this._createWidget();
             // Set up the bug data on the page.
-            Y.one('#linkbug').setContent('Link to another');
+            Y.one('#linkbug').setContent('Link to another bug report');
             Y.one('#buglink-list').appendChild(
-                Y.Node.create('<div id="buglink-3"></div>'));
+                Y.Node.create(
+                    '<div id="buglink-3" class="buglink-summary" />'));
             this.widget._unlink_bug_success(3);
             Y.Assert.areEqual(
                 'Link to a bug report', Y.one('#linkbug').getContent());
+        },
+
+        // If there are still linked bugs remaining after unlinking one, the
+        // #linkbug text is left unchanged.
+        test_unlink_bug_branch_still_remaining: function() {
+            this.widget = this._createWidget();
+            // Set up the bug data on the page.
+            Y.one('#linkbug').setContent('Link to another bug report');
+            console.log(Y.one('#buglink-list'));
+            Y.one('#buglink-list').appendChild(
+                Y.Node.create(
+                    '<div id="buglink-3" class="buglink-summary" />'));
+            Y.one('#buglink-list').appendChild(
+                Y.Node.create(
+                    '<div id="buglink-4" class="buglink-summary" />'));
+            this.widget._unlink_bug_success(3);
+            Y.Assert.areEqual(
+                'Link to another bug report', Y.one('#linkbug').getContent());
         }
     })));
 

=== modified file 'lib/lp/code/stories/branches/xx-bug-branch-links.txt'
--- lib/lp/code/stories/branches/xx-bug-branch-links.txt	2013-09-27 04:13:23 +0000
+++ lib/lp/code/stories/branches/xx-bug-branch-links.txt	2017-04-18 23:56:38 +0000
@@ -24,7 +24,7 @@
     Unauthorized: (...launchpad.AnyPerson')
 
     >>> def printBugBranchLinks(browser):
-    ...     tags = find_tags_by_class(browser.contents, 'bug-branch-summary')
+    ...     tags = find_tags_by_class(browser.contents, 'buglink-summary')
     ...     if len(tags) == 0:
     ...         print 'No bug branch links'
     ...     else:

=== modified file 'lib/lp/code/stories/branches/xx-private-branch-listings.txt'
--- lib/lp/code/stories/branches/xx-private-branch-listings.txt	2015-06-02 10:53:10 +0000
+++ lib/lp/code/stories/branches/xx-private-branch-listings.txt	2017-04-18 23:56:38 +0000
@@ -218,7 +218,7 @@
 There are no branches linked to this bug.
 
     >>> def printBugBranchLinks(browser):
-    ...     tags = find_tags_by_class(browser.contents, 'bug-branch-summary')
+    ...     tags = find_tags_by_class(browser.contents, 'buglink-summary')
     ...     if len(tags) == 0:
     ...         print 'No bug branch links'
     ...     else:

=== modified file 'lib/lp/code/templates/branch-macros.pt'
--- lib/lp/code/templates/branch-macros.pt	2016-07-29 16:53:13 +0000
+++ lib/lp/code/templates/branch-macros.pt	2017-04-18 23:56:38 +0000
@@ -109,7 +109,7 @@
       <tr tal:condition="bugtask/bug/required:launchpad.View"
            tal:define="show_edit show_edit|nothing;"
            tal:attributes="id string:buglink-${bugtask/bug/id}"
-           class="bug-branch-summary">
+           class="buglink-summary">
         <td tal:content="structure bugtask/fmt:link:bugs" class="first"/>
         <td>
           <span tal:content="bugtask/importance/title"

=== added file 'lib/lp/code/templates/branchmergeproposal-bug-links.pt'
--- lib/lp/code/templates/branchmergeproposal-bug-links.pt	1970-01-01 00:00:00 +0000
+++ lib/lp/code/templates/branchmergeproposal-bug-links.pt	2017-04-18 23:56:38 +0000
@@ -0,0 +1,8 @@
+<div
+  xmlns:tal="http://xml.zope.org/namespaces/tal";
+  xmlns:metal="http://xml.zope.org/namespaces/metal";
+  xmlns:i18n="http://xml.zope.org/namespaces/i18n";>
+
+  <metal:bug-links use-macro="context/@@+bmp-macros/bug-links"/>
+
+</div>

=== modified file 'lib/lp/code/templates/branchmergeproposal-macros.pt'
--- lib/lp/code/templates/branchmergeproposal-macros.pt	2016-07-29 16:53:13 +0000
+++ lib/lp/code/templates/branchmergeproposal-macros.pt	2017-04-18 23:56:38 +0000
@@ -77,7 +77,7 @@
     lib/lp/bugs/templates/bug-branch.pt has similar code for Bazaar.
   </tal:comment>
 
-  <div class="bug-mp-summary"
+  <div class="buglink-summary"
        tal:define="show_edit bug/required:launchpad.Edit"
        tal:condition="proposal/required:launchpad.View">
     <a tal:attributes="href proposal/merge_source/fmt:url"
@@ -107,7 +107,7 @@
     <tal:bug-tasks repeat="bugtask view/linked_bugtasks">
       <tr tal:condition="bugtask/bug/required:launchpad.View"
            tal:attributes="id string:buglink-${bugtask/bug/id}"
-           class="bug-mp-summary">
+           class="buglink-summary">
         <td tal:content="structure bugtask/fmt:link:bugs" class="first"/>
         <td>
           <span tal:content="bugtask/importance/title"

=== modified file 'lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt'
--- lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt	2017-04-13 13:57:21 +0000
+++ lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt	2017-04-18 23:56:38 +0000
@@ -130,15 +130,19 @@
       <td>bzr merge <span class="branch-url" tal:content="context/source_branch/bzr_identity" /></td>
     </tr>
     <tr id="related-bugs">
-      <th>Related bugs:</th>
+      <th style="vertical-align: top;">Related bugs:</th>
       <td>
-        <metal:bug-links use-macro="context/@@+bmp-macros/bug-links"/>
-        <div tal:define="link context_menu/link_bug"
-             tal:condition="link/enabled">
-          <a id="linkbug"
-             class="sprite add"
-             tal:attributes="href link/url"
-             tal:content="link/text" />
+        <div id="buglinks">
+          <div id="buglink-list">
+            <metal:bug-links use-macro="context/@@+bmp-macros/bug-links"/>
+          </div>
+          <div tal:define="link context_menu/link_bug"
+               tal:condition="link/enabled">
+            <a id="linkbug"
+               class="sprite add"
+               tal:attributes="href link/url"
+               tal:content="link/text" />
+          </div>
         </div>
         <script type="text/javascript">
           LPJS.use('io-base', 'lp.code.branch.bugspeclinks', function(Y) {
@@ -147,7 +151,7 @@
 
               if (logged_in) {
                 var config = {
-                  picker_activator = '#linkbug'
+                  picker_activator: '#linkbug'
                 };
                 var linked_bug_picker = new
                   Y.lp.code.branch.bugspeclinks.LinkedBugPicker(config);


Follow ups