From 344c4c7927dc319a588ddd8a31d21350e2e799b7 Mon Sep 17 00:00:00 2001 From: Alessandro Castellani Date: Thu, 29 Jun 2023 17:19:15 +0000 Subject: [PATCH] Bug 1828499 - Add a sort menu to the threadPaneDisplayButton menu. r=Paenglab Differential Revision: https://phabricator.services.mozilla.com/D180040 --HG-- extra : moz-landing-system : lando --- mail/base/content/about3Pane.js | 55 +++++++++++- mail/base/content/about3Pane.xhtml | 133 ++++++++++++++++++++++++++++- 2 files changed, 186 insertions(+), 2 deletions(-) diff --git a/mail/base/content/about3Pane.js b/mail/base/content/about3Pane.js index 0322ef1fde..5815901bea 100644 --- a/mail/base/content/about3Pane.js +++ b/mail/base/content/about3Pane.js @@ -3887,8 +3887,13 @@ var threadPaneHeader = { /** * Update the context menu to reflect the currently selected display options. + * + * @param {Event} event - The popupshowing DOMEvent. */ - updateDisplayContextMenu() { + updateDisplayContextMenu(event) { + if (event.target.id != "threadPaneDisplayContext") { + return; + } const isTableLayout = document.body.classList.contains("layout-table"); document .getElementById( @@ -3897,6 +3902,54 @@ var threadPaneHeader = { .setAttribute("checked", "true"); }, + /** + * Update the menuitems inside the thread pane sort menupopup. + * + * @param {Event} event - The popupshowing DOMEvent. + */ + updateThreadPaneSortMenu(event) { + if (event.target.id != "menu_threadPaneSortPopup") { + return; + } + + const hiddenColumns = threadPane.columns + .filter(c => c.hidden) + .map(c => c.sortKey); + + // Update menuitem to reflect sort key. + for (const menuitem of event.target.querySelectorAll(`[name="sortby"]`)) { + const sortKey = menuitem.getAttribute("value"); + menuitem.setAttribute( + "checked", + gViewWrapper.primarySortType == Ci.nsMsgViewSortType[sortKey] + ); + if (hiddenColumns.includes(sortKey)) { + menuitem.setAttribute("disabled", "true"); + } else { + menuitem.removeAttribute("disabled"); + } + } + + // Update sort direction menu items. + event.target + .querySelector(`[value="ascending"]`) + .setAttribute("checked", gViewWrapper.isSortedAscending); + event.target + .querySelector(`[value="descending"]`) + .setAttribute("checked", !gViewWrapper.isSortedAscending); + + // Update the threaded and groupedBy menu items. + event.target + .querySelector(`[value="threaded"]`) + .setAttribute("checked", gViewWrapper.showThreaded); + event.target + .querySelector(`[value="unthreaded"]`) + .setAttribute("checked", gViewWrapper.showUnthreaded); + event.target + .querySelector(`[value="group"]`) + .setAttribute("checked", gViewWrapper.showGroupedBySort); + }, + /** * Change the display view of the message list pane. * diff --git a/mail/base/content/about3Pane.xhtml b/mail/base/content/about3Pane.xhtml index c0676bc19b..1c85628163 100644 --- a/mail/base/content/about3Pane.xhtml +++ b/mail/base/content/about3Pane.xhtml @@ -590,7 +590,7 @@ + onpopupshowing="threadPaneHeader.updateDisplayContextMenu(event);"> + + + + + + + + + + + + + + + + + + + + + + + + + + +