Merge lp:~benji/launchpad/bug-771231 into lp:launchpad

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: no longer in the source branch.
Merged at revision: 12964
Proposed branch: lp:~benji/launchpad/bug-771231
Merge into: lp:launchpad
Diff against target: 206 lines (+113/-16)
3 files modified
lib/lp/registry/javascript/structural-subscription.js (+30/-0)
lib/lp/registry/javascript/tests/test_structural_subscription.html (+1/-0)
lib/lp/registry/javascript/tests/test_structural_subscription.js (+82/-16)
To merge this branch: bzr merge lp:~benji/launchpad/bug-771231
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+59555@code.launchpad.net

Commit message

[r=bac][bug=771231] add feedback when creating a structural subscription

Description of the change

Bug 771231 is about getting confirmation that adding a structural
subscription worked and that the new subscription is configured the way
the user intended. This branch adds such a confirmation by building an
informational message box (the same kind of box
response.addNotification(text) results in).

The related JS tests can be run by loading
lib/lp/registry/javascript/tests/test_structural_subscription.html in a
browser. They all pass locally.

The make lint report is clean.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
--- lib/lp/registry/javascript/structural-subscription.js 2011-04-28 17:07:38 +0000
+++ lib/lp/registry/javascript/structural-subscription.js 2011-04-29 21:10:54 +0000
@@ -1567,6 +1567,36 @@
1567 config, subscription_info, 0,1567 config, subscription_info, 0,
1568 filter_info, filter_id, anim_node);1568 filter_info, filter_id, anim_node);
1569 Y.lazr.anim.green_flash({node: anim_node}).run();1569 Y.lazr.anim.green_flash({node: anim_node}).run();
1570 } else {
1571 // Since there is no filter description to update we need another
1572 // way to tell the user that the subscription was sucessfully
1573 // added. We'll do that by creating an informational message box.
1574 var description = filter.get('description');
1575 var header = Y.Node.create('<div/>')
1576 .setStyle('marginBottom', '1em')
1577 .append('The subscription')
1578 .append('&#32;'); // a space
1579 if (description) {
1580 header
1581 .append('named "')
1582 .append(Y.Node.create('<span/>')
1583 .set('text', description))
1584 .append('"')
1585 .append('&#32;'); // a space
1586 }
1587 header.append('has been created.');
1588
1589 Y.one('#request-notifications')
1590 .empty()
1591 .append(Y.Node.create('<div/>')
1592 // We're creating an informational message box.
1593 .addClass('informational')
1594 .addClass('message')
1595 // The box needs to be a little wider to accomodate the
1596 // wordy subscription description.
1597 .setStyle('width', '50em')
1598 .append(header)
1599 .append(create_filter_description(filter.getAttrs())));
1570 }1600 }
1571 };1601 };
1572}1602}
15731603
=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.html'
--- lib/lp/registry/javascript/tests/test_structural_subscription.html 2011-04-11 16:12:18 +0000
+++ lib/lp/registry/javascript/tests/test_structural_subscription.html 2011-04-29 21:10:54 +0000
@@ -55,6 +55,7 @@
55 </style>55 </style>
56</head>56</head>
57<body class="yui3-skin-sam">57<body class="yui3-skin-sam">
58 <div id="request-notifications"></div>
58 <div id="log"></div>59 <div id="log"></div>
59</body>60</body>
60</html>61</html>
6162
=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
--- lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-04-27 22:00:21 +0000
+++ lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-04-29 21:10:54 +0000
@@ -907,8 +907,18 @@
907 setUp: function() {907 setUp: function() {
908 var TestBugFilter = function() {};908 var TestBugFilter = function() {};
909 TestBugFilter.prototype = {909 TestBugFilter.prototype = {
910 'getAttrs': function () {910 get: function (name) {
911 return {};911 return 'DESCRIPTION';
912 },
913 getAttrs: function () {
914 return {
915 description: 'DESCRIPTION',
916 statuses: [],
917 importances: [],
918 tags: [],
919 find_all_tags: true,
920 bug_notification_level: 'Discussion'
921 };
912 }922 }
913 };923 };
914 // We need an lp_client that will appear to succesfully create the924 // We need an lp_client that will appear to succesfully create the
@@ -920,7 +930,7 @@
920 this.post_called = true;930 this.post_called = true;
921 },931 },
922 patch: function(uri, representation, config, headers) {932 patch: function(uri, representation, config, headers) {
923 config.on.success();933 config.on.success(new TestBugFilter());
924 this.patch_called = true;934 this.patch_called = true;
925 },935 },
926 post_called: false,936 post_called: false,
@@ -977,6 +987,49 @@
977 }));987 }));
978988
979 suite.add(new Y.Test.Case({989 suite.add(new Y.Test.Case({
990 // The make_add_subscription_success_handler function constructs a
991 // function that gives a visual feedback after adding a subscription.
992
993 name:
994 'Structural Subscription: make_add_subscription_success_handler',
995
996 _should: {error: {}},
997
998 setUp: function() {
999 this.TestBugFilter = function() {};
1000 this.TestBugFilter.prototype = {
1001 get: function (name) {
1002 return 'DESCRIPTION';
1003 },
1004 getAttrs: function () {
1005 return {
1006 description: 'DESCRIPTION',
1007 statuses: [],
1008 importances: [],
1009 tags: [],
1010 find_all_tags: true,
1011 bug_notification_level: 'Discussion'
1012 };
1013 }
1014 };
1015 },
1016
1017 test_description_is_added: function() {
1018 // If we add a subscription on a page that doesn't display
1019 // subcription details then we need to add an "informational
1020 // message" describing the just-added subscription.
1021 var handler;
1022 var config = {add_filter_description: false};
1023 handler = module._make_add_subscription_success_handler(config);
1024 var form_data = {};
1025 handler(form_data, new this.TestBugFilter());
1026 var text = Y.one('#request-notifications').get('text');
1027 Assert.isTrue(text.indexOf('DESCRIPTION') !== -1);
1028 }
1029
1030 }));
1031
1032 suite.add(new Y.Test.Case({
980 name: 'Structural Subscription: edit subcription workflow',1033 name: 'Structural Subscription: edit subcription workflow',
9811034
982 _should: {error: {}},1035 _should: {error: {}},
@@ -1198,10 +1251,11 @@
1198 };1251 };
1199 this.content_box = create_test_node();1252 this.content_box = create_test_node();
1200 Y.one('body').appendChild(this.content_box);1253 Y.one('body').appendChild(this.content_box);
1254 this.original_lp = monkeypatch_LP();
1201 },1255 },
12021256
1203 tearDown: function() {1257 tearDown: function() {
1204 //delete this.configuration;1258 window.LP = this.original_lp;
1205 remove_test_node();1259 remove_test_node();
1206 delete this.content_box;1260 delete this.content_box;
1207 },1261 },
@@ -1257,18 +1311,6 @@
1257 }, 20);1311 }, 20);
1258 },1312 },
12591313
1260 // Success handler for adding a subscription does nothing in
1261 // the DOM if config.add_filter_description is not set.
1262 test_make_add_subscription_success_handler_nothing: function() {
1263 var success_handler =
1264 module._make_add_subscription_success_handler(this.config);
1265 var subs_list = this.content_box.appendChild(
1266 Y.Node.create('<div id="structural-subscriptions"></div>'));
1267 success_handler();
1268 // No sub-nodes have been created in the subs_list node.
1269 Assert.isTrue(subs_list.all('div.subscription-filter').isEmpty());
1270 },
1271
1272 // Success handler for adding a subscription creates1314 // Success handler for adding a subscription creates
1273 // a subscription listing if there's none and adds a filter to it.1315 // a subscription listing if there's none and adds a filter to it.
1274 test_make_add_subscription_success_handler_empty_list: function() {1316 test_make_add_subscription_success_handler_empty_list: function() {
@@ -1286,6 +1328,9 @@
1286 url: "http://target/" };1328 url: "http://target/" };
1287 window.LP.cache.target_info = target_info;1329 window.LP.cache.target_info = target_info;
1288 var filter = {1330 var filter = {
1331 get: function (name) {
1332 return 'DESCRIPTION';
1333 },
1289 getAttrs: function() {1334 getAttrs: function() {
1290 return {1335 return {
1291 importances: [],1336 importances: [],
@@ -1330,6 +1375,27 @@
1330 var target_info = {1375 var target_info = {
1331 title: "Subscription target",1376 title: "Subscription target",
1332 url: "http://target/" };1377 url: "http://target/" };
1378 window.LP.cache.subscription_info = [{
1379 target_url: 'http://example.com',
1380 target_title:'Example project',
1381 filters: [{
1382 filter: {
1383 description: 'DESCRIPTION',
1384 statuses: [],
1385 importances: [],
1386 tags: [],
1387 find_all_tags: true,
1388 bug_notification_level: 'Discussion',
1389 self_link: 'http://example.com/a_filter'
1390 },
1391 can_mute: true,
1392 is_muted: false,
1393 subscriber_is_team: false,
1394 subscriber_url: 'http://example.com/subscriber',
1395 subscriber_title: 'Thidwick',
1396 user_is_team_admin: false
1397 }]
1398 }];
1333 window.LP.cache.target_info = target_info;1399 window.LP.cache.target_info = target_info;
1334 var filter = {1400 var filter = {
1335 getAttrs: function() {1401 getAttrs: function() {