Now displays a notification box when an error occurred posting a comment. With a retry button (but no cowbell).
authorShawn Wilsher <me@shawnwilsher.com>
Thu, 05 Nov 2009 07:51:57 -0800
changeset 30 ffe19e7a72d5cde8c622a8a68ae4c81dab5eb5ca
parent 29 561ac9f839ebaa116ccd8dbeebbbddfb82893f96
child 31 b481c842050403750eadbdad71ee872fe43bfa3b
push id16
push usersdwilsh@shawnwilsher.com
push dateThu, 05 Nov 2009 16:17:28 +0000
Now displays a notification box when an error occurred posting a comment. With a retry button (but no cowbell).
resource/BugzillaHelper.jsm
--- a/resource/BugzillaHelper.jsm
+++ b/resource/BugzillaHelper.jsm
@@ -175,17 +175,37 @@ CommentActivity.prototype = {
    * To be called when an error occurred.  Updates the UI to indicate that an
    * error occurred and the user should retry.
    */
   error: function CA_error()
   {
     this._process.state = Ci.nsIActivityProcess.STATE_WAITINGFORRETRY;
 
     // We need to break the cycle between this and the process.
+    let process = this._process;
     this._process = null;
+
+    // Notify the user that an error occurred as well.
+    let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
+             getService(Ci.nsIWindowMediator);
+    let win = wm.getMostRecentWindow("mail:3pane");
+    if (!win)
+      return;
+    let nb = win.document.getElementById("mail-notification-box");
+
+    let message = "An error occurred posting a comment to bug " + this._bug;
+    let self = this;
+    let buttons = [
+      {
+        label: "Retry",
+        callback: function() { self.retry(process) },
+      },
+    ];
+    nb.appendNotification(message, "comment" + this._bug, "",
+                          nb.PRIORITY_WARNING_MEDIUM, buttons);
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsIActivityRetryHandler
 
   retry: function CA_retry(aProcess)
   {
     // Recreate our cycle - it will break again when we complete.
@@ -288,12 +308,11 @@ function commentHandler(aResponseCode,
     activity.complete();
     let auth = aContext.auth;
     if (auth)
       storePassword(auth.username, auth.password);
     return;
   }
   activity.error();
   // We had something unexpected.  Tell the user.
-  // XXX dispatch to notification box (id="mail-notification-box" in parent)
   Components.utils.reportError("Got HTTP/" + aResponseCode + "\n" +
                                aResponse + "\n for comment" + aContext.comment);
 }