launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05380
[Merge] lp:~abentley/launchpad/bug-fields into lp:launchpad
Aaron Bentley has proposed merging lp:~abentley/launchpad/bug-fields into lp:launchpad with lp:~deryck/launchpad/custom-bug-listings-css-polish as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~abentley/launchpad/bug-fields/+merge/81061
= Summary =
Enable showing/hiding the bug fields programmatically, add milestone.
== Proposed fix ==
See above
== Pre-implementation notes ==
None
== Implementation details ==
This is implemented in the template, rather than by CSS, so that it's easily reproduced client-side or server-side.
== Tests ==
bin/test -t test_hiding bugtask
== Demo and Q/A ==
None. This should have no UI impact so far.
No lint, except ./lib/canonical/launchpad/icing/style-3-0.css, which has too much lint to do anything about.
--
https://code.launchpad.net/~abentley/launchpad/bug-fields/+merge/81061
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/bug-fields into lp:launchpad.
=== modified file 'lib/canonical/launchpad/icing/style-3-0.css'
--- lib/canonical/launchpad/icing/style-3-0.css 2011-11-02 18:58:30 +0000
+++ lib/canonical/launchpad/icing/style-3-0.css 2011-11-02 18:58:32 +0000
@@ -2185,6 +2185,9 @@
background: #999;
color: white;
}
+#client-listing .field {
+ margin-left: 1em;
+}
/* =====
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2011-11-01 16:02:45 +0000
+++ lib/lp/bugs/browser/bugtask.py 2011-11-02 18:58:32 +0000
@@ -2145,6 +2145,10 @@
"""Provide flattened data about bugtask for simple templaters."""
badges = getAdapter(self.bugtask, IPathAdapter, 'image').badges()
target_image = getAdapter(self.target, IPathAdapter, 'image')
+ if self.bugtask.milestone is not None:
+ milestone_name = self.bugtask.milestone.displayname
+ else:
+ milestone_name = None
return {
'importance': self.importance.title,
'importance_class': 'importance' + self.importance.name,
@@ -2157,6 +2161,7 @@
'bugtarget_css': target_image.sprite_css(),
'bug_heat_html': self.bug_heat_html,
'badges': badges,
+ 'milestone_name': milestone_name,
}
@@ -2169,6 +2174,15 @@
# rules to a mixin so that MilestoneView and others can use it.
self.request = request
self.target_context = target_context
+ self.field_visibility = {
+ 'show_bugtarget': True,
+ 'show_bug_heat': True,
+ 'show_id': True,
+ 'show_importance': True,
+ 'show_status': True,
+ 'show_title': True,
+ 'show_milestone_name': False,
+ }
TableBatchNavigator.__init__(
self, tasks, request, columns_to_show=columns_to_show, size=size)
@@ -2222,6 +2236,8 @@
@property
def model(self):
bugtasks = [bugtask.model for bugtask in self.getBugListingItems()]
+ for bugtask in bugtasks:
+ bugtask.update(self.field_visibility)
return {'bugtasks': bugtasks}
=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
--- lib/lp/bugs/browser/tests/test_bugtask.py 2011-11-01 16:02:45 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask.py 2011-11-02 18:58:32 +0000
@@ -45,8 +45,8 @@
from lp.bugs.adapters.bugchange import BugTaskStatusChange
from lp.bugs.browser.bugtask import (
BugActivityItem,
+ BugListingBatchNavigator,
BugTaskEditView,
- BugListingBatchNavigator,
BugTaskListingItem,
BugTasksAndNominationsView,
BugTaskSearchListingView,
@@ -1472,6 +1472,79 @@
bug_number = self.getBugNumberTag(bug_task)
self.assertHTML(browser, self.client_listing, bug_number)
+ def getNavigator(self):
+ request = LaunchpadTestRequest()
+ navigator = BugListingBatchNavigator([], request, [], 1)
+ cache = IJSONRequestCache(request)
+ bugtask = {
+ 'id': '3.14159',
+ 'title': 'title1',
+ 'status': 'status1',
+ 'importance': 'importance1',
+ 'importance_class': 'importance_class1',
+ 'bugtarget': 'bugtarget1',
+ 'bugtarget_css': 'bugtarget_css1',
+ 'bug_heat_html': 'bug_heat_html1',
+ 'bug_url': 'bug_url1',
+ 'milestone_name': 'milestone_name1'
+ }
+ bugtask.update(navigator.field_visibility)
+ cache.objects['mustache_model'] = {
+ 'bugtasks': [bugtask],
+ }
+ mustache_model = cache.objects['mustache_model']
+ return navigator, mustache_model
+
+ def test_hiding_bug_number(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertIn('3.14159', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_id'] = False
+ self.assertNotIn('3.14159', navigator.mustache)
+
+ def test_hiding_status(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertIn('status1', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_status'] = False
+ self.assertNotIn('status1', navigator.mustache)
+
+ def test_hiding_importance(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertIn('importance1', navigator.mustache)
+ self.assertIn('importance_class1', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_importance'] = False
+ self.assertNotIn('importance1', navigator.mustache)
+ self.assertNotIn('importance_class1', navigator.mustache)
+
+ def test_hiding_bugtarget(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertIn('bugtarget1', navigator.mustache)
+ self.assertIn('bugtarget_css1', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_bugtarget'] = False
+ self.assertNotIn('bugtarget1', navigator.mustache)
+ self.assertNotIn('bugtarget_css1', navigator.mustache)
+
+ def test_hiding_bug_heat(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertIn('bug_heat_html1', navigator.mustache)
+ self.assertIn('bug-heat-icons', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_bug_heat'] = False
+ self.assertNotIn('bug_heat_html1', navigator.mustache)
+ self.assertNotIn('bug-heat-icons', navigator.mustache)
+
+ def test_hiding_bug_title(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertIn('title1', navigator.mustache)
+ self.assertIn('bug_url1', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_title'] = False
+ self.assertNotIn('title1', navigator.mustache)
+ self.assertIn('bug_url1', navigator.mustache)
+
+ def test_hiding_milstone_name(self):
+ navigator, mustache_model = self.getNavigator()
+ self.assertNotIn('milestone_name1', navigator.mustache)
+ mustache_model['bugtasks'][0]['show_milestone_name'] = True
+ self.assertIn('milestone_name1', navigator.mustache)
+
class TestBugListingBatchNavigator(TestCaseWithFactory):
@@ -1507,3 +1580,8 @@
self.assertEqual(
'<span alt="private" title="Private" class="sprite private">'
' </span>', model['badges'])
+ self.assertEqual(None, model['milestone_name'])
+ item.bugtask.milestone = self.factory.makeMilestone(
+ product=item.bugtask.target)
+ milestone_name = item.milestone.displayname
+ self.assertEqual(milestone_name, item.model['milestone_name'])
=== modified file 'lib/lp/bugs/javascript/buglisting.js'
--- lib/lp/bugs/javascript/buglisting.js 2011-11-01 17:55:21 +0000
+++ lib/lp/bugs/javascript/buglisting.js 2011-11-02 18:58:32 +0000
@@ -34,6 +34,10 @@
this.io_provider = io_provider;
this.current_batch = lp_client.wrap_resource(null, cache);
this.template = template;
+ //Work around mustache.js bug 48 "Blank lines are not preserved."
+ if (Y.Lang.isValue(this.template)){
+ this.template = this.template.replace(/\n/g, ' ');
+ }
this.target = target;
this.batches = {};
this.backwards_navigation = new Y.NodeList([]);
=== modified file 'lib/lp/bugs/templates/buglisting.mustache'
--- lib/lp/bugs/templates/buglisting.mustache 2011-11-02 18:58:30 +0000
+++ lib/lp/bugs/templates/buglisting.mustache 2011-11-02 18:58:32 +0000
@@ -3,30 +3,49 @@
<div class="buglisting-row">
<div class="buglisting-col1">
+ {{#show_importance}}
<div class="importance {{importance_class}}">
{{importance}}
</div>
+ {{/show_importance}}
+ {{#show_status}}
<div class="status {{status_class}}">
{{status}}
</div>
+ {{/show_status}}
</div>
<div class="buglisting-col2">
<div class="buginfo">
- <span class="bugnumber">#{{id}}</span>
- <a href="{{bug_url}}" class="bugtitile">{{title}}</a>
+ {{#show_id}}
+ <a class="bugnumber" href="{{bug_url}}">#{{id}}</a>
+ {{/show_id}}
+ {{#show_title}}
+ <a href="{{bug_url}}" class="bugtitile">{{title}}</a>
+ {{/show_title}}
</div>
<div class="buginfo-extras">
- <div class="{{bugtarget_css}}">
+ {{#show_bugtarget}}
+ <span class="{{bugtarget_css}}">
{{bugtarget}}
- </div>
+ </span>
+ {{/show_bugtarget}}
+ {{#show_milestone_name}}
+ {{#milestone_name}}
+ <span class="sprite milestone field">
+ {{milestone_name}}
+ </span>
+ {{/milestone_name}}
+ {{/show_milestone_name}}
</div>
</div>
<div class="buglisting-col3">
+ {{#show_bug_heat}}
<span class="bug-heat-icons">
{{{bug_heat_html}}}
</span>
+ {{/show_bug_heat}}
<span class="bug-related-icons">
{{{badges}}}
</span>