Bug 1481915 - Do not allow converting Local Folders to maildir if the needed pref isn't set. r=mkmelin a=jorgk
authoraceman <acelists@atlas.sk>
Sun, 18 Nov 2018 15:52:00 +0100
changeset 33504 93768af94f66a9d6e66e07042f9ed333772acabb
parent 33503 5450ff655f69ae201d4fca1cbda2f8b2d3f34435
child 33505 73dcb0c167eaa05273c6e01dc4634f1d9c4cdf73
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersmkmelin, jorgk
bugs1481915
Bug 1481915 - Do not allow converting Local Folders to maildir if the needed pref isn't set. r=mkmelin a=jorgk
mailnews/base/prefs/content/am-serverwithnoidentities.js
--- a/mailnews/base/prefs/content/am-serverwithnoidentities.js
+++ b/mailnews/base/prefs/content/am-serverwithnoidentities.js
@@ -1,16 +1,16 @@
 /* -*- 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/. */
 
 ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm");
 
-var gAccount;
+var gServer;
 var gOriginalStoreType;
 
 /**
  * Called when the store type menu is clicked.
  * @param {Object} aStoreTypeElement - store type menu list element.
  */
 function clickStoreTypeMenu(aStoreTypeElement) {
   if (aStoreTypeElement.value == gOriginalStoreType) {
@@ -18,18 +18,17 @@ function clickStoreTypeMenu(aStoreTypeEl
   }
 
   // Response from migration dialog modal. If the conversion is complete
   // 'response.newRootFolder' will hold the path to the new account root folder,
   // otherwise 'response.newRootFolder' will be null.
   let response = { newRootFolder: null };
   // Send 'response' as an argument to converterDialog.xhtml.
   window.openDialog("converterDialog.xhtml","mailnews:mailstoreconverter",
-                    "modal,centerscreen,width=800,height=180",
-                    gAccount.incomingServer,
+                    "modal,centerscreen,width=800,height=180", gServer,
                     aStoreTypeElement.value, response);
   changeStoreType(response);
 }
 
 /**
  * Revert store type to the original store type if converter modal closes
  * before migration is complete, otherwise change original store type to
  * currently selected store type.
@@ -48,30 +47,33 @@ function changeStoreType(aResponse) {
     // The conversion failed or was cancelled.
     // Restore selected item to what was selected before conversion.
     document.getElementById("server.storeTypeMenulist").value =
       gOriginalStoreType;
   }
 }
 
 function onInit(aPageId, aServerId) {
-
   // UI for account store type
   let storeTypeElement = document.getElementById("server.storeTypeMenulist");
   // set the menuitem to match the account
   let currentStoreID = document.getElementById("server.storeContractID")
                                .getAttribute("value");
   let targetItem = storeTypeElement.getElementsByAttribute("value", currentStoreID);
   storeTypeElement.selectedItem = targetItem[0];
+  // Disable store type change if store has not been used yet.
+  storeTypeElement.setAttribute("disabled",
+    gServer.getBoolValue("canChangeStoreType") ?
+      "false" : !Services.prefs.getBoolPref("mail.store_conversion_enabled"));
   // Initialise 'gOriginalStoreType' to the item that was originally selected.
   gOriginalStoreType = storeTypeElement.value;
 }
 
 function onPreInit(account, accountValues) {
-  gAccount = account;
+  gServer = account.incomingServer;
 }
 
 function onSave()
 {
   let storeContractID = document.getElementById("server.storeTypeMenulist")
                                 .selectedItem
                                 .value;
   document.getElementById("server.storeContractID")