Bug 360926 - add confirmation dialog to Identity list editor. ui-r=bwinton, r=IanN, r=squib
authoraceman <acelists@atlas.sk>
Fri, 03 Aug 2012 01:47:49 -0500
changeset 13190 42234d57ebdc3509e4471db5a1bb00503c6c472b
parent 13189 f060e51439c5876ea3fa685791a5075d1a57a5fc
child 13191 6bfbaf41e44b3147fa5415e4f81c1bd7dc240feb
push idunknown
push userunknown
push dateunknown
reviewersbwinton, IanN, squib
bugs360926
Bug 360926 - add confirmation dialog to Identity list editor. ui-r=bwinton, r=IanN, r=squib
mail/locales/en-US/chrome/messenger/prefs.properties
mailnews/base/prefs/content/am-identities-list.js
suite/locales/en-US/chrome/mailnews/pref/prefs.properties
--- a/mail/locales/en-US/chrome/messenger/prefs.properties
+++ b/mail/locales/en-US/chrome/messenger/prefs.properties
@@ -50,17 +50,24 @@ prefPanel-copies=Copies & Folders
 prefPanel-synchronization=Synchronization & Storage
 prefPanel-diskspace=Disk Space
 prefPanel-addressing=Composition & Addressing
 prefPanel-junk=Junk Settings
 ## LOCALIZATION NOTE (prefPanel-smtp): Don't translate "SMTP"
 prefPanel-smtp=Outgoing Server (SMTP)
 
 # account manager multiple identity support
-#LOCALIZATION NOTE: accountName: %1$S 
+#LOCALIZATION NOTE: accountName: %1$S
 identity-list-title=Identities for %1$S
 
 identity-edit-req=You must specify a valid email address for this identity.
 identity-edit-req-title=Error Creating Identity
 
+## LOCALIZATION NOTE (identity-delete-confirm): %S is the identity name
+# and should be put on a new line. The new line is produced with the "\n" string.
+identity-delete-confirm=Are you sure you want to delete the identity\n%S?
+## LOCALIZATION NOTE (identity-delete-confirm-title): %S is the account name
+identity-delete-confirm-title=Deleting identity for %S
+identity-delete-confirm-button=Delete
+
 choosefile=Choose a file
 
 forAccount=For account "%S"
--- a/mailnews/base/prefs/content/am-identities-list.js
+++ b/mailnews/base/prefs/content/am-identities-list.js
@@ -1,13 +1,15 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 var gIdentityListBox;                 // the root <listbox> node
 var gAddButton;
 var gEditButton;
 var gDeleteButton;
 
 var gAccount = null;  // the account we are showing the identities for
 
 function onLoad()
@@ -54,17 +56,18 @@ function refreshIdentityList()
 
 // opens the identity editor dialog
 // identity: pass in the identity (if any) to load in the dialog
 function openIdentityEditor(identity)
 {
   var result = false;
   var args = { identity: identity, account: gAccount, result: result };
 
-  window.openDialog("am-identity-edit.xul", "", "chrome,modal,resizable=no,centerscreen", args);
+  window.openDialog("am-identity-edit.xul", "",
+                    "chrome,modal,resizable=no,centerscreen", args);
 
   var selectedItemIndex = gIdentityListBox.selectedIndex;
 
   if (args.result)
   {
     refreshIdentityList();
     gIdentityListBox.selectedIndex = selectedItemIndex;
   }
@@ -106,17 +109,33 @@ function updateButtons()
   }
 }
 
 function onDelete(event)
 {
   if (gIdentityListBox.getRowCount() <= 1)  // don't support deleting the last identity
     return;
 
-  gAccount.removeIdentity(getSelectedIdentity());
+  // get delete confirmation
+  let selectedIdentity = getSelectedIdentity();
+
+  let prefsBundle = document.getElementById("bundle_prefs");
+  let confirmTitle = prefsBundle.getFormattedString("identity-delete-confirm-title",
+                                                    [window.arguments[0].accountName]);
+  let confirmText = prefsBundle.getFormattedString("identity-delete-confirm",
+                                                   [selectedIdentity.identityName]);
+  let confirmButton = prefsBundle.getString("identity-delete-confirm-button");
+
+  if (Services.prompt.confirmEx(window, confirmTitle, confirmText,
+                                (Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING) +
+                                (Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL),
+                                confirmButton, null, null, null, {}))
+    return;
+
+  gAccount.removeIdentity(selectedIdentity);
   // rebuild the list
   refreshIdentityList();
 }
 
 function onOk()
 {
   window.arguments[0].result = true;
   return true;
--- a/suite/locales/en-US/chrome/mailnews/pref/prefs.properties
+++ b/suite/locales/en-US/chrome/mailnews/pref/prefs.properties
@@ -51,17 +51,24 @@ prefPanel-copies=Copies & Folders
 prefPanel-synchronization=Synchronization & Storage
 prefPanel-diskspace=Disk Space
 prefPanel-addressing=Composition & Addressing
 prefPanel-junk=Junk Settings
 ## LOCALIZATION NOTE (prefPanel-smtp): Don't translate "SMTP"
 prefPanel-smtp=Outgoing Server (SMTP)
 
 # account manager multiple identity support
-#LOCALIZATION NOTE: accountName: %1$S 
+#LOCALIZATION NOTE: accountName: %1$S
 identity-list-title=Identities for %1$S
 
 identity-edit-req=You must specify a valid email address for this identity.
 identity-edit-req-title=Error Creating Identity
 
+## LOCALIZATION NOTE (identity-delete-confirm): %S is the identity name
+# and should be put on a new line. The new line is produced with the "\n" string.
+identity-delete-confirm=Are you sure you want to delete the identity\n%S?
+## LOCALIZATION NOTE (identity-delete-confirm-title): %S is the account name
+identity-delete-confirm-title=Deleting identity for %S
+identity-delete-confirm-button=Delete
+
 choosefile=Choose a file
 
 forAccount=For account "%S"