launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07849
[Merge] lp:~jcsackett/launchpad/use-banner-to-cleanup-privacy into lp:launchpad
j.c.sackett has proposed merging lp:~jcsackett/launchpad/use-banner-to-cleanup-privacy into lp:launchpad with lp:~jcsackett/launchpad/banner-fixes as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/use-banner-to-cleanup-privacy/+merge/105731
Summary
=======
This branch uses the new lp.app.banner.Banner object to rewrite the privacy
banner.
Preimp
======
Spoke with Curtis Hovey, Rick Harding
Implementation
==============
A new object, PrivacyBanner has been created that extends
lp.app.banner.Banner.
There is a simple method to simulate singleton behavior on the privacy banner,
so that all the other modules using it get the same banner object. Otherwise,
the show/hide behavior gets goofy as new banners are created with new visible
attributes, regardless of the state of the banner html. Given this, some of
the work in banner-fixes (the single banner code) can probably be removed, but
that's work for another branch.
All call sites were updated, and the information_type_choice tests and privacy
tests were updated.
Tests
=====
bin/test -vvc -t privacy -t information_type_choice --layer=YUI
QA
==
Check a private page; the banner should be displayed.
Mark a public bug private--the banner should be displayed.
Mark that same bug public--the banner should be hidden.
File a bug, and mark it as security related--the banner should be shown
explaining the bug can be disclosed later but is private now.
LoC
===
This removes code.
Lint
====
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/app/javascript/banners/tests/test_banner.js
lib/lp/app/javascript/banners/banner.js
lib/lp/bugs/templates/bugtarget-macros-filebug.pt
lib/lp/app/javascript/banners/privacy.js
lib/lp/app/javascript/banners/tests/test_privacy.js
lib/lp/bugs/javascript/tests/test_information_type_choice.js
lib/lp/app/templates/base-layout-macros.pt
lib/lp/bugs/javascript/bugtask_index.js
lib/lp/bugs/javascript/tests/test_bugtask_delete.html
lib/lp/app/javascript/banners/tests/test_privacy.html
lib/lp/bugs/javascript/tests/test_information_type_choice.html
lib/lp/bugs/javascript/information_type_choice.js
--
https://code.launchpad.net/~jcsackett/launchpad/use-banner-to-cleanup-privacy/+merge/105731
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/use-banner-to-cleanup-privacy into lp:launchpad.
=== modified file 'lib/lp/app/javascript/banners/banner.js'
--- lib/lp/app/javascript/banners/banner.js 2012-05-14 22:21:25 +0000
+++ lib/lp/app/javascript/banners/banner.js 2012-05-14 22:21:26 +0000
@@ -30,7 +30,6 @@
_showBanner: function () {
var body = Y.one('body');
body.addClass('global-notification-visible');
-
var global_notification = Y.one('.global-notification');
global_notification.removeClass('hidden');
=== modified file 'lib/lp/app/javascript/banners/privacy.js'
--- lib/lp/app/javascript/banners/privacy.js 2012-05-01 17:01:21 +0000
+++ lib/lp/app/javascript/banners/privacy.js 2012-05-14 22:21:26 +0000
@@ -1,135 +1,38 @@
-YUI.add('lp.app.privacy', function(Y) {
-
-var namespace = Y.namespace('lp.app.privacy');
-
-var notification_node = null;
-/*
- * Display privacy notifications
- *
- * This should be called after the page has loaded e.g. on 'domready'.
- */
-
-function setup_privacy_notification(config) {
- if (notification_node !== null) {
- return;
- }
- var notification_text = 'The information on this page is private';
- var hidden = true;
- var target_id = "maincontent";
- if (config !== undefined) {
- if (config.notification_text !== undefined) {
- notification_text = config.notification_text;
- }
- if (config.hidden !== undefined) {
- hidden = config.hidden;
- }
- if (config.target_id !== undefined) {
- target_id = config.target_id;
- }
- }
- var id_selector = "#" + target_id;
- var main = Y.one(id_selector);
- notification_node = Y.Node.create('<div></div>')
- .addClass('global-notification');
- if (hidden) {
- notification_node.addClass('hidden');
- }
- var notification_span = Y.Node.create('<span></span>')
- .addClass('sprite')
- .addClass('notification-private');
- notification_node.set('text', notification_text);
-
- main.appendChild(notification_node);
- notification_node.appendChild(notification_span);
-}
-namespace.setup_privacy_notification = setup_privacy_notification;
-
-/**
- * For unit tests - we need to reset the notification setup.
- */
-namespace._reset_privacy_notification = function () {
- notification_node = null;
-};
-
-function display_privacy_notification() {
- /* Set a temporary class on the body for the feature flag,
- this is because we have no way to use feature flags in
- css directly. This should be removed if the feature
- is accepted. */
- var body = Y.one('body');
- body.addClass('feature-flag-bugs-private-notification-enabled');
- /* Set the visible flag so that the content moves down. */
- body.addClass('global-notification-visible');
-
- setup_privacy_notification();
- var global_notification = Y.one('.global-notification');
- if (global_notification.hasClass('hidden')) {
- global_notification.addClass('transparent');
- global_notification.removeClass('hidden');
-
- var fade_in = new Y.Anim({
- node: global_notification,
- to: {opacity: 1},
- duration: 0.3
- });
- var body_space = new Y.Anim({
- node: 'body',
- to: {'paddingTop': '40px'},
- duration: 0.2,
- easing: Y.Easing.easeOut
- });
- var login_space = new Y.Anim({
- node: '.login-logout',
- to: {'top': '45px'},
- duration: 0.2,
- easing: Y.Easing.easeOut
- });
-
- fade_in.run();
- body_space.run();
- login_space.run();
- }
-}
-namespace.display_privacy_notification = display_privacy_notification;
-
-/*
- * Hide privacy notifications
- *
- * This should be called after the page has loaded e.g. on 'domready'.
- */
-function hide_privacy_notification() {
- setup_privacy_notification();
- if (!Y.one('.global-notification').hasClass('hidden')) {
- var fade_out = new Y.Anim({
- node: '.global-notification',
- to: {opacity: 0},
- duration: 0.3
- });
- var body_space = new Y.Anim({
- node: 'body',
- to: {'paddingTop': 0},
- duration: 0.2,
- easing: Y.Easing.easeOut
- });
- var login_space = new Y.Anim({
- node: '.login-logout',
- to: {'top': '6px'},
- duration: 0.2,
- easing: Y.Easing.easeOut
- });
- fade_out.on('end', function() {
- fade_out.get('node').addClass('hidden');
- });
- body_space.on('end', function() {
- Y.one('body').removeClass('global-notification-visible');
- });
-
- fade_out.run();
- body_space.run();
- login_space.run();
- }
-}
-namespace.hide_privacy_notification = hide_privacy_notification;
-
-
-}, "0.1", {"requires": ["base", "node", "anim"]});
+YUI.add('lp.app.banner.privacy', function(Y) {
+
+var ns = Y.namespace('lp.app.banner.privacy');
+var baseBanner = Y.lp.app.banner.Banner;
+
+ns.PrivacyBanner = Y.Base.create('privacyBanner', baseBanner, [], {
+
+ renderUI: function () {
+ var body = Y.one('body');
+ body.addClass('feature-flag-bugs-private-notification-enabled');
+ baseBanner.prototype.renderUI.apply(this, arguments);
+ }
+
+}, {
+ ATTRS: {
+ banner_id: { value: "privacy-banner" },
+ notification_text: {
+ value: "The information on this page is private."
+ },
+ banner_icon: {
+ value: '<span class="sprite notification-private"></span>'
+ },
+ }
+});
+
+// For the privacy banner to work, it needs to have one instance, and one
+// instance only.
+var _singleton_privacy_banner = null;
+
+ns.getPrivacyBanner = function () {
+ if (_singleton_privacy_banner === null) {
+ _singleton_privacy_banner = new ns.PrivacyBanner();
+ _singleton_privacy_banner.render();
+ }
+ return _singleton_privacy_banner;
+}
+
+}, "0.1", {"requires": ["base", "node", "anim", "lp.app.banner"]});
=== modified file 'lib/lp/app/javascript/banners/tests/test_privacy.html'
--- lib/lp/app/javascript/banners/tests/test_privacy.html 2012-05-01 17:01:21 +0000
+++ lib/lp/app/javascript/banners/tests/test_privacy.html 2012-05-14 22:21:26 +0000
@@ -6,7 +6,7 @@
<html>
<head>
- <title>Test privacy</title>
+ <title>lp.app.banner.privacy Tests</title>
<!-- YUI and test setup -->
<script type="text/javascript"
@@ -25,26 +25,22 @@
<link rel="stylesheet" href="../../../../app/javascript/testing/test.css" />
<!-- Dependencies -->
- <script type="text/javascript"
- src="../../../../../../build/js/lp/app/client.js"></script>
- <script type="text/javascript"
- src="../../../../../../build/js/lp/app/lp.js"></script>
+ <script type="text/javascript" src="../../mustache.js"></script>
+ <script type="text/javascript" src="../banner.js"></script>
<!-- The module under test. -->
<script type="text/javascript" src="../privacy.js"></script>
- <!-- Placeholder for any css asset for this module. -->
- <!-- <link rel="stylesheet" href="../assets/privacy-core.css" /> -->
-
<!-- The test suite. -->
<script type="text/javascript" src="test_privacy.js"></script>
</head>
<body class="yui3-skin-sam">
<ul id="suites">
- <!-- <li>lp.large_indicator.test</li> -->
- <li>lp.privacy.test</li>
- <div id="maincontent"> </div>
+ <li>lp.app.banner.privacy.test</li>
</ul>
+
+ <!-- The example markup required by the script to run. -->
+ <div id="maincontent"></div>
</body>
</html>
=== modified file 'lib/lp/app/javascript/banners/tests/test_privacy.js'
--- lib/lp/app/javascript/banners/tests/test_privacy.js 2012-05-01 17:01:21 +0000
+++ lib/lp/app/javascript/banners/tests/test_privacy.js 2012-05-14 22:21:26 +0000
@@ -1,79 +1,57 @@
-/* Copyright 2011 Canonical Ltd. This software is licensed under the
+/* Copyright 2011-2012 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE).
*/
-// Set the "enabled" variable, normally set by base-layout-macros.
-// This must be a global variable for the code being tested to work.
-var privacy_notification_enabled = true;
-
-YUI().use('lp.testing.runner', 'test', 'console', 'node',
- 'lp.app.privacy', 'node-event-simulate', function(Y) {
-
- var suite = new Y.Test.Suite("lp.app.privacy Tests");
-
- suite.add(new Y.Test.Case({
- name: 'privacy',
-
- _reset_container: function () {
- Y.lp.app.privacy._reset_privacy_notification();
+YUI.add('lp.app.banner.privacy.test', function (Y) {
+
+ var tests = Y.namespace('lp.app.banner.privacy.test');
+ tests.suite = new Y.Test.Suite('lp.app.banner.privacy Tests');
+
+ tests.suite.add(new Y.Test.Case({
+ name: 'privacy_tests',
+
+ setUp: function () {
+ var main = Y.one('#maincontent');
+ var login_logout = Y.Node.create('<div></div>')
+ .addClass('login-logout');
+ main.appendChild(login_logout);
+ },
+
+ tearDown: function () {
var body = Y.one(document.body);
-
- // Replace the container.
- var container = Y.one('#maincontent');
- container.remove(true);
- container = Y.Node.create('<div></div>')
+ var main = Y.one('#maincontent');
+ main.remove(true);
+ main = Y.Node.create('<div></div>')
.set('id', 'maincontent');
- body.appendChild(container);
- return container;
- },
-
- setUp: function () {
- // Create the global notification html.
- var container = this._reset_container();
+ body.appendChild(main);
var login_logout = Y.Node.create('<div></div>')
.addClass('login-logout');
- container.appendChild(login_logout);
- },
-
- test_setup: function() {
- // Undo the setup.
- var container = this._reset_container();
- var config = {
- notification_text: "stuff is private",
- hidden: true,
- target_id: container.get('id')
- };
- Y.lp.app.privacy.setup_privacy_notification(config);
- var ribbon = Y.one('.global-notification');
- Y.Assert.isTrue(ribbon.hasClass('hidden'));
-
- Y.Assert.areEqual(config.notification_text, ribbon.get('text'));
- },
-
- test_display_shows_ribbon: function () {
- Y.lp.app.privacy.display_privacy_notification();
- var ribbon = Y.one('.global-notification');
- Y.Assert.isFalse(ribbon.hasClass('hidden.'));
- },
-
- test_hide_removes_ribbon: function () {
- Y.lp.app.privacy.display_privacy_notification();
- var ribbon = Y.one('.global-notification');
- Y.Assert.isFalse(ribbon.hasClass('hidden'));
- Y.lp.app.privacy.hide_privacy_notification(false);
-
- // We wait for the privacy ribbon fadeout to complete.
- // It takes 300ms, but we have to pad that out to avoid a race and
- // intermittent failures.
- var wait_for_anim = 320;
- this.wait(
- function () {
- Y.Assert.isTrue(ribbon.hasClass('hidden'));
- },
- wait_for_anim);
+ main.appendChild(login_logout);
+ },
+
+ test_library_exists: function () {
+ Y.Assert.isObject(Y.lp.app.banner.privacy,
+ "Could not locate the lp.app.banner.privacy module");
+ },
+
+ test_init: function () {
+ var banner = new Y.lp.app.banner.privacy.PrivacyBanner();
+ Y.Assert.areEqual(
+ "The information on this page is private.",
+ banner.get('notification_text'));
+ Y.Assert.areEqual(
+ '<span class="sprite notification-private"></span>',
+ banner.get('banner_icon'));
+ },
+
+ test_render: function () {
+ var banner = new Y.lp.app.banner.privacy.PrivacyBanner();
+ banner.render();
+
+ var body = Y.one('body');
+ var exp_class = 'feature-flag-bugs-private-notification-enabled';
+ Y.Assert.isTrue(body.hasClass(exp_class));
}
}));
- Y.lp.testing.Runner.run(suite);
-});
-
+}, '0.1', {'requires': ['test', 'console', 'lp.app.banner.privacy']});
=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt 2012-04-19 20:34:55 +0000
+++ lib/lp/app/templates/base-layout-macros.pt 2012-05-14 22:21:26 +0000
@@ -152,7 +152,7 @@
<script id="base-layout-load-scripts" type="text/javascript">
LPJS.use('base', 'node', 'console', 'event',
- 'oop', 'lp', 'lp.app.privacy',
+ 'oop', 'lp', 'lp.app.banner.privacy',
'lp.app.beta_features', 'lp.app.foldables','lp.app.sorttable',
'lp.app.inlinehelp', 'lp.app.links', 'lp.app.longpoll',
'lp.bugs.bugtask_index', 'lp.bugs.subscribers',
@@ -161,8 +161,8 @@
Y.on("domready", function () {
if (Y.one(document.body).hasClass('private')) {
- Y.lp.app.privacy.setup_privacy_notification();
- Y.lp.app.privacy.display_privacy_notification();
+ banner = Y.lp.app.banner.privacy.getPrivacyBanner();
+ banner.show();
}
Y.lp.app.beta_features.display_beta_notification();
Y.lp.app.sorttable.SortTable.init();
=== modified file 'lib/lp/bugs/javascript/bugtask_index.js'
--- lib/lp/bugs/javascript/bugtask_index.js 2012-05-11 20:34:22 +0000
+++ lib/lp/bugs/javascript/bugtask_index.js 2012-05-14 22:21:26 +0000
@@ -409,19 +409,20 @@
privacy_spinner.setStyle('display', 'none');
privacy_link.setStyle('display', 'inline');
+ var banner = Y.lp.app.banner.privacy.getPrivacyBanner();
if (private_flag) {
Y.one('body').replaceClass('public', 'private');
privacy_div.replaceClass('public', 'private');
privacy_text.set(
'innerHTML',
'This report is <strong>private</strong> ');
- Y.lp.app.privacy.display_privacy_notification();
+ banner.show();
} else {
Y.one('body').replaceClass('private', 'public');
privacy_div.replaceClass('private', 'public');
privacy_text.set(
'innerHTML', 'This report is public ');
- Y.lp.app.privacy.hide_privacy_notification();
+ banner.hide();
}
privacy_text.appendChild(privacy_link);
privacy_text.appendChild(privacy_spinner);
@@ -1520,4 +1521,4 @@
"lp.bugs.information_type_choice",
"lp.app.widgets.expander", "lp.client", "escape",
"lp.client.plugins", "lp.app.errors",
- "lp.app.privacy", "lp.app.confirmationoverlay"]});
+ "lp.app.banner.privacy", "lp.app.confirmationoverlay"]});
=== modified file 'lib/lp/bugs/javascript/information_type_choice.js'
--- lib/lp/bugs/javascript/information_type_choice.js 2012-04-24 06:19:16 +0000
+++ lib/lp/bugs/javascript/information_type_choice.js 2012-05-14 22:21:26 +0000
@@ -29,14 +29,14 @@
var body = Y.one('body');
var private_type = (Y.Array.indexOf(LP.cache.private_types, value) >= 0);
var subscription_ns = Y.lp.bugs.bugtask_index.portlets.subscription;
- var privacy_ns = Y.lp.app.privacy;
+ var privacy_banner = Y.lp.app.banner.privacy.getPrivacyBanner();
subscription_ns.update_subscription_status();
if (private_type) {
body.replaceClass('public', 'private');
- privacy_ns.display_privacy_notification();
+ privacy_banner.show();
} else {
body.replaceClass('private', 'public');
- privacy_ns.hide_privacy_notification();
+ privacy_banner.hide();
}
};
@@ -63,7 +63,6 @@
});
privacy_link.addClass('js-action');
};
-
}, "0.1", {"requires": ["base", "oop", "node", "event", "io-base",
- "lazr.choiceedit", "lp.app.privacy",
- "lp.bugs.bugtask_index"]});
+ "lazr.choiceedit", "lp.bugs.bugtask_index",
+ "lp.app.banner.privacy"]});
=== modified file 'lib/lp/bugs/javascript/tests/test_bugtask_delete.html'
--- lib/lp/bugs/javascript/tests/test_bugtask_delete.html 2012-03-14 04:41:36 +0000
+++ lib/lp/bugs/javascript/tests/test_bugtask_delete.html 2012-05-14 22:21:26 +0000
@@ -47,7 +47,7 @@
<script type="text/javascript" src="../../../../../build/js/lp/app/picker/picker.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/picker/picker_patcher.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/picker/person_picker.js"></script>
- <script type="text/javascript" src="../../../../../build/js/lp/app/privacy.js"></script>
+ <script type="text/javascript" src="../../../../../build/js/lp/app/banner/privacy.js"></script>
<script type="text/javascript" src="../../../../../biuld/js/lp/bugs/bug_subscription_portlet.js"></script>
=== modified file 'lib/lp/bugs/javascript/tests/test_information_type_choice.html'
--- lib/lp/bugs/javascript/tests/test_information_type_choice.html 2012-05-09 21:04:05 +0000
+++ lib/lp/bugs/javascript/tests/test_information_type_choice.html 2012-05-14 22:21:26 +0000
@@ -26,31 +26,33 @@
<!-- Dependencies -->
<script type="text/javascript"
- src="../../../../../build/js/lp/app/testing/mockio.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/client.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/extras/extras.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/anim/anim.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/effects/effects.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/lazr/lazr.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/choiceedit/choiceedit.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/banners/privacy.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/overlay/overlay.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/expander.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/app/errors.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/bugs/bug_subscription_portlet.js"></script>
- <script type="text/javascript"
- src="../../../../../build/js/lp/bugs/bugtask_index.js"></script>
+ src="../../../../lp/app/javascript/testing/mockio.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/client.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/extras/extras.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/anim/anim.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/effects/effects.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/lazr/lazr.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/choiceedit/choiceedit.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/overlay/overlay.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/expander.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/errors.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/banners/banner.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/app/javascript/banners/privacy.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/bugs/javascript/bug_subscription_portlet.js"></script>
+ <script type="text/javascript"
+ src="../../../../lp/bugs/javascript/bugtask_index.js"></script>
<!-- The module under test. -->
<script type="text/javascript" src="../information_type_choice.js"></script>
=== modified file 'lib/lp/bugs/javascript/tests/test_information_type_choice.js'
--- lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-04-24 07:44:29 +0000
+++ lib/lp/bugs/javascript/tests/test_information_type_choice.js 2012-05-14 22:21:26 +0000
@@ -35,6 +35,21 @@
},
tearDown: function () {},
+ _shim_privacy_banner: function () {
+ old_func = Y.lp.app.banner.privacy.getPrivacyBanner;
+ Y.lp.app.banner.privacy.getPrivacyBanner = function () {
+ return {
+ show: function () { Y.fire('show') },
+ hide: function () { Y.fire('hide') }
+ }
+ }
+ return old_func;
+ },
+
+ _unshim_privacy_banner: function (old_func) {
+ Y.lp.app.banner.privacy.getPrivacyBanner = old_func;
+ },
+
test_library_exists: function () {
Y.Assert.isObject(Y.lp.bugs.information_type_choice,
"Cannot locate the lp.bugs.information_type_choice module");
@@ -54,31 +69,31 @@
},
test_information_type_save_success_private: function() {
- var privacy_ns = Y.lp.app.privacy;
- var orig_function = privacy_ns.display_privacy_notification;
- var function_called = false;
- privacy_ns.display_privacy_notification = function() {
- function_called = true;
- };
+ var old_func = this._shim_privacy_banner();
+ var flag = false;
+ Y.on('show', function() {
+ flag = true;
+ });
+
ns.information_type_save_success('Private');
var body = Y.one('body');
Y.Assert.isTrue(body.hasClass('private'));
- Y.Assert.isTrue(function_called);
- privacy_ns.display_privacy_notification = orig_function;
+ Y.Assert.isTrue(flag);
+ this._unshim_privacy_banner(old_func);
},
test_information_type_save_success_public: function() {
- var privacy_ns = Y.lp.app.privacy;
- var orig_function = privacy_ns.hide_privacy_notification;
- var function_called = false;
- privacy_ns.hide_privacy_notification = function() {
- function_called = true;
- };
+ var old_func = this._shim_privacy_banner();
+ var flag = false;
+ Y.on('hide', function() {
+ flag = true;
+ });
+
ns.information_type_save_success('Public');
var body = Y.one('body');
Y.Assert.isTrue(body.hasClass('public'));
- Y.Assert.isTrue(function_called);
- privacy_ns.hide_privacy_notification = orig_function;
+ Y.Assert.isTrue(flag);
+ this._unshim_privacy_banner(old_func);
},
test_perform_update_information_type: function() {
@@ -92,9 +107,7 @@
var orig_save_information_type = ns.save_information_type;
var function_called = false;
ns.save_information_type = function(value, lp_client) {
- Y.Assert.areEqual('User Data', value);
- function_called = true;
- };
+ Y.Assert.areEqual('User Data', value); function_called = true; };
private_choice.simulate('click');
Y.Assert.isTrue(function_called);
ns.save_information_type = orig_save_information_type;
@@ -102,5 +115,5 @@
}));
}, '0.1', {'requires': ['test', 'console', 'event', 'node-event-simulate',
- 'lp.testing.mockio', 'lp.client', 'lp.bugs.information_type_choice',
- 'lp.app.privacy']});
+ 'lp.testing.mockio', 'lp.client',
+ 'lp.bugs.information_type_choice']});
=== modified file 'lib/lp/bugs/templates/bugtarget-macros-filebug.pt'
--- lib/lp/bugs/templates/bugtarget-macros-filebug.pt 2012-04-26 15:37:30 +0000
+++ lib/lp/bugs/templates/bugtarget-macros-filebug.pt 2012-05-14 22:21:26 +0000
@@ -328,30 +328,32 @@
<metal:privacy define-macro="bug-reporting-privacy">
<tal:private condition="view/isPrivate">
<script type="text/javascript">
- LPJS.use('lp.app.privacy', function(Y) {
+ LPJS.use('lp.app.banner.privacy', function(Y) {
Y.on('domready', function() {
- var cfg = {
- notification_text: "This report will be private. "
- + "You can disclose it later."
- };
- Y.lp.app.privacy.setup_privacy_notification(cfg);
- Y.lp.app.privacy.display_privacy_notification();
+ var cfg = {
+ notification_text: "This report will be private. "
+ + "You can disclose it later."
+ };
+ var banner = new Y.lp.app.banner.privacy.PrivacyBanner(cfg);
+ banner.show();
});
});
</script>
</tal:private>
<tal:flip-privacy>
<script type="text/javascript">
- LPJS.use('node-event-delegate', 'lp.app.privacy', function(Y) {
+ LPJS.use('node-event-delegate', 'lp.app.banner.privacy', function(Y) {
var setup_information_type = function() {
var itypes_table = Y.one('.radio-button-widget');
itypes_table.delegate('click', function() {
var private_type = (Y.Array.indexOf(
LP.cache.private_types, this.get('value')) >= 0);
+ privacy_ns = Y.lp.app.banner.privacy;
+ var banner = privacy_ns.getPrivacyBanner();
if (private_type) {
- Y.lp.app.privacy.display_privacy_notification();
+ banner.show();
} else {
- Y.lp.app.privacy.hide_privacy_notification();
+ banner.hide();
}
}, "input[name='field.information_type']");
};
@@ -361,14 +363,16 @@
+ "because it is a security vulnerability. You "
+ "can disclose it later."
};
- Y.lp.app.privacy.setup_privacy_notification(cfg);
+ var privacy_ns = Y.lp.app.banner.privacy;
+ var banner = new privacy_ns.PrivacyBanner(cfg);
+ banner.render();
var sec = Y.one('[id="field.security_related"]');
sec.on('change', function() {
var checked = sec.get('checked');
if (checked) {
- Y.lp.app.privacy.display_privacy_notification();
+ banner.show();
} else {
- Y.lp.app.privacy.hide_privacy_notification();
+ banner.hide();
}
});
};
Follow ups