Merge lp:~wallyworld/launchpad/show-ajax-notifications into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Ian Booth |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12738 |
Proposed branch: | lp:~wallyworld/launchpad/show-ajax-notifications |
Merge into: | lp:launchpad |
Diff against target: |
268 lines (+130/-9) 10 files modified
lib/canonical/launchpad/webapp/configure.zcml (+5/-0) lib/canonical/launchpad/webapp/servers.py (+0/-1) lib/lp/app/javascript/client.js (+63/-0) lib/lp/app/javascript/tests/test_lp_client.html (+3/-1) lib/lp/app/javascript/tests/test_lp_client.js (+47/-0) lib/lp/bugs/stories/webservice/xx-bug.txt (+5/-0) lib/lp/bugs/tests/test_bugs_webservice.py (+2/-2) lib/lp/code/model/tests/test_branchset.py (+1/-1) lib/lp/registry/tests/test_person.py (+2/-2) versions.cfg (+2/-2) |
To merge this branch: | bzr merge lp:~wallyworld/launchpad/show-ajax-notifications |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Henning Eggers (community) | code | Approve | |
Review via email: mp+54342@code.launchpad.net |
Commit message
[r=henninge][no-qa] Display notifications that may be included in an xhr response object. These are of type informational, error, warning or debug.
Description of the change
Display notifications that may be included in an xhr response object (as we use for things like "Recipes are in beta", "Thanks for submitting a bug report" etc). These are of type informational, error, warning or debug.
This branch uses new functionality added to lazr.restful in branch lp:~wallyworld/lazr.restful/propogate-notifications
== Implementation ==
Notifications generated resulting from page loads are rendered using a tales macro. The HTML is inserted under the "context-
When a lazr restful call is made via client.js, any notifications added to the HTTP response by the server using the addNotification() call will be packaged up and sent back using the X-Lazr-
This branch is a prerequisite for the real reason for adding this functionality: lp:~wallyworld/launchpad/assign-non-contributor to fix bug 698138
== Tests ==
Added new javascript unit test case to test_lp_client.js. Tests:
test_
== Lint ==
Linting changed files:
versions.cfg
lib/canonical
lib/canonical
lib/lp/
lib/lp/
lib/lp/
./versions.cfg
241: Line exceeds 78 characters.
./lib/lp/
4: Line exceeds 78 characters.
191: Line exceeds 78 characters.
566: Line exceeds 78 characters.
614: Line exceeds 78 characters.
741: Line exceeds 78 characters.
743: Line exceeds 78 characters.
./lib/lp/
22: Line exceeds 78 characters.
23: Line exceeds 78 characters.
25: Line exceeds 78 characters.
38: Line exceeds 78 characters.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Ian,
I am doing this review although I am not an experienced Javascript reviewer or
coder. I am hoping, hat this will help to change that. ;-) Feel free to
request another review.
A note on the MP itself: You mixed up commit message and the description. You
should swap that back. ;-)
I will mark this needs-information for now just because I have so many
questions. ;-)
review needs-information
Cheers,
Henning
Am 28.03.2011 04:09, schrieb Ian Booth: launchpad/ webapp/ configure. zcml' launchpad/ webapp/ servers. py' app/javascript/ client. js' app/javascript/ client. js 2011-02-25 01:54:00 +0000 app/javascript/ client. js 2011-03-28 01:50:57 +0000 getResponseHead er('Content- Type'); type.substring( 0,16) == 'application/json') { parse(response. responseText) ; notifications( getResponseHead er('X-Lazr- Notifications' )); wrap_resource( uri, representation); success( wrapped) ; notifications( notifications) { notifications( div_class) { div.'+div_ class); function( node) { 'parentNode' ); removeChild( node); notifications( 'error' ); notifications( 'warning' ); notifications( 'informational' ); notifications( 'debug' );
> === modified file 'lib/canonical/
> === modified file 'lib/canonical/
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -242,6 +242,8 @@
> var media_type = response.
> if (media_
> representation = Y.JSON.
> + display_
> + response.
> wrapped = client.
> result = old_on_
> if (update_cache) {
> @@ -254,6 +256,73 @@
> }
> };
>
> +/**
> + * Display a list of notifications - error, warning, informational or debug.
> + * @param notifications An json encoded array of (level, message) tuples.
> + */
> +function display_
> + if (notifications === undefined)
> + return;
> +
> + // First remove any existing notifications.
> + function remove_
> + var nodes = Y.all('
> + nodes.each(
> + var parent = node.get(
> + parent.
> + });
> + }
> + remove_
> + remove_
> + remove_
> + remove_
I am a bit worried that this might accidentally remove more than wanted. Class
names like "error" and "warning" seem so general that somebody might use them
locally. How about "lp-error", "lp-warning" etc. ?
> + parse(notificat ions); notifications, function( notification, key) { push(message) ; message) ; push(message) ; push(message) ;
> + // Now display the new ones.
> + notifications = Y.JSON.
> + var warnings = new Array();
> + var errors = new Array();
> + var infos = new Array();
> + var debugs = new Array();
> +
> + Y.each(
> + var level = notification[0];
> + var message = notification[1];
> + switch (level) {
> + case 10:
> + debugs.
> + break;
> + case 20:
> + infos.push(
> + break;
> + case 30:
> + warnings.
> + break;
> + case 40:
> + errors.
> + break;
> + }
> + });
> + // The place where we want to insert the notification divs.
> + var last_messag...