From 6eea43a7065618332eeaed2f501b634c4d1e8102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Dieudonn=C3=A9?= Date: Mon, 20 Nov 2023 09:55:47 +0100 Subject: [PATCH] [REV] web: blockui when executing a target=self act_url action Follow-up of https://github.com/odoo/odoo/pull/134277 This reverts commit 91b80fbb5c0787411e91470e98d23aee323e34b4 as it adds some unwanted visual effect. In other words, the "block UI" is never unblocked when some actions are triggered. this is specific to the mobile app when the URL is outside of the webview scope ("/web" or "/pos"). Even if the target is self, the mobile app forces a new tab because opening something else that the backend in the webview could disturb users. Steps to reproduce: - Open "Field Service" - Choose a task and start it - Stop it and confirm time spent - Sign report => A new tab is openened in the mobile app and the block UI is never unblock in the app. To fix this, we simply decided to avoid to use the block UI for act_url actions. this is consistent with what we did previously: See https://github.com/odoo/odoo/commit/ebe64aafacec8eaa69a5a1781fc159ff77bc884a We will only use `BlockUI` when really necessary and not by default. Note that this commit will also remove the block UI when you do some operations on apps like installing it. For now, we consider that is OK. This means that the user will be able to continue his work during installation. Also note that if the user navigates to another application during the process, the page will not be refreshed at the end. He will have to do it himself by pressing "F5" to be able to see the app in the home menu. In the future, the idea should be to better notify the user at the end of this king of background operations but we will see... closes odoo/odoo#142656 Signed-off-by: Romain Estievenart (res) --- .../src/webclient/actions/action_service.js | 14 +---------- .../webclient/actions/url_action_tests.js | 24 ------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 31c3a57baab..1417e31d078 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -870,20 +870,8 @@ function makeActionManager(env) { if (url && !(url.startsWith("http") || url.startsWith("/"))) { url = "/" + url; } - if (action.target === "download") { + if (action.target === "download" || action.target === "self") { browser.location.assign(url); - } else if (action.target === "self") { - let willUnload = false; - const onUnload = () => { - willUnload = true; - }; - browser.addEventListener("beforeunload", onUnload); - env.services.ui.block(); - browser.location.assign(url); - browser.removeEventListener("beforeunload", onUnload); - if (!willUnload) { - env.services.ui.unblock(); - } } else { const w = browser.open(url, "_blank"); if (!w || w.closed || typeof w.closed === "undefined") { diff --git a/addons/web/static/tests/webclient/actions/url_action_tests.js b/addons/web/static/tests/webclient/actions/url_action_tests.js index e79149da88b..36b00cff26c 100644 --- a/addons/web/static/tests/webclient/actions/url_action_tests.js +++ b/addons/web/static/tests/webclient/actions/url_action_tests.js @@ -1,6 +1,5 @@ /** @odoo-module **/ -import { registry } from "@web/core/registry"; import { makeTestEnv } from "../../helpers/mock_env"; import { setupWebClientRegistries, doAction, getActionManagerServerData } from "./../helpers"; import { getFixture, patchWithCleanup } from "@web/../tests/helpers/utils"; @@ -8,7 +7,6 @@ import { browser } from "@web/core/browser/browser"; let target; let serverData; -const serviceRegistry = registry.category("services"); QUnit.module("ActionManager", (hooks) => { hooks.beforeEach(() => { @@ -34,28 +32,6 @@ QUnit.module("ActionManager", (hooks) => { assert.verifySteps(["/my/test/url"]); }); - QUnit.test("an 'ir.actions.act_url' with target 'self' blocks the ui", async (assert) => { - serviceRegistry.add("ui", { - start() { - return { - block: () => assert.step("block"), - // we can't simulate a page unload in the tests, so in this scenario the - // ui will be unblocked directly (and we thus need to define the unblock - // function) - unblock: () => {}, - }; - }, - }); - setupWebClientRegistries(); - const env = await makeTestEnv({ serverData }); - await doAction(env, { - type: "ir.actions.act_url", - target: "self", - url: "/my/test/url", - }); - assert.verifySteps(["block"]); - }); - QUnit.test("execute an 'ir.actions.act_url' action with onClose option", async (assert) => { setupWebClientRegistries(); patchWithCleanup(browser, {