Bug 1597554 - Port |Bug 537378 - "search messages" (Ctrl+Shift+F) should be enabled in the 3pane - doesn't open if no folder or account selected/focused in folder pane.|. r=frg a=frg CLOSED TREE
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sun, 24 Nov 2019 14:23:24 +0100
changeset 32378 c12e2470fc25712059d8271e4f0b8175e4e67c9e
parent 32377 232db96d678a8360116d6f2d2f956432ea6a9ab7
child 32379 24c7d081d9776547189442453a3cd831ba7815aa
push id231
push userfrgrahl@gmx.net
push dateSun, 24 Nov 2019 13:24:21 +0000
treeherdercomm-esr60@fddcb5bd203c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg, frg
bugs1597554, 537378
Bug 1597554 - Port |Bug 537378 - "search messages" (Ctrl+Shift+F) should be enabled in the 3pane - doesn't open if no folder or account selected/focused in folder pane.|. r=frg a=frg CLOSED TREE
suite/mailnews/content/mail3PaneWindowCommands.js
suite/mailnews/content/mailWindowOverlay.js
suite/mailnews/content/mailWindowOverlay.xul
--- a/suite/mailnews/content/mail3PaneWindowCommands.js
+++ b/suite/mailnews/content/mail3PaneWindowCommands.js
@@ -1,13 +1,20 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+/**
+ * Functionality for the main application window (aka the 3pane) usually
+ * consisting of folder pane, thread pane and message pane.
+ */
+
+ChromeUtils.import("resource:///modules/mailServices.js");
+
 // Controller object for folder pane
 var FolderPaneController =
 {
   supportsCommand: function(command)
   {
     switch ( command )
     {
       case "cmd_delete":
@@ -377,20 +384,20 @@ var DefaultController =
         return IsFolderSelected();
       case "cmd_find":
       case "cmd_findNext":
       case "cmd_findPrev":
         return IsMessageDisplayedInMessagePane();
         break;
       case "button_search":
       case "cmd_search":
-        return IsCanSearchMessagesEnabled();
+        return MailServices.accounts.accounts.length > 0;
       case "cmd_selectAll":
       case "cmd_selectFlagged":
-        return gDBView != null;
+        return !!gDBView;
       // these are enabled on when we are in threaded mode
       case "cmd_selectThread":
         if (GetNumSelectedMessages() <= 0) return false;
       case "cmd_expandAllThreads":
       case "cmd_collapseAllThreads":
         return gDBView && (gDBView.viewFlags & nsMsgViewFlagsType.kThreadedDisplay);
         break;
       case "cmd_nextFlaggedMsg":
@@ -885,27 +892,16 @@ function IsSubscribeEnabled()
 
 function IsRenameFolderEnabled()
 {
   let folders = GetSelectedMsgFolders();
   return folders.length == 1 && folders[0].canRename &&
          isCommandEnabled("cmd_renameFolder");
 }
 
-function IsCanSearchMessagesEnabled()
-{
-  var folderURI = GetSelectedFolderURI();
-  if (!folderURI)
-    return false;
-
-  var folder = GetMsgFolderFromUri(folderURI, false);
-  return folder.server.canSearchMessages &&
-         !(folder.flags & Ci.nsMsgFolderFlags.Virtual);
-}
-
 function IsFolderCharsetEnabled()
 {
   return IsFolderSelected();
 }
 
 function IsPropertiesEnabled(command)
 {
   let folders = GetSelectedMsgFolders();
--- a/suite/mailnews/content/mailWindowOverlay.js
+++ b/suite/mailnews/content/mailWindowOverlay.js
@@ -2970,24 +2970,27 @@ function SendMDNResponse()
   gMessageNotificationBar.mdnGenerator.userAgreed();
 }
 
 function IgnoreMDNResponse()
 {
   gMessageNotificationBar.mdnGenerator.userDeclined();
 }
 
-function MsgSearchMessages()
-{
-  var preselectedFolder = null;
-  if ("GetFirstSelectedMsgFolder" in window)
-    preselectedFolder = GetFirstSelectedMsgFolder();
-
-  var args = { folder: preselectedFolder };
-  OpenOrFocusWindow(args, "mailnews:search", "chrome://messenger/content/SearchDialog.xul");
+/**
+ * Opens a search window with the given folder, or the displayed one if none is
+ * chosen.
+ *
+ * @param [aFolder] the folder to open the search window for, if different from
+ *                  the displayed one
+ */
+function MsgSearchMessages(aFolder) {
+  let folder = aFolder || gFolderDisplay.displayedFolder;
+  OpenOrFocusWindow({ folder: folder }, "mailnews:search",
+                    "chrome://messenger/content/SearchDialog.xul");
 }
 
 function MsgJunkMailInfo(aCheckFirstUse)
 {
   if (aCheckFirstUse) {
     if (!Services.prefs.getBoolPref("mailnews.ui.junk.firstuse"))
       return;
     Services.prefs.setBoolPref("mailnews.ui.junk.firstuse", false);
--- a/suite/mailnews/content/mailWindowOverlay.xul
+++ b/suite/mailnews/content/mailWindowOverlay.xul
@@ -177,19 +177,22 @@
   <command id="cmd_properties" oncommand="goDoCommand('cmd_properties')"
          valueNewsgroup="&folderPropsNewsgroupCmd.label;"
          valueFolder="&folderPropsFolderCmd.label;"
          valueGeneric="&folderPropsCmd.label;"/>
   <command id="cmd_find" oncommand="goDoCommand('cmd_find')" disabled="true"/>
   <command id="cmd_findNext"
            oncommand="goDoCommand('cmd_findNext');"
            disabled="true"/>
-  <command id="cmd_findPrev"  oncommand="goDoCommand('cmd_findPrev')"  disabled="true"/>
+  <command id="cmd_findPrev"
+           oncommand="goDoCommand('cmd_findPrev');"
+           disabled="true"/>
   <command id="cmd_findTypeText"/>
   <command id="cmd_findTypeLinks"/>
+  <command id="cmd_search" oncommand="goDoCommand('cmd_search');"/>
   <command id="cmd_stop" oncommand="MsgStop();"/>
 </commandset>
 
 <commandset id="mailEditContextMenuItems">
   <command id="cmd_copyLink"/>
   <command id="cmd_copyImage"/>
 </commandset>
 
@@ -296,17 +299,16 @@
            oncommand="goDoCommand('cmd_applyFiltersToSelection');"
            disabled="true"
            valueSelection="&filtersApplyToSelection.label;"
            valueSelectionAccessKey="&filtersApplyToSelection.accesskey;"
            valueMessage="&filtersApplyToMessage.label;"
            valueMessageAccessKey="&filtersApplyToMessage.accesskey;"/>
   <command id="cmd_runJunkControls" oncommand="goDoCommand('cmd_runJunkControls');" disabled="true"/>
   <command id="cmd_deleteJunk" oncommand="goDoCommand('cmd_deleteJunk');" disabled="true"/>
-  <command id="cmd_search" oncommand="goDoCommand('cmd_search')"/>
 </commandset>
 
 <keyset id="mailKeys">
   <key id="space" key=" " modifiers="shift any" oncommand="SpaceHit(event);"/>
 
   <!-- File Menu -->
   <key id="key_newTab"
        key="&newTabCmd.key;"