Merge lp:~jcsackett/launchpad/private-bugs-open-teams-and-delegate-teams-oh-my into lp:launchpad

Proposed by j.c.sackett
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: 14334
Proposed branch: lp:~jcsackett/launchpad/private-bugs-open-teams-and-delegate-teams-oh-my
Merge into: lp:launchpad
Diff against target: 22 lines (+8/-2)
1 file modified
lib/lp/app/javascript/subscribers/subscribers_list.js (+8/-2)
To merge this branch: bzr merge lp:~jcsackett/launchpad/private-bugs-open-teams-and-delegate-teams-oh-my
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+82703@code.launchpad.net

Commit message

[r=bac][bug=878531] Provides a better error message to webapp user when they try to subscribe open/delegated teams to private bugs.

Description of the change

Summary
=======
You can no longer add open or delegated teams as a subscriber on a private
bug. This is implemented on the model/API level, and handled by try/except on
the view level. However, subscription in the webapp is actually managed by
javascript, which was simply returning the 400 BAD REQUEST data as an error
msg.

This branch updates the subscriber error handler to show response text error
msg, if it exists.

Preimplementation
=================
None

Implementation
==============
In the _subscribe function's error handling, we now check if an error
condition occurred (response code of 400) and if response text exists. If
those conditions are met, we know we're getting an error message from the API,
which we should display. We pass that along as the error msg instead of the
bad request data.

Tests
=====
bin/test -vvc --layer=YUI

QA
==
Attempt to add an open/delegated team to a private bug. You will receive an
error message saying that open and delegated teams can't be subscribed to
private bugs, as you would via an API call.

Lint
====
This branch is lint free.

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

Looks good Jonathan.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
2--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-09-16 00:11:16 +0000
3+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2011-11-18 16:26:25 +0000
4@@ -512,10 +512,16 @@
5 } else {
6 loader.subscribers_list.stopActivity();
7 }
8+ if (response.status === 400 && response.responseText !== undefined) {
9+ error_msg = response.responseText;
10+ } else {
11+ error_msg = (
12+ response.status + " (" + response.statusText + "). " +
13+ "Failed to subscribe " + subscriber.display_name + ".");
14+ }
15 Y.lp.app.errors.display_error(
16 false,
17- response.status + " (" + response.statusText + "). " +
18- "Failed to subscribe " + subscriber.display_name + "."
19+ error_msg
20 );
21 }
22 var config = {