From aab6f884393fa33b6e1105103cd8ff7cb4d29c94 Mon Sep 17 00:00:00 2001 From: Bruno Boi Date: Thu, 10 Jun 2021 08:19:42 +0000 Subject: [PATCH] [MOV] web,base_automation: hotkeys from webclient/ to core/ The hotkeys feature is a core feature, not only useful for the webclient. closes odoo-dev/odoo#942 Related: odoo-dev/enterprise#172 Signed-off-by: Aaron Bohy (aab) --- .../static/tests/base_automation_error_dialog.js | 2 +- .../src/{webclient => core}/hotkeys/hotkey.scss | 0 .../src/{webclient => core}/hotkeys/hotkey_service.js | 6 +++--- .../static/src/webclient/commands/command_service.js | 2 +- .../static/tests/core/debug/debug_manager_tests.js | 2 +- addons/web/static/tests/core/dialog_service_tests.js | 2 +- addons/web/static/tests/core/dialog_tests.js | 2 +- addons/web/static/tests/core/dropdown_tests.js | 2 +- .../static/tests/core/errors/error_dialogs_tests.js | 2 +- .../hotkeys/hotkey_service_tests.js | 2 +- addons/web/static/tests/helpers/legacy_env_utils.js | 2 +- .../tests/webclient/commands/command_service_tests.js | 11 ++++------- addons/web/static/tests/webclient/helpers.js | 2 +- addons/web/static/tests/webclient/navbar_tests.js | 2 +- .../tests/webclient/switch_company_menu_tests.js | 2 +- addons/web/static/tests/webclient/user_menu_tests.js | 2 +- addons/web/static/tests/webclient/webclient_tests.js | 2 +- 17 files changed, 21 insertions(+), 24 deletions(-) rename addons/web/static/src/{webclient => core}/hotkeys/hotkey.scss (100%) rename addons/web/static/src/{webclient => core}/hotkeys/hotkey_service.js (98%) rename addons/web/static/tests/{webclient => core}/hotkeys/hotkey_service_tests.js (99%) diff --git a/addons/base_automation/static/tests/base_automation_error_dialog.js b/addons/base_automation/static/tests/base_automation_error_dialog.js index 8258c038d3d..2da00d3eb15 100644 --- a/addons/base_automation/static/tests/base_automation_error_dialog.js +++ b/addons/base_automation/static/tests/base_automation_error_dialog.js @@ -6,7 +6,7 @@ import { errorService } from "@web/core/errors/error_service"; import { dialogService } from "@web/core/dialog/dialog_service"; import { notificationService } from "@web/core/notifications/notification_service"; import { uiService } from "@web/core/ui_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { registerCleanup } from "@web/../tests/helpers/cleanup"; import { makeTestEnv } from "@web/../tests/helpers/mock_env"; import { makeFakeRPCService, makeFakeLocalizationService } from "@web/../tests/helpers/mock_services"; diff --git a/addons/web/static/src/webclient/hotkeys/hotkey.scss b/addons/web/static/src/core/hotkeys/hotkey.scss similarity index 100% rename from addons/web/static/src/webclient/hotkeys/hotkey.scss rename to addons/web/static/src/core/hotkeys/hotkey.scss diff --git a/addons/web/static/src/webclient/hotkeys/hotkey_service.js b/addons/web/static/src/core/hotkeys/hotkey_service.js similarity index 98% rename from addons/web/static/src/webclient/hotkeys/hotkey_service.js rename to addons/web/static/src/core/hotkeys/hotkey_service.js index 3e36338ae83..10a6d89ce90 100644 --- a/addons/web/static/src/webclient/hotkeys/hotkey_service.js +++ b/addons/web/static/src/core/hotkeys/hotkey_service.js @@ -1,8 +1,8 @@ /** @odoo-module **/ -import { isMacOS } from "../../core/browser/feature_detection"; -import { registry } from "../../core/registry"; -import { browser } from "../../core/browser/browser"; +import { isMacOS } from "../browser/feature_detection"; +import { registry } from "../registry"; +import { browser } from "../browser/browser"; export function getHotkeyToPress(hotkey, altIsOptional = false) { let result = hotkey.split("+"); diff --git a/addons/web/static/src/webclient/commands/command_service.js b/addons/web/static/src/webclient/commands/command_service.js index 465205cdcd0..19b906ec6c9 100644 --- a/addons/web/static/src/webclient/commands/command_service.js +++ b/addons/web/static/src/webclient/commands/command_service.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { registry } from "../../core/registry"; -import { getHotkeyToPress } from "../hotkeys/hotkey_service"; +import { getHotkeyToPress } from "../../core/hotkeys/hotkey_service"; import { CommandPaletteDialog } from "./command_palette_dialog"; /** diff --git a/addons/web/static/tests/core/debug/debug_manager_tests.js b/addons/web/static/tests/core/debug/debug_manager_tests.js index a2537519f7b..a718d83d3eb 100644 --- a/addons/web/static/tests/core/debug/debug_manager_tests.js +++ b/addons/web/static/tests/core/debug/debug_manager_tests.js @@ -8,7 +8,7 @@ import { debugService } from "@web/core/debug/debug_service"; import { ormService } from "@web/core/orm_service"; import { uiService } from "@web/core/ui_service"; import { ActionDialog } from "@web/webclient/actions/action_dialog"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { registerCleanup } from "../../helpers/cleanup"; import { makeTestEnv, prepareRegistriesWithCleanup } from "../../helpers/mock_env"; import { makeFakeDialogService, makeFakeLocalizationService } from "../../helpers/mock_services"; diff --git a/addons/web/static/tests/core/dialog_service_tests.js b/addons/web/static/tests/core/dialog_service_tests.js index 431c5955aca..7a5d60d84b2 100644 --- a/addons/web/static/tests/core/dialog_service_tests.js +++ b/addons/web/static/tests/core/dialog_service_tests.js @@ -7,7 +7,7 @@ import { errorService } from "@web/core/errors/error_service"; import { registry } from "@web/core/registry"; import { notificationService } from "@web/core/notifications/notification_service"; import { uiService } from "@web/core/ui_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { registerCleanup } from "../helpers/cleanup"; import { clearRegistryWithCleanup, makeTestEnv } from "../helpers/mock_env"; import { makeFakeLocalizationService, makeFakeRPCService } from "../helpers/mock_services"; diff --git a/addons/web/static/tests/core/dialog_tests.js b/addons/web/static/tests/core/dialog_tests.js index 53a89f14b97..c7177247101 100644 --- a/addons/web/static/tests/core/dialog_tests.js +++ b/addons/web/static/tests/core/dialog_tests.js @@ -3,7 +3,7 @@ import { registry } from "@web/core/registry"; import { useService } from "@web/core/service_hook"; import { uiService } from "@web/core/ui_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { Dialog } from "@web/core/dialog/dialog"; import { makeTestEnv } from "../helpers/mock_env"; import { click, getFixture, nextTick } from "../helpers/utils"; diff --git a/addons/web/static/tests/core/dropdown_tests.js b/addons/web/static/tests/core/dropdown_tests.js index 0996c049d44..3e77b16b502 100644 --- a/addons/web/static/tests/core/dropdown_tests.js +++ b/addons/web/static/tests/core/dropdown_tests.js @@ -2,7 +2,7 @@ import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { makeTestEnv } from "../helpers/mock_env"; import { click, getFixture, makeDeferred, nextTick, triggerHotkey } from "../helpers/utils"; diff --git a/addons/web/static/tests/core/errors/error_dialogs_tests.js b/addons/web/static/tests/core/errors/error_dialogs_tests.js index f677fe0502a..1c2fadcf571 100644 --- a/addons/web/static/tests/core/errors/error_dialogs_tests.js +++ b/addons/web/static/tests/core/errors/error_dialogs_tests.js @@ -11,7 +11,7 @@ import { } from "@web/core/errors/error_dialogs"; import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { makeTestEnv } from "../../helpers/mock_env"; import { makeFakeDialogService, makeFakeLocalizationService } from "../../helpers/mock_services"; import { click, getFixture, nextTick, patchWithCleanup } from "../../helpers/utils"; diff --git a/addons/web/static/tests/webclient/hotkeys/hotkey_service_tests.js b/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js similarity index 99% rename from addons/web/static/tests/webclient/hotkeys/hotkey_service_tests.js rename to addons/web/static/tests/core/hotkeys/hotkey_service_tests.js index 9fdb94b51fc..442e0c83d79 100644 --- a/addons/web/static/tests/webclient/hotkeys/hotkey_service_tests.js +++ b/addons/web/static/tests/core/hotkeys/hotkey_service_tests.js @@ -4,7 +4,7 @@ import { browser } from "@web/core/browser/browser"; import { useHotkey } from "@web/core/hotkey_hook"; import { registry } from "@web/core/registry"; import { uiService, useActiveElement } from "@web/core/ui_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { makeTestEnv } from "../../helpers/mock_env"; import { getFixture, nextTick, patchWithCleanup, triggerHotkey } from "../../helpers/utils"; diff --git a/addons/web/static/tests/helpers/legacy_env_utils.js b/addons/web/static/tests/helpers/legacy_env_utils.js index 9495bc58a51..eb21fe00f7b 100644 --- a/addons/web/static/tests/helpers/legacy_env_utils.js +++ b/addons/web/static/tests/helpers/legacy_env_utils.js @@ -4,7 +4,7 @@ import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; import { patch, unpatch } from "@web/core/utils/patch"; import { makeLegacyDialogMappingService } from "@web/legacy/utils"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import core from "web.core"; import makeTestEnvironment from "web.test_env"; import { registerCleanup } from "./cleanup"; diff --git a/addons/web/static/tests/webclient/commands/command_service_tests.js b/addons/web/static/tests/webclient/commands/command_service_tests.js index ffd756fd185..3b6b794464c 100644 --- a/addons/web/static/tests/webclient/commands/command_service_tests.js +++ b/addons/web/static/tests/webclient/commands/command_service_tests.js @@ -5,7 +5,7 @@ import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; import { useCommand } from "@web/webclient/commands/command_hook"; import { commandService } from "@web/webclient/commands/command_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { makeTestEnv } from "../../helpers/mock_env"; import { click, getFixture, nextTick, triggerHotkey } from "../../helpers/utils"; @@ -90,12 +90,9 @@ QUnit.test("useCommand hook", async (assert) => { class MyComponent extends TestComponent { setup() { super.setup(); - useCommand( - "Take the throne", - () => { - assert.step("Hodor"); - }, - ); + useCommand("Take the throne", () => { + assert.step("Hodor"); + }); } } testComponent = await mount(MyComponent, { env, target }); diff --git a/addons/web/static/tests/webclient/helpers.js b/addons/web/static/tests/webclient/helpers.js index 13895c74281..efebae3b676 100644 --- a/addons/web/static/tests/webclient/helpers.js +++ b/addons/web/static/tests/webclient/helpers.js @@ -15,7 +15,7 @@ import { import { viewService } from "@web/views/view_service"; import { actionService } from "@web/webclient/actions/action_service"; import { effectService } from "@web/webclient/effects/effect_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { menuService } from "@web/webclient/menu_service"; import { WebClient } from "@web/webclient/webclient"; // This import is needed because of it's sideeffects, for exemple : diff --git a/addons/web/static/tests/webclient/navbar_tests.js b/addons/web/static/tests/webclient/navbar_tests.js index 7176376bc7e..be0774b4989 100644 --- a/addons/web/static/tests/webclient/navbar_tests.js +++ b/addons/web/static/tests/webclient/navbar_tests.js @@ -6,7 +6,7 @@ import { menuService } from "@web/webclient/menu_service"; import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; import { actionService } from "@web/webclient/actions/action_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { NavBar } from "@web/webclient/navbar/navbar"; import { clearRegistryWithCleanup, makeTestEnv } from "../helpers/mock_env"; import { click, getFixture, nextTick, patchWithCleanup } from "../helpers/utils"; diff --git a/addons/web/static/tests/webclient/switch_company_menu_tests.js b/addons/web/static/tests/webclient/switch_company_menu_tests.js index f390d9c0894..a91c1be851a 100644 --- a/addons/web/static/tests/webclient/switch_company_menu_tests.js +++ b/addons/web/static/tests/webclient/switch_company_menu_tests.js @@ -2,7 +2,7 @@ import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { SwitchCompanyMenu } from "@web/webclient/switch_company_menu/switch_company_menu"; import { registerCleanup } from "../helpers/cleanup"; import { makeTestEnv } from "../helpers/mock_env"; diff --git a/addons/web/static/tests/webclient/user_menu_tests.js b/addons/web/static/tests/webclient/user_menu_tests.js index a78b09ff277..32693d04795 100644 --- a/addons/web/static/tests/webclient/user_menu_tests.js +++ b/addons/web/static/tests/webclient/user_menu_tests.js @@ -5,7 +5,7 @@ import { ormService } from "@web/core/orm_service"; import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; import { patch, unpatch } from "@web/core/utils/patch"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { UserMenu } from "@web/webclient/user_menu/user_menu"; import { preferencesItem } from "@web/webclient/user_menu/user_menu_items"; import { userService } from "@web/core/user_service"; diff --git a/addons/web/static/tests/webclient/webclient_tests.js b/addons/web/static/tests/webclient/webclient_tests.js index 346757fd7c1..7d2e288cf05 100644 --- a/addons/web/static/tests/webclient/webclient_tests.js +++ b/addons/web/static/tests/webclient/webclient_tests.js @@ -7,7 +7,7 @@ import { registry } from "@web/core/registry"; import { uiService } from "@web/core/ui_service"; import { legacyServiceProvider } from "@web/legacy/legacy_service_provider"; import { actionService } from "@web/webclient/actions/action_service"; -import { hotkeyService } from "@web/webclient/hotkeys/hotkey_service"; +import { hotkeyService } from "@web/core/hotkeys/hotkey_service"; import { menuService } from "@web/webclient/menu_service"; import { WebClient } from "@web/webclient/webclient"; import { clearRegistryWithCleanup, makeTestEnv } from "../helpers/mock_env";