From 4500a72c1cf3b7a1bf5a04ee4772df25c4e8efab Mon Sep 17 00:00:00 2001 From: "Francois (fge)" Date: Tue, 17 Aug 2021 09:48:53 +0000 Subject: [PATCH] [IMP] mail: add empty message (@ and #) closes odoo/odoo#74933 Task-id: 2622240 Signed-off-by: Lucas Perais (lpe) --- .../static/src/webclient/commands/command_category.js | 2 +- .../static/src/webclient/commands/mail_providers.js | 10 +++++++--- .../tests/webclient/commands/mail_providers_tests.js | 11 +++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/addons/mail/static/src/webclient/commands/command_category.js b/addons/mail/static/src/webclient/commands/command_category.js index 61dcf48c4df..82b81dd4cc9 100644 --- a/addons/mail/static/src/webclient/commands/command_category.js +++ b/addons/mail/static/src/webclient/commands/command_category.js @@ -4,4 +4,4 @@ import { registry } from "@web/core/registry"; import { _lt } from "@web/core/l10n/translation"; const commandCategoryRegistry = registry.category("command_categories"); -commandCategoryRegistry.add("mail", { label: _lt("Discuss") }, { sequence: 20 }); +commandCategoryRegistry.add("mail", {}, { sequence: 20 }); diff --git a/addons/mail/static/src/webclient/commands/mail_providers.js b/addons/mail/static/src/webclient/commands/mail_providers.js index c81aa8b9fd7..74d4aeae750 100644 --- a/addons/mail/static/src/webclient/commands/mail_providers.js +++ b/addons/mail/static/src/webclient/commands/mail_providers.js @@ -1,5 +1,6 @@ /** @odoo-module */ +import { _lt } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; const { Component } = owl; @@ -13,10 +14,13 @@ DialogCommand.template = xml` `; -const commandProviderRegistry = registry.category("command_provider"); +const commandEmptyMessageRegistry = registry.category("command_empty_list"); +commandEmptyMessageRegistry.add("@", _lt("No user found")); +commandEmptyMessageRegistry.add("#", _lt("No channel found")); +const commandProviderRegistry = registry.category("command_provider"); commandProviderRegistry.add("partner", { - nameSpace: "@", + namespace: "@", async provide(newEnv, options) { const messaging = await Component.env.services.messaging.get(); const suggestions = []; @@ -43,7 +47,7 @@ commandProviderRegistry.add("partner", { }); commandProviderRegistry.add("channel", { - nameSpace: "#", + namespace: "#", async provide(newEnv, options) { const messaging = await Component.env.services.messaging.get(); const channels = await messaging.models['mail.thread'].searchChannelsToOpen({ diff --git a/addons/mail/static/tests/webclient/commands/mail_providers_tests.js b/addons/mail/static/tests/webclient/commands/mail_providers_tests.js index da97c8748ea..31a463f262b 100644 --- a/addons/mail/static/tests/webclient/commands/mail_providers_tests.js +++ b/addons/mail/static/tests/webclient/commands/mail_providers_tests.js @@ -2,6 +2,7 @@ import { afterEach, afterNextRender, beforeEach, start } from '@mail/utils/test_utils'; import { click, nextTick, patchWithCleanup, triggerHotkey } from "@web/../tests/helpers/utils"; +import { editSearchBar } from '@web/../tests/webclient/commands/command_service_tests'; import { browser } from '@web/core/browser/browser'; import { registry } from "@web/core/registry"; import { commandService } from "@web/webclient/commands/command_service"; @@ -49,10 +50,7 @@ QUnit.module('mail', {}, function () { await nextTick(); // Switch to partners - const search = webClient.el.querySelector(".o_command_palette_search input"); - search.value = "@"; - search.dispatchEvent(new InputEvent("input")); - await nextTick(); + await editSearchBar("@"); assert.deepEqual( [...webClient.el.querySelectorAll(".o_command_palette .o_command")].map((el) => el.textContent), [ @@ -91,10 +89,7 @@ QUnit.module('mail', {}, function () { await nextTick(); // Switch to channels - const search = webClient.el.querySelector(".o_command_palette_search input"); - search.value = "#"; - search.dispatchEvent(new InputEvent("input")); - await nextTick(); + await editSearchBar("#"); assert.deepEqual( [...webClient.el.querySelectorAll(".o_command_palette .o_command")].map((el) => el.textContent), [