Bug 1866819 - Disable reply, forward, etc. for collapsed threads. r=aleca

Differential Revision: https://phabricator.services.mozilla.com/D194832

--HG--
extra : amend_source : 7dca3730b98589f635192be07c31429c8717f63b
This commit is contained in:
welpy-cw 2023-12-02 11:44:02 +02:00
Родитель 188e806bc2
Коммит 58a6dc5200
3 изменённых файлов: 63 добавлений и 17 удалений

Просмотреть файл

@ -540,10 +540,13 @@ var commandController = {
case "cmd_forwardAttachment":
case "cmd_redirect":
case "cmd_editAsNew":
if (!hasIdentities) {
return false;
}
// Falls through.
return (
hasIdentities &&
(numSelectedMessages == 1 ||
(numSelectedMessages > 1 &&
// Exclude collapsed threads.
numSelectedMessages == gDBView.selection.count))
);
case "cmd_copyMessage":
case "cmd_saveAsFile":
return numSelectedMessages >= 1;

Просмотреть файл

@ -58,9 +58,19 @@ const allThreePane = [
...singleSelectionMessagePane,
...singleSelectionThreadPane,
"multipleMessagesTree",
"collapsedThreadTree",
"multipleDraftsFolderTree",
"multipleTemplatesFolderTree",
];
const noCollapsedThreads = [
...singleSelectionMessagePane,
...singleSelectionThreadPane,
"multipleMessagesTree",
"multipleDraftsFolderTree",
"multipleTemplatesFolderTree",
...onePane,
...external,
];
const notExternal = [...allThreePane, ...onePane];
const singleNotExternal = [
...singleSelectionMessagePane,
@ -97,6 +107,7 @@ const mailContextData = {
...singleSelectionMessagePane,
...singleSelectionThreadPane,
...onePane,
"collapsedThreadTree",
],
"mailContext-openContainingFolder": [
"syntheticFolderDraft",
@ -105,8 +116,8 @@ const mailContextData = {
"syntheticFolderTree",
...onePane,
],
"mailContext-replySender": true,
"mailContext-replyAll": true,
"mailContext-replySender": noCollapsedThreads,
"mailContext-replyAll": noCollapsedThreads,
"mailContext-replyList": ["listFolder", "listFolderTree"],
"mailContext-forward": allSingleSelection,
"mailContext-forwardAsMenu": allSingleSelection,
@ -115,8 +126,8 @@ const mailContextData = {
"multipleDraftsFolderTree",
"multipleTemplatesFolderTree",
],
"mailContext-redirect": true,
"mailContext-editAsNew": true,
"mailContext-redirect": noCollapsedThreads,
"mailContext-editAsNew": noCollapsedThreads,
"mailContext-tags": notExternal,
"mailContext-mark": notExternal,
"mailContext-archive": notExternal,
@ -124,6 +135,7 @@ const mailContextData = {
"mailContext-copyMenu": true,
"mailContext-decryptToFolder": [
"multipleMessagesTree",
"collapsedThreadTree",
"multipleDraftsFolderTree",
"multipleTemplatesFolderTree",
],
@ -136,6 +148,7 @@ const mailContextData = {
"mailContext-print": true,
"mailContext-downloadSelected": [
"multipleMessagesTree",
"collapsedThreadTree",
"multipleDraftsFolderTree",
"multipleTemplatesFolderTree",
],
@ -408,12 +421,12 @@ add_task(async function testSingleMessage() {
});
/**
* Tests the mailContext menu on the thread tree and message pane when more
* than one message is selected.
* Tests the mailContext menu on the thread tree when more than one message is
* selected.
*/
add_task(async function testMultipleMessages() {
await TestUtils.waitForCondition(
() => ConversationOpener.isMessageIndexed(testMessages[1]),
() => ConversationOpener.isMessageIndexed(testMessages[6]),
"waiting for Gloda to finish indexing",
1000
);
@ -441,14 +454,32 @@ add_task(async function testMultipleMessages() {
checkMenuitems(mailContext);
// Open the menu from the thread pane.
let shownPromise = BrowserTestUtils.waitForEvent(mailContext, "popupshown");
EventUtils.synthesizeMouseAtCenter(
threadTree.getRowAtIndex(2),
{ type: "contextmenu" },
about3Pane
);
await shownPromise;
checkMenuitems(mailContext, "multipleMessagesTree");
// Select a collapsed thread and open the menu.
threadTree.scrollToIndex(6, true);
threadTree.selectedIndices = [6];
shownPromise = BrowserTestUtils.waitForEvent(mailContext, "popupshown");
EventUtils.synthesizeMouseAtCenter(
threadTree.getRowAtIndex(6),
{ type: "contextmenu" },
about3Pane
);
await shownPromise;
checkMenuitems(mailContext, "collapsedThreadTree");
// Open the menu in the thread pane on a message scrolled out of view.
threadTree.selectAll();
threadTree.currentIndex = 200;
await TestUtils.waitForTick();
@ -460,7 +491,7 @@ add_task(async function testMultipleMessages() {
"Current row is scrolled out of view"
);
const shownPromise = BrowserTestUtils.waitForEvent(mailContext, "popupshown");
shownPromise = BrowserTestUtils.waitForEvent(mailContext, "popupshown");
EventUtils.synthesizeMouseAtCenter(
threadTree,
{ type: "contextmenu", button: 0 },
@ -633,6 +664,7 @@ add_task(async function testListMessage() {
);
threadTree.selectedIndex = 0;
await loadedPromise;
// Open the menu from the message pane.
Assert.ok(

Просмотреть файл

@ -91,9 +91,11 @@ add_setup(async function () {
testFolder = rootFolder
.getChildNamed("messageMenu")
.QueryInterface(Ci.nsIMsgLocalMailFolder);
testFolder.addMessageBatch(
generator.makeMessages({ count: 5 }).map(message => message.toMboxString())
);
const messages = [
...generator.makeMessages({ count: 5 }),
...generator.makeMessages({ count: 5, msgsPerThread: 5 }),
];
testFolder.addMessageBatch(messages.map(message => message.toMboxString()));
testFolder.addMessage(
generator
.makeMessage({
@ -235,7 +237,7 @@ add_task(async function testSingleSelection() {
});
// This message has an attachment.
tabmail.currentAbout3Pane.threadTree.selectedIndex = 5;
tabmail.currentAbout3Pane.threadTree.selectedIndex = 6;
await BrowserTestUtils.browserLoaded(
tabmail.currentAboutMessage.getMessagePaneBrowser()
);
@ -249,7 +251,7 @@ add_task(async function testSingleSelection() {
});
// This message is from a mailing list.
tabmail.currentAbout3Pane.threadTree.selectedIndex = 6;
tabmail.currentAbout3Pane.threadTree.selectedIndex = 7;
await BrowserTestUtils.browserLoaded(
tabmail.currentAboutMessage.getMessagePaneBrowser()
);
@ -288,6 +290,15 @@ add_task(async function testMultiSelection() {
tagMenu: {},
"tagMenu-tagRemoveAll": {},
});
// Messages in a collapsed thread.
tabmail.currentAbout3Pane.threadTree.selectedIndex = 5;
await helper.testItems({
replyMainMenu: { disabled: true },
menu_replyToAll: { disabled: true },
menu_redirectMsg: { disabled: true },
menu_editMsgAsNew: { disabled: true },
});
});
add_task(async function testDraftsFolder() {