diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index c23f3ba1947..0ecd9765bf7 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -203,9 +203,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/env.js', 'web/static/src/core/utils/transitions.scss', # included early because used by other files 'web/static/src/core/**/*', - # TODO: split debug files correctly when converting frontend debug - # manager so we don't need action-service and stuff - ('remove', 'web/static/src/core/debug/**/*'), 'web/static/src/public/error_notifications.js', 'web/static/src/legacy/scss/base_frontend.scss', diff --git a/addons/web/static/src/core/debug/debug_context.js b/addons/web/static/src/core/debug/debug_context.js index d1c102cc46c..a77ba98ac2a 100644 --- a/addons/web/static/src/core/debug/debug_context.js +++ b/addons/web/static/src/core/debug/debug_context.js @@ -61,8 +61,12 @@ class DebugContext { } const debugContextSymbol = Symbol("debugContext"); +export function createDebugContext(env, { categories = [] } = {}) { + return { [debugContextSymbol]: new DebugContext(env, categories) }; +} + export function useOwnDebugContext({ categories = [] } = {}) { - useSubEnv({ [debugContextSymbol]: new DebugContext(useEnv(), categories) }); + useSubEnv(createDebugContext(useEnv(), { categories })); } export function useCurrentDebugContext() { diff --git a/addons/web/static/src/core/debug/debug_menu_items.js b/addons/web/static/src/core/debug/debug_menu_items.js index c9d0ed93939..6ef2c887d35 100644 --- a/addons/web/static/src/core/debug/debug_menu_items.js +++ b/addons/web/static/src/core/debug/debug_menu_items.js @@ -4,85 +4,6 @@ import { browser } from "../browser/browser"; import { routeToUrl } from "../browser/router_service"; import { registry } from "../registry"; -// @legacy -import dialogs from "web.view_dialogs"; -import { ComponentAdapter } from "web.OwlCompatibility"; - -// Backend Debug Manager Items -function runJSTestsItem({ env }) { - const runTestsURL = browser.location.origin + "/web/tests?mod=*"; - return { - type: "item", - description: env._t("Run JS Tests"), - href: runTestsURL, - callback: () => { - browser.open(runTestsURL); - }, - sequence: 10, - }; -} - -function runJSTestsMobileItem({ env }) { - const runTestsMobileURL = browser.location.origin + "/web/tests/mobile?mod=*"; - return { - type: "item", - description: env._t("Run JS Mobile Tests"), - href: runTestsMobileURL, - callback: () => { - browser.open(runTestsMobileURL); - }, - sequence: 20, - }; -} - -export function openViewItem({ env }) { - async function onSelected(records) { - const views = await env.services.orm.searchRead( - "ir.ui.view", - [["id", "=", records[0].id]], - ["name", "model", "type"], - { limit: 1 } - ); - const view = views[0]; - view.type = view.type === "tree" ? "list" : view.type; // ignore tree view - env.services.action.doAction({ - type: "ir.actions.act_window", - name: view.name, - res_model: view.model, - views: [[view.id, view.type]], - }); - } - - return { - type: "item", - description: env._t("Open View"), - callback: () => { - const adapterParent = new ComponentAdapter(null, { Component: owl.Component }); - const selectCreateDialog = new dialogs.SelectCreateDialog(adapterParent, { - res_model: "ir.ui.view", - title: env._t("Select a view"), - disable_multiple_selection: true, - domain: [ - ["type", "!=", "qweb"], - ["type", "!=", "search"], - ], - on_selected: onSelected, - }); - - selectCreateDialog.open(); - }, - sequence: 40, - }; -} - -// Global Debug Manager Items -function globalSeparator() { - return { - type: "separator", - sequence: 400, - }; -} - function activateAssetsDebugging({ env }) { return { type: "item", @@ -155,12 +76,6 @@ function leaveDebugMode({ env }) { registry .category("debug") .category("default") - // Backend - .add("runJSTestsItem", runJSTestsItem) - .add("runJSTestsMobileItem", runJSTestsMobileItem) - .add("openViewItem", openViewItem) - // Global - .add("globalSeparator", globalSeparator) .add("activateAssetsDebugging", activateAssetsDebugging) .add("regenerateAssets", regenerateAssets) .add("becomeSuperuser", becomeSuperuser) diff --git a/addons/web/static/src/core/debug/profiling/profiling_item.js b/addons/web/static/src/core/debug/profiling/profiling_item.js index 949bde29eea..b56f85d9c45 100644 --- a/addons/web/static/src/core/debug/profiling/profiling_item.js +++ b/addons/web/static/src/core/debug/profiling/profiling_item.js @@ -8,7 +8,6 @@ const { Component } = owl; export class ProfilingItem extends Component { setup() { this.profiling = useService("profiling"); - this.actionService = useService("action"); useBus(this.props.bus, "UPDATE", this.render); } @@ -16,7 +15,13 @@ export class ProfilingItem extends Component { this.profiling.setParam(param, ev.target.value); } openProfiles() { - this.actionService.doAction("base.action_menu_ir_profile"); + if (this.env.services.action) { + // using doAction in the backend to preserve breadcrumbs and stuff + this.env.services.action.doAction("base.action_menu_ir_profile"); + } else { + // No action service means we are in the frontend. + window.location = "/web/#action=base.action_menu_ir_profile"; + } } } ProfilingItem.components = { DropdownItem }; diff --git a/addons/web/static/src/core/errors/error_handlers.js b/addons/web/static/src/core/errors/error_handlers.js index b761d8eff74..f0d63de995c 100644 --- a/addons/web/static/src/core/errors/error_handlers.js +++ b/addons/web/static/src/core/errors/error_handlers.js @@ -18,6 +18,7 @@ import { UncaughtClientError, UncaughtCorsError, UncaughtPromiseError } from "./ const errorHandlerRegistry = registry.category("error_handlers"); const errorDialogRegistry = registry.category("error_dialogs"); +const errorNotificationRegistry = registry.category("error_notifications"); // ----------------------------------------------------------------------------- // CORS errors @@ -71,7 +72,7 @@ errorHandlerRegistry.add("clientErrorHandler", clientErrorHandler, { sequence: 9 * @param {Error} originalError * @returns {boolean} */ -function rpcErrorHandler(env, error, originalError) { +export function rpcErrorHandler(env, error, originalError) { if (!(error instanceof UncaughtPromiseError)) { return false; } @@ -85,9 +86,16 @@ function rpcErrorHandler(env, error, originalError) { // error is here a RPCError error.unhandledRejectionEvent.preventDefault(); const exceptionName = originalError.exceptionName; - let ErrorComponent = null; - if (exceptionName && errorDialogRegistry.contains(exceptionName)) { - ErrorComponent = errorDialogRegistry.get(exceptionName); + let ErrorComponent = originalError.Component; + if (!ErrorComponent && exceptionName) { + if (errorNotificationRegistry.contains(exceptionName)) { + const notif = errorNotificationRegistry.get(exceptionName); + env.services.notification.add(notif.message || originalError.data.message, notif); + return true; + } + if (errorDialogRegistry.contains(exceptionName)) { + ErrorComponent = errorDialogRegistry.get(exceptionName); + } } env.services.dialog.add(ErrorComponent || RPCErrorDialog, { diff --git a/addons/web/static/src/legacy/frontend/debug_manager/debug.xml b/addons/web/static/src/legacy/frontend/debug_manager/debug.xml deleted file mode 100644 index 4e50a483608..00000000000 --- a/addons/web/static/src/legacy/frontend/debug_manager/debug.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - Activate Assets Debugging - Activate Tests Assets Debugging - Regenerate Assets Bundles - Become Superuser - Leave the Developer Tools -