From 1b549bddd13ef7d51b6bddf07d43befa8a2278b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 3 Jun 2021 08:12:47 +0000 Subject: [PATCH] [REF] web: improve main_component registry API to accept props closes odoo-dev/odoo#910 Signed-off-by: Aaron Bohy (aab) --- addons/bus/static/tests/assets_watchdog_tests.js | 4 +++- .../static/tests/calendar_notification_tests.js | 4 +++- addons/point_of_sale/static/src/js/main.js | 4 ++-- .../static/src/core/dialog/dialog_container.js | 4 +++- .../core/notifications/notification_container.js | 4 +++- .../static/src/core/popover/popover_service.js | 4 +++- .../static/src/webclient/block_ui/block_ui.js | 2 +- .../src/webclient/effects/effect_container.js | 4 +++- .../loading_indicator/loading_indicator.js | 4 +++- addons/web/static/src/webclient/webclient.xml | 4 ++-- .../static/tests/core/dialog_service_tests.js | 8 +++++--- .../tests/core/popover/popover_service_tests.js | 8 +++++--- .../webclient/actions/client_action_tests.js | 8 ++++++-- .../tests/webclient/actions/effects_tests.js | 16 ++++++++++++---- .../tests/webclient/actions/legacy_tests.js | 8 ++++++-- .../webclient/actions/report_action_tests.js | 4 +++- .../webclient/actions/window_action_tests.js | 4 +++- .../webclient/commands/command_service_tests.js | 2 +- .../static/tests/webclient/webclient_tests.js | 2 +- 19 files changed, 68 insertions(+), 30 deletions(-) diff --git a/addons/bus/static/tests/assets_watchdog_tests.js b/addons/bus/static/tests/assets_watchdog_tests.js index 175a069176e..73ea72c3f3a 100644 --- a/addons/bus/static/tests/assets_watchdog_tests.js +++ b/addons/bus/static/tests/assets_watchdog_tests.js @@ -34,7 +34,9 @@ QUnit.module("Bus Assets WatchDog", (hooks) => { serviceRegistry.add("assetsWatchdog", assetsWatchdogService); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("NotificationContainer", NotificationContainer); + mainComponentRegistry.add("NotificationContainer", { + Component: NotificationContainer + }); patchWithCleanup(browser, { setTimeout: (fn) => fn(), clearTimeout: () => {}, diff --git a/addons/calendar/static/tests/calendar_notification_tests.js b/addons/calendar/static/tests/calendar_notification_tests.js index 9ac4238b81c..28d682da446 100644 --- a/addons/calendar/static/tests/calendar_notification_tests.js +++ b/addons/calendar/static/tests/calendar_notification_tests.js @@ -34,7 +34,9 @@ QUnit.module("Calendar Notification", (hooks) => { serviceRegistry.add("calendarNotification", calendarNotificationService); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("NotificationContainer", NotificationContainer); + mainComponentRegistry.add("NotificationContainer", { + Component: NotificationContainer + }); patchWithCleanup(browser, { setTimeout: (fn) => fn(), diff --git a/addons/point_of_sale/static/src/js/main.js b/addons/point_of_sale/static/src/js/main.js index a851c9379c2..633b3e7a40b 100644 --- a/addons/point_of_sale/static/src/js/main.js +++ b/addons/point_of_sale/static/src/js/main.js @@ -17,8 +17,8 @@ PosApp.template = owl.tags.xml`
- - + +
diff --git a/addons/web/static/src/core/dialog/dialog_container.js b/addons/web/static/src/core/dialog/dialog_container.js index 87895912317..5c1681af7b7 100644 --- a/addons/web/static/src/core/dialog/dialog_container.js +++ b/addons/web/static/src/core/dialog/dialog_container.js @@ -57,4 +57,6 @@ DialogContainer.template = tags.xml` `; -registry.category("main_components").add("DialogContainer", DialogContainer); +registry.category("main_components").add("DialogContainer", { + Component: DialogContainer, +}); diff --git a/addons/web/static/src/core/notifications/notification_container.js b/addons/web/static/src/core/notifications/notification_container.js index 87882c5d1c3..f732252a274 100644 --- a/addons/web/static/src/core/notifications/notification_container.js +++ b/addons/web/static/src/core/notifications/notification_container.js @@ -25,4 +25,6 @@ NotificationContainer.template = tags.xml` `; NotificationContainer.components = { NotificationComponent }; -registry.category("main_components").add("NotificationContainer", NotificationContainer); +registry.category("main_components").add("NotificationContainer", { + Component: NotificationContainer, +}); diff --git a/addons/web/static/src/core/popover/popover_service.js b/addons/web/static/src/core/popover/popover_service.js index b6b017c5b0a..ebc65eb74b4 100644 --- a/addons/web/static/src/core/popover/popover_service.js +++ b/addons/web/static/src/core/popover/popover_service.js @@ -92,7 +92,9 @@ PopoverManager.template = xml` `; -registry.category("main_components").add("PopoverManager", PopoverManager); +registry.category("main_components").add("PopoverManager", { + Component: PopoverManager, +}); export const popoverService = { start() { diff --git a/addons/web/static/src/webclient/block_ui/block_ui.js b/addons/web/static/src/webclient/block_ui/block_ui.js index 8dd590ebe9f..19caca1d501 100644 --- a/addons/web/static/src/webclient/block_ui/block_ui.js +++ b/addons/web/static/src/webclient/block_ui/block_ui.js @@ -86,4 +86,4 @@ BlockUI.template = tags.xml` `; -registry.category("main_components").add("BlockUI", BlockUI); +registry.category("main_components").add("BlockUI", { Component: BlockUI }); diff --git a/addons/web/static/src/webclient/effects/effect_container.js b/addons/web/static/src/webclient/effects/effect_container.js index 66c92b016e6..7d377a6c372 100644 --- a/addons/web/static/src/webclient/effects/effect_container.js +++ b/addons/web/static/src/webclient/effects/effect_container.js @@ -27,4 +27,6 @@ EffectContainer.template = tags.xml` `; EffectContainer.components = { RainbowMan }; -registry.category("main_components").add("EffectContainer", EffectContainer); +registry.category("main_components").add("EffectContainer", { + Component: EffectContainer, +}); diff --git a/addons/web/static/src/webclient/loading_indicator/loading_indicator.js b/addons/web/static/src/webclient/loading_indicator/loading_indicator.js index f843b81e74a..ce4dea56bfb 100644 --- a/addons/web/static/src/webclient/loading_indicator/loading_indicator.js +++ b/addons/web/static/src/webclient/loading_indicator/loading_indicator.js @@ -50,4 +50,6 @@ export class LoadingIndicator extends Component { LoadingIndicator.template = "web.LoadingIndicator"; -registry.category("main_components").add("LoadingIndicator", LoadingIndicator); +registry.category("main_components").add("LoadingIndicator", { + Component: LoadingIndicator, +}); diff --git a/addons/web/static/src/webclient/webclient.xml b/addons/web/static/src/webclient/webclient.xml index e021ab8d461..a5b3d0a838b 100644 --- a/addons/web/static/src/webclient/webclient.xml +++ b/addons/web/static/src/webclient/webclient.xml @@ -7,8 +7,8 @@
- - + +
diff --git a/addons/web/static/tests/core/dialog_service_tests.js b/addons/web/static/tests/core/dialog_service_tests.js index 4ccdf514036..c067ee7d319 100644 --- a/addons/web/static/tests/core/dialog_service_tests.js +++ b/addons/web/static/tests/core/dialog_service_tests.js @@ -31,8 +31,8 @@ PseudoWebClient.template = tags.xml`
- - + +
@@ -45,7 +45,9 @@ QUnit.module("DialogManager", { serviceRegistry.add("ui", uiService); serviceRegistry.add("hotkey", hotkeyService); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("DialogContainer", DialogContainer); + mainComponentRegistry.add("DialogContainer", { + Component: DialogContainer, + }); env = await makeTestEnv(); }, afterEach() { diff --git a/addons/web/static/tests/core/popover/popover_service_tests.js b/addons/web/static/tests/core/popover/popover_service_tests.js index e3256f5e63a..2da54aea6a9 100644 --- a/addons/web/static/tests/core/popover/popover_service_tests.js +++ b/addons/web/static/tests/core/popover/popover_service_tests.js @@ -32,8 +32,8 @@ PseudoWebClient.template = xml`
Anchor
Close
- - + +
@@ -43,7 +43,9 @@ QUnit.module("PopoverManager", { async beforeEach() { serviceRegistry.add("popover", popoverService); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("PopoverManager", PopoverManager); + mainComponentRegistry.add("PopoverManager", { + Component: PopoverManager, + }); env = await makeTestEnv(); pseudoWebClient = await mount(PseudoWebClient, { env, diff --git a/addons/web/static/tests/webclient/actions/client_action_tests.js b/addons/web/static/tests/webclient/actions/client_action_tests.js index 81a37b9e0cd..18b769f1820 100644 --- a/addons/web/static/tests/webclient/actions/client_action_tests.js +++ b/addons/web/static/tests/webclient/actions/client_action_tests.js @@ -334,7 +334,9 @@ QUnit.module("ActionManager", (hooks) => { QUnit.test("test display_notification client action", async function (assert) { assert.expect(6); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("NotificationContainer", NotificationContainer); + mainComponentRegistry.add("NotificationContainer", { + Component: NotificationContainer, + }); const webClient = await createWebClient({ testConfig }); await doAction(webClient, 1); assert.containsOnce(webClient, ".o_kanban_view"); @@ -375,7 +377,9 @@ QUnit.module("ActionManager", (hooks) => { QUnit.test("test next action on display_notification client action", async function (assert) { clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("NotificationContainer", NotificationContainer); + mainComponentRegistry.add("NotificationContainer", { + Component: NotificationContainer, + }); const webClient = await createWebClient({ testConfig }); const options = { onClose: function (infos) { diff --git a/addons/web/static/tests/webclient/actions/effects_tests.js b/addons/web/static/tests/webclient/actions/effects_tests.js index b5bf333f23e..db57d5e4196 100644 --- a/addons/web/static/tests/webclient/actions/effects_tests.js +++ b/addons/web/static/tests/webclient/actions/effects_tests.js @@ -27,7 +27,9 @@ QUnit.module("ActionManager", (hooks) => { force: true, }); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("EffectContainer", EffectContainer); + mainComponentRegistry.add("EffectContainer", { + Component: EffectContainer, + }); const webClient = await createWebClient({ testConfig }); await doAction(webClient, 1); assert.containsOnce(webClient.el, ".o_kanban_view"); @@ -56,7 +58,9 @@ QUnit.module("ActionManager", (hooks) => { QUnit.test("show effect notification instead of rainbow man", async function (assert) { assert.expect(6); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("NotificationContainer", NotificationContainer); + mainComponentRegistry.add("NotificationContainer", { + Component: NotificationContainer, + }); const webClient = await createWebClient({ testConfig }); await doAction(webClient, 1); @@ -88,7 +92,9 @@ QUnit.module("ActionManager", (hooks) => { } }; clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("EffectContainer", EffectContainer); + mainComponentRegistry.add("EffectContainer", { + Component: EffectContainer, + }); const webClient = await createWebClient({ testConfig, mockRPC }); await doAction(webClient, 6); await click(webClient.el.querySelector('button[name="object"]')); @@ -115,7 +121,9 @@ QUnit.module("ActionManager", (hooks) => { } }; clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("EffectContainer", EffectContainer); + mainComponentRegistry.add("EffectContainer", { + Component: EffectContainer, + }); const webClient = await createWebClient({ testConfig, mockRPC }); await doAction(webClient, 6); diff --git a/addons/web/static/tests/webclient/actions/legacy_tests.js b/addons/web/static/tests/webclient/actions/legacy_tests.js index 5482360410c..263adbcb300 100644 --- a/addons/web/static/tests/webclient/actions/legacy_tests.js +++ b/addons/web/static/tests/webclient/actions/legacy_tests.js @@ -40,7 +40,9 @@ QUnit.module("ActionManager", (hooks) => { }); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("NotificationContainer", NotificationContainer); + mainComponentRegistry.add("NotificationContainer", { + Component: NotificationContainer, + }); const webClient = await createWebClient({ testConfig }); await doAction(webClient, 3); assert.containsOnce(webClient, ".o_list_view"); @@ -67,7 +69,9 @@ QUnit.module("ActionManager", (hooks) => { }, }); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("DialogContainer", DialogContainer); + mainComponentRegistry.add("DialogContainer", { + Component: DialogContainer, + }); const webClient = await createWebClient({ testConfig }); await doAction(webClient, 3); diff --git a/addons/web/static/tests/webclient/actions/report_action_tests.js b/addons/web/static/tests/webclient/actions/report_action_tests.js index 892f48eec3a..877c2049255 100644 --- a/addons/web/static/tests/webclient/actions/report_action_tests.js +++ b/addons/web/static/tests/webclient/actions/report_action_tests.js @@ -19,7 +19,9 @@ QUnit.module("ActionManager", (hooks) => { hooks.beforeEach(() => { testConfig = getActionManagerTestConfig(); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("DialogContainer", DialogContainer); + mainComponentRegistry.add("DialogContainer", { + Component: DialogContainer, + }); }); QUnit.module("Report actions"); diff --git a/addons/web/static/tests/webclient/actions/window_action_tests.js b/addons/web/static/tests/webclient/actions/window_action_tests.js index ea77bd72e16..79af2bb1fdb 100644 --- a/addons/web/static/tests/webclient/actions/window_action_tests.js +++ b/addons/web/static/tests/webclient/actions/window_action_tests.js @@ -2132,7 +2132,9 @@ QUnit.module("ActionManager", (hooks) => { const mainComponentRegistry = registry.category("main_components"); clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("DialogContainer", DialogContainer); + mainComponentRegistry.add("DialogContainer", { + Component: DialogContainer, + }); testConfig.serverData.views["partner,false,form"] = `
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 50287a60019..5caf05f82cd 100644 --- a/addons/web/static/tests/webclient/commands/command_service_tests.js +++ b/addons/web/static/tests/webclient/commands/command_service_tests.js @@ -20,7 +20,7 @@ const commandCategoryRegistry = registry.category("command_categories"); class TestComponent extends Component {} TestComponent.components = { - DialogContainer: registry.category("main_components").get("DialogContainer"), + DialogContainer: registry.category("main_components").get("DialogContainer").Component, }; TestComponent.template = xml`
diff --git a/addons/web/static/tests/webclient/webclient_tests.js b/addons/web/static/tests/webclient/webclient_tests.js index 320eaab622f..bb20f8671dd 100644 --- a/addons/web/static/tests/webclient/webclient_tests.js +++ b/addons/web/static/tests/webclient/webclient_tests.js @@ -50,7 +50,7 @@ QUnit.test("can render a main component", async (assert) => { class MyComponent extends Component {} MyComponent.template = xml`MyComponent`; clearRegistryWithCleanup(mainComponentRegistry); - mainComponentRegistry.add("mycomponent", MyComponent); + mainComponentRegistry.add("mycomponent", { Component: MyComponent }); const env = await makeTestEnv(baseConfig); const target = getFixture(); const webClient = await mount(WebClient, { env, target });