From d7dd853a82918cf435b0eb422668011154b15f10 Mon Sep 17 00:00:00 2001 From: "Francois (fge)" Date: Tue, 24 Aug 2021 13:20:45 +0000 Subject: [PATCH] [REM] mail: remove "Message a user" command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Message a user" command has been removed because a search with the @ namespace in the command palette does the same thing. closes odoo/odoo#75526 Task-id: 2622240 Signed-off-by: Sébastien Theys (seb) --- addons/mail/__manifest__.py | 1 - .../new_message_service.js | 25 ---- .../tests/new_message_service_tests.js | 117 ------------------ 3 files changed, 143 deletions(-) delete mode 100644 addons/mail/static/src/services/new_message_service/new_message_service.js delete mode 100644 addons/mail/static/src/services/new_message_service/tests/new_message_service_tests.js diff --git a/addons/mail/__manifest__.py b/addons/mail/__manifest__.py index c8a9b4c52ad..fc928e3f2b7 100644 --- a/addons/mail/__manifest__.py +++ b/addons/mail/__manifest__.py @@ -93,7 +93,6 @@ 'mail/static/src/components/*/tests/*.js', 'mail/static/src/model/tests/**/*.js', 'mail/static/src/models/*/tests/*.js', - 'mail/static/src/services/*/tests/*.js', 'mail/static/src/utils/*/tests/*.js', 'mail/static/src/widgets/*/tests/*.js', ], diff --git a/addons/mail/static/src/services/new_message_service/new_message_service.js b/addons/mail/static/src/services/new_message_service/new_message_service.js deleted file mode 100644 index 88c548f702f..00000000000 --- a/addons/mail/static/src/services/new_message_service/new_message_service.js +++ /dev/null @@ -1,25 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; - -export const newMessageService = { - dependencies: ["command"], - start(newEnv, { command }) { - command.add("Message a user", async () => { - const messaging = await owl.Component.env.services.messaging.get(); - if (messaging.discuss.isOpen) { - messaging.discuss.update({ - isAddingChannel: false, - isAddingChat: true, - }); - } else { - messaging.chatWindowManager.openNewMessage(); - } - }, { - category: "mail", - hotkey: "alt+shift+w", - }); - }, -}; - -registry.category("services").add("new_message", newMessageService); diff --git a/addons/mail/static/src/services/new_message_service/tests/new_message_service_tests.js b/addons/mail/static/src/services/new_message_service/tests/new_message_service_tests.js deleted file mode 100644 index bcd8bbf6326..00000000000 --- a/addons/mail/static/src/services/new_message_service/tests/new_message_service_tests.js +++ /dev/null @@ -1,117 +0,0 @@ -/** @odoo-module **/ - -import { newMessageService } from "@mail/services/new_message_service/new_message_service"; -import { afterEach, afterNextRender, beforeEach, start } from '@mail/utils/test_utils'; - -import { click, nextTick, patchWithCleanup, triggerHotkey } from "@web/../tests/helpers/utils"; -import { browser } from '@web/core/browser/browser'; -import { registry } from "@web/core/registry"; -import { commandService } from "@web/webclient/commands/command_service"; - -const serviceRegistry = registry.category("services"); - -QUnit.module('mail', {}, function () { -QUnit.module('services', {}, function () { -QUnit.module('new_message_service', {}, function () { -QUnit.module('new_message_service_tests.js', { - beforeEach() { - serviceRegistry.add("command", commandService); - serviceRegistry.add("new_message", newMessageService); - beforeEach(this); - patchWithCleanup(browser, { - clearTimeout() {}, - setTimeout(later, wait) { - later(); - }, - }); - registry.category("command_categories").add("default", { label: ("default") }); - }, - afterEach() { - afterEach(this); - }, -}, function () { - -QUnit.test('Open "New Message" chat window with a command', async function (assert) { - assert.expect(3); - - const { widget: webClient } = await start({ - data: this.data, - hasChatWindow: true, - hasWebClient: true, - }); - triggerHotkey("control+k"); - await nextTick(); - - const search = webClient.el.querySelector(".o_command_palette_search input"); - search.value = "Message a user"; - search.dispatchEvent(new window.InputEvent("input")); - await nextTick(); - assert.deepEqual( - webClient.el.querySelector(".o_command_palette .o_command.focused").textContent, - "Message a userALT + SHIFT + W", - ); - - await afterNextRender(() => click(document.body, ".o_command.focused")); - assert.containsOnce(document.body, ".o_ChatWindow"); - assert.strictEqual(document.querySelector(".o_ChatWindow .o_ChatWindowHeader_name").textContent, "New message"); - - webClient.destroy(); -}); - -QUnit.test('open "New Message" chat window with a hotkey', async function (assert) { - assert.expect(2); - - const { widget: webClient } = await start({ - data: this.data, - hasChatWindow: true, - hasWebClient: true, - }); - await afterNextRender(() => triggerHotkey("alt+shift+w")); - assert.containsOnce(document.body, ".o_ChatWindow"); - assert.strictEqual(document.querySelector(".o_ChatWindow .o_ChatWindowHeader_name").textContent, "New message"); - - webClient.destroy(); -}); - -QUnit.test('Open "New Message" in discuss with a command', async function (assert) { - assert.expect(1); - - const { widget: webClient } = await start({ - autoOpenDiscuss: true, - data: this.data, - hasDiscuss: true, - hasWebClient: true, - }); - triggerHotkey("control+k"); - await nextTick(); - - const search = webClient.el.querySelector(".o_command_palette_search input"); - search.value = "Message a user"; - search.dispatchEvent(new window.InputEvent("input")); - await nextTick(); - - await afterNextRender(() => click(document.body, ".o_command.focused")); - assert.containsOnce(document.body, ".o_DiscussSidebar_itemNewInput"); - - webClient.destroy(); -}); - -QUnit.test('Open "New Message" in discuss with a hotkey', async function (assert) { - assert.expect(1); - - const { widget: webClient } = await start({ - autoOpenDiscuss: true, - data: this.data, - hasDiscuss: true, - hasWebClient: true, - }); - await afterNextRender(() => triggerHotkey("alt+shift+w")); - assert.containsOnce(document.body, ".o_DiscussSidebar_itemNewInput"); - - webClient.destroy(); -}); - -}); -}); -}); -});