Merge lp:~jcsackett/launchpad/extend-privacy-notification-to-comments into lp:launchpad

Proposed by j.c.sackett
Status: Merged
Approved by: j.c.sackett
Approved revision: no longer in the source branch.
Merged at revision: 13566
Proposed branch: lp:~jcsackett/launchpad/extend-privacy-notification-to-comments
Merge into: lp:launchpad
Prerequisite: lp:~jcsackett/launchpad/decouple-privacy-notifications
Diff against target: 77 lines (+34/-2)
3 files modified
lib/lp/app/javascript/privacy.js (+6/-2)
lib/lp/bugs/browser/bugcomment.py (+7/-0)
lib/lp/bugs/templates/bugcomment-index.pt (+21/-0)
To merge this branch: bzr merge lp:~jcsackett/launchpad/extend-privacy-notification-to-comments
Reviewer Review Type Date Requested Status
Ian Booth (community) code * Approve
Review via email: mp+69655@code.launchpad.net

Commit message

Extends the new privacy notifications to comments on private bugs.

Description of the change

Summary
=======
We're expanding the ribbon style privacy notification seen right now on bugtasks to other contexts. This branch extends it to bugcomments on private bugs.

Preimplementation
=================
Spoke with Curtis Hovey about bugcomments not being currently covered as part of bugs/bugtasks.

Implementation
==============
lib/lp/app/javascript/privacy.js
--------------------------------
display_privacy_notification() has been modified to accept a parameter indicating if a portlet should be hidden on dismissal of the ribbon. This parameter is passed along to hide_privacy_notification, and defaults to true.

lib/lp/bugs/browser/bugcomment.py
---------------------------------
A property has been added to the view code to determine the "hidden" class to be applied to the privacy ribbon. This is basically cargo culted from the other use of the ribbon in bugtasks.

lib/lp/bugs/templates/bugcomment-index.pt
-----------------------------------------
The privacy notification code has been included in the template, and the notification html has been added.

Tests
=====
bin/test -vvcm lp.bugs.browser.tests
firefox lib/lp/app/javascript/tests/test_privacy.html

QA
==
Check that the comments on a private bug have the ribbon. Check that the comments on a public bug do not.

Also, confirm that the dismissal of the ribbon on private bugs highlights the privacy portlet.

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :

Thanks for such a detailed mp description. Did you run lint?

35 - 'group_comments_with_activity',
36 - ]
37 + 'group_comments_with_activity', ]

Why the above change? I think the original formatting is correct and is used everywhere else. Could you change this back prior to landing?

I was going to ask about adding a yui test for the display_privacy_notification() method but then noticed there appear to be no yui tests for privacy.js :-(

I originally was also going to ask about the privacy_notice_classes property returning '' and not None and then saw that returning '' makes the tales easier to write so I think that's ok.

review: Approve (code *)
Revision history for this message
j.c.sackett (jcsackett) wrote :

The tests are in the dependent branch.

That change in the list formatting is just a typo; I'll fix it before landing this branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/privacy.js'
2--- lib/lp/app/javascript/privacy.js 2011-07-29 14:54:38 +0000
3+++ lib/lp/app/javascript/privacy.js 2011-07-29 14:54:39 +0000
4@@ -6,8 +6,12 @@
5 *
6 * This should be called after the page has loaded e.g. on 'domready'.
7 */
8-function display_privacy_notification() {
9+function display_privacy_notification(highlight_portlet_on_close) {
10 /* Check if the feature flag is set for this notification. */
11+ var highlight = true;
12+ if (highlight_portlet_on_close !== undefined) {
13+ highlight = highlight_portlet_on_close;
14+ }
15 if (privacy_notification_enabled) {
16 /* Set a temporary class on the body for the feature flag,
17 this is because we have no way to use feature flags in
18@@ -47,7 +51,7 @@
19 }
20
21 Y.one('.global-notification-close').on('click', function(e) {
22- hide_privacy_notification(true);
23+ hide_privacy_notification(highlight);
24 e.halt();
25 });
26 }
27
28=== modified file 'lib/lp/bugs/browser/bugcomment.py'
29--- lib/lp/bugs/browser/bugcomment.py 2011-05-11 18:00:35 +0000
30+++ lib/lp/bugs/browser/bugcomment.py 2011-07-29 14:54:39 +0000
31@@ -333,6 +333,13 @@
32 return 'Comment %d for bug %d' % (
33 self.comment.index, self.context.bug.id)
34
35+ @property
36+ def privacy_notice_classes(self):
37+ if not self.context.bug.private:
38+ return 'hidden'
39+ else:
40+ return ''
41+
42
43 class BugCommentBoxViewMixin:
44 """A class which provides proxied Librarian URLs for bug attachments."""
45
46=== modified file 'lib/lp/bugs/templates/bugcomment-index.pt'
47--- lib/lp/bugs/templates/bugcomment-index.pt 2010-09-24 22:30:48 +0000
48+++ lib/lp/bugs/templates/bugcomment-index.pt 2011-07-29 14:54:39 +0000
49@@ -7,7 +7,28 @@
50 i18n:domain="launchpad"
51 >
52 <body>
53+ <metal:block fill-slot="head_epilogue">
54+ <script>
55+ LPS.use('base', 'node', 'lp.app.privacy', function(Y) {
56+ Y.on("domready", function () {
57+ if (Y.one(document.body).hasClass('private')) {
58+ Y.lp.app.privacy.display_privacy_notification(false);
59+ }
60+ });
61+ });
62+ </script>
63+ </metal:block>
64 <div metal:fill-slot="main" tal:define="comment view/comment">
65+ <tal:if condition="request/features/bugs.private_notification.enabled">
66+ <div tal:attributes="class string: global-notification ${view/privacy_notice_classes}">
67+ <span class="sprite notification-private"></span>
68+ This comment is on a private bug
69+ <a href="#" class="global-notification-close">
70+ <span class="sprite notification-close"></span>
71+ Hide
72+ </a>
73+ </div>
74+ </tal:if>
75 <h1 tal:content="view/page_title">Foo doesn't work</h1>
76 <tal:comment replace="structure comment/@@+box-expanded-reply">
77 </tal:comment>