Bug 717264 - Move Quick Filter Bar toggle button from tab toolbar to mail toolbar. ui-r+r=bwinton.
--- a/mail/base/content/mailWindowOverlay.xul
+++ b/mail/base/content/mailWindowOverlay.xul
@@ -1966,19 +1966,19 @@
class="inline-toolbar chromeclass-toolbar"
toolbarname="&showMessengerToolbarCmd.label;"
accesskey="&showMessengerToolbarCmd.accesskey;"
fullscreentoolbar="true" mode="full"
customizable="true"
context="toolbar-context-menu"
#ifdef XP_MACOSX
iconsize="small"
- defaultset="button-getmsg,button-newmsg,button-address,spacer,button-tag,spring,gloda-search">
+ defaultset="button-getmsg,button-newmsg,button-address,spacer,button-tag,qfb-show-filter-bar,spring,gloda-search">
#else
- defaultset="button-getmsg,button-newmsg,button-address,separator,button-tag,spring,gloda-search">
+ defaultset="button-getmsg,button-newmsg,button-address,separator,button-tag,qfb-show-filter-bar,spring,gloda-search">
#endif
</toolbar>
<toolbarset id="customToolbars" context="toolbar-context-menu"/>
</toolbox>
<!-- The msgNotificationBar appears on top of the message and displays
information like: junk, contains remote images, or is a suspected phishing
--- a/mail/base/content/messenger.xul
+++ b/mail/base/content/messenger.xul
@@ -321,17 +321,17 @@
#tabbar-toolbar below. -->
<hbox id="tabmail-buttons"/>
<toolbar id="tabbar-toolbar" toolboxid="mail-toolbox"
context="toolbar-context-menu"
customizable="true"
mode="icons" defaultmode="icons" lockmode="true"
iconsize="small" defaulticonsize="small" lockiconsize="true"
- defaultset="qfb-show-filter-bar"/>
+ defaultset=""/>
<toolbarbutton class="tabs-alltabs-button"
id="alltabs-button"
type="menu"
tooltiptext="&listAllTabs.label;">
<menupopup class="tabs-alltabs-popup"
id="alltabs-popup" position="after_end"
tabcontainer="tabcontainer"/>
--- a/mail/base/modules/mailMigrator.js
+++ b/mail/base/modules/mailMigrator.js
@@ -128,17 +128,17 @@ var MailMigrator = {
/**
* Determine if the UI has been upgraded in a way that requires us to reset
* some user configuration. If so, performs the resets.
*/
_migrateUI: function MailMigrator__migrateUI() {
// The code for this was ported from
// mozilla/browser/components/nsBrowserGlue.js
- const UI_VERSION = 2;
+ const UI_VERSION = 3;
const MESSENGER_DOCURL = "chrome://messenger/content/messenger.xul#";
const UI_VERSION_PREF = "mail.ui-rdf.version";
let currentUIVersion = 0;
try {
currentUIVersion = Services.prefs.getIntPref(UI_VERSION_PREF);
} catch(ex) {}
@@ -155,18 +155,18 @@ var MailMigrator = {
// However, the inital implementation of migrateUI swallowed up
// exceptions, and bumped the value of UI_VERSION_PREF regardless.
// Now, instead, we fail to bump the UI_VERSION_PREF if something goes
// wrong, and we've moved the folderPaneBox operation into
// currentUIVersion < 2 just in case the operation failed for some of
// our users the first time.
if (currentUIVersion < 2) {
// We want to remove old settings that collapse the folderPaneBox
- let fpbResource = this._rdf.GetResource(MESSENGER_DOCURL +
- "folderPaneBox");
+ let fpbResource = this._rdf.GetResource(MESSENGER_DOCURL
+ + "folderPaneBox");
let collapsedResource = this._rdf.GetResource("collapsed");
let collapsed = this._getPersist(fpbResource, collapsedResource);
if (collapsed !== null) {
// We want to override this, and set it to false. We should really
// be ignoring this persist attribute, anyhow.
dirty = true;
this._unAssert(fpbResource, collapsedResource);
@@ -189,22 +189,62 @@ var MailMigrator = {
currentSet.indexOf("throbber-box") != -1) {
dirty = true;
currentSet = currentSet.replace(/(^|,)throbber-box($|,)/, "$1$2");
this._setPersist(barResource, currentSetResource, currentSet);
}
}
}
+ // In UI version 3, we move the QFB button from the tabbar toolbar to
+ // to the mail toolbar.
+ if (currentUIVersion < 3) {
+ let currentSetResource = this._rdf.GetResource("currentset");
+ let tbtResource = this._rdf.GetResource(MESSENGER_DOCURL
+ + "tabbar-toolbar");
+ if (tbtResource !== null) {
+ let currentSet = this._getPersist(tbtResource, currentSetResource);
+ if (currentSet
+ && currentSet.indexOf("qfb-show-filter-bar") != -1) {
+ dirty = true;
+ currentSet = currentSet.replace(/(^|,)qfb-show-filter-bar($|,)/,
+ "$1$2");
+ this._setPersist(tbtResource, currentSetResource, currentSet);
+ }
+ }
+
+ let barResource = this._rdf.GetResource(MESSENGER_DOCURL + "mail-bar3");
+ if (barResource !== null) {
+ let currentSet = this._getPersist(barResource, currentSetResource);
+
+ if (currentSet
+ && currentSet.indexOf("qfb-show-filter-bar") == -1) {
+
+ dirty = true;
+ if (currentSet.indexOf("gloda-search") != -1) {
+ // Put the QFB toggle before the gloda-search and any of
+ // spring / spacer / separator.
+ currentSet = currentSet.replace(/(^|,)([spring,|spacer,|separator,]*)gloda-search($|,)/,
+ "$1qfb-show-filter-bar,$2gloda-search$3");
+ } else {
+ // If there's no gloda-search, just put the QFB toggle at the end
+ currentSet = currentSet + ",qfb-show-filter-bar";
+ }
+ this._setPersist(barResource, currentSetResource, currentSet);
+ }
+ }
+ }
+
// Update the migration version.
Services.prefs.setIntPref(UI_VERSION_PREF, UI_VERSION);
} catch(e) {
Cu.reportError("Migrating from UI version " + currentUIVersion + " to "
- + UI_VERSION + " failed. Will reattempt on next start.");
+ + UI_VERSION + " failed. Error message was: " + e + " -- "
+ + "Will reattempt on next start.");
} finally {
if (dirty)
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
delete this._rdf;
delete this._dataSource;
}
},
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/migration-to-rdf-ui-3/localstore.rdf
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
+ xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#attachment-view-toolbar"
+ iconsize="small" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#attachment-view-toolbox"
+ mode="full"
+ iconsize="small"
+ labelalign="end" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#header-view-toolbar"
+ iconsize="small"
+ currentset="hdrReplyToSenderButton,hdrSmartReplyButton,hdrForwardButton,hdrArchiveButton,hdrJunkButton,hdrTrashButton,abp-toolbarbutton" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#header-view-toolbox"
+ mode="full"
+ iconsize="small"
+ labelalign="end" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#messengerWindow"
+ width="1024"
+ height="1160"
+ screenX="0"
+ screenY="0"
+ sizemode="normal" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#mail-toolbar-menubar2"
+ mode="full"
+ iconsize="large"
+ currentset="menubar-items,spring,throbber-box" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#tabbar-toolbar"
+ currentset="qfb-show-filter-bar" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#mail-bar3"
+ currentset="button-getmsg,button-newmsg,button-address,separator,button-tag,spring,separator,spring,spacer,gloda-search" />
+
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul">
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#messengerWindow"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#messagepaneboxwrapper"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#header-view-toolbox"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#header-view-toolbar"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#attachment-view-toolbox"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#attachment-view-toolbar"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#abp-hooks"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#folderPaneBox"/>
+ <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#mail-bar3"/>
+ </RDF:Description>
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#folderPaneBox"
+ width="500"
+ collapsed="true" />
+ <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#abp-hooks"
+ currentVersion="2.0.2" />
+</RDF:RDF>
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/migration-to-rdf-ui-3/test-migrate-to-rdf-ui-3.js
@@ -0,0 +1,42 @@
+/* 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/. */
+
+/**
+ * When moving from ui-rdf 0 to 1, we ensure that we've removed the collapsed
+ * property from the folderPaneBox, but that we still persist width.
+ */
+
+let MODULE_NAME = "test-migrate-to-rdf-ui-3";
+let RELATIVE_ROOT = "../shared-modules";
+let MODULE_REQUIRES = ["folder-display-helpers", "migration-helpers"];
+
+let Cc = Components.classes;
+let Ci = Components.interfaces;
+let Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+function setupModule(module) {
+ let fdh = collector.getModule("folder-display-helpers");
+ fdh.installInto(module);
+ let mh = collector.getModule("migration-helpers");
+ mh.installInto(module);
+}
+
+/**
+ * Test that the QFB toggle was moved from the tabbar-toolbar to the
+ * mail-bar3.
+ */
+function test_qfb_button_moved() {
+ let currentSet = mc.e("tabbar-toolbar").currentSet;
+ assert_equals(-1, currentSet.indexOf("qfb-show-filter-bar"),
+ "We found the QFB filter toggle where we shouldn't have.");
+
+ // Now make sure that we've got the QFB filter toggle in the mail bar,
+ // and that it is placed before the gloda-search and any spring, spacer,
+ // or separator items.
+ let currentSet = mc.e("mail-bar3").currentSet;
+ assert_not_equals(-1, currentSet.indexOf("button-tag,qfb-show-filter-bar,spring"),
+ "We didn't find the QFB filter toggle where we should have.");
+}
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/migration-to-rdf-ui-3/wrapper.py
@@ -0,0 +1,16 @@
+# 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/.
+
+import os
+import shutil
+
+def on_profile_created(profiledir):
+ """
+ On profile creation, this copies localstore.rdf from the current folder to
+ the profile_dir.
+ """
+ # The localstore.rdf file is in the same directory this script is in
+ localstore = os.path.join(os.path.dirname(__file__),
+ "localstore.rdf")
+ shutil.copy(localstore, profiledir)
--- a/mail/test/mozmill/migration/test-toolbar.js
+++ b/mail/test/mozmill/migration/test-toolbar.js
@@ -41,31 +41,31 @@
var MODULE_NAME = "test-toolbar";
var RELATIVE_ROOT = "../shared-modules";
var MODULE_REQUIRES = ["folder-display-helpers", "migration-helpers"];
// Use the Windows/Linux settings as the default, but check out setupModule.
var DEFAULT_TB2_SET = "button-getmsg,button-newmsg,button-address,separator,button-reply,button-replyall,button-replylist,button-forward,separator,button-tag,button-delete,button-junk,button-print,separator,button-goback,button-goforward,spring,gloda-search";
-var DEFAULT_TB3_SET = "button-getmsg,button-newmsg,button-address,separator,button-tag,spring,gloda-search"
+var DEFAULT_TB3_SET = "button-getmsg,button-newmsg,button-address,separator,button-tag,qfb-show-filter-bar,spring,gloda-search"
var CUSTOM_TB3_SET = "button-getmsg,button-newmsg,button-address,spacer,button-tag,spring,folder-location-container,gloda-search,throbber-box";
var DEFAULT_TB3_ICONSIZE = "large";
function setupModule(module) {
let fdh = collector.getModule("folder-display-helpers");
fdh.installInto(module);
let mh = collector.getModule("migration-helpers");
mh.installInto(module);
// The Mac has different settings for the toolbar, so adjust for that.
if (Application.platformIsMac) {
DEFAULT_TB2_SET = "button-getmsg,button-newmsg,button-address,spacer,button-reply,button-replyall,button-replylist,button-forward,spacer,button-tag,button-delete,button-junk,button-print,spacer,button-goback,button-goforward,spring,gloda-search,throbber-box";
- DEFAULT_TB3_SET = "button-getmsg,button-newmsg,button-address,spacer,button-tag,spring,gloda-search";
+ DEFAULT_TB3_SET = "button-getmsg,button-newmsg,button-address,spacer,button-tag,qfb-show-filter-bar,spring,gloda-search";
DEFAULT_TB3_ICONSIZE = "small";
}
}
/**
* Assert that the settings correspond to the default TB2 settings.
*
* @param aNewBar the mail-bar3 to check.
--- a/mail/test/mozmill/mozmilltests.list
+++ b/mail/test/mozmill/mozmilltests.list
@@ -11,15 +11,16 @@ folder-tree-modes
folder-widget
instrumentation
junk-commands
message-header
message-window
migration
migration-from-tb2
migration-to-rdf-ui-2
+migration-to-rdf-ui-3
newmailaccount
notification
pref-window
quick-filter-bar
search-window
session-store
tabmail