From f65fdd01f220f593c89497cdec24c8012fad9672 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 29 Aug 2023 14:55:00 +0200 Subject: [PATCH] [REF] web: remove LegacyAdaptedActionDialog This component was necessary during the transition phase, when all actions weren't converted to owl yet. Now, they are, so we can get rid of this small compatibility layer. Part of task~3439226 closes odoo/odoo#133489 Signed-off-by: Samuel Degueldre (sad) --- addons/web/static/src/legacy/utils.js | 20 --------- .../src/webclient/actions/action_dialog.js | 45 +------------------ .../src/webclient/actions/action_dialog.xml | 10 ----- .../src/webclient/actions/action_service.js | 12 ++++- 4 files changed, 12 insertions(+), 75 deletions(-) diff --git a/addons/web/static/src/legacy/utils.js b/addons/web/static/src/legacy/utils.js index 49ab4cfb31b..8dd659be439 100644 --- a/addons/web/static/src/legacy/utils.js +++ b/addons/web/static/src/legacy/utils.js @@ -208,26 +208,6 @@ export function makeLegacyRPCService(legacyEnv) { }; } -export function useLegacyRefs() { - const env = owl.useEnv(); - - let legacyRefs; - if (env.legacyRefs) { - legacyRefs = env.legacyRefs; - } else { - legacyRefs = { - component: null, - widget: null, - }; - } - - owl.useChildSubEnv({ - legacyRefs, - }); - - return legacyRefs; -} - /** * This hook allows legacy owl Components to use services coming from the wowl env. * @param {string} serviceName diff --git a/addons/web/static/src/webclient/actions/action_dialog.js b/addons/web/static/src/webclient/actions/action_dialog.js index 0ff32a1c475..126fd9f8a94 100644 --- a/addons/web/static/src/webclient/actions/action_dialog.js +++ b/addons/web/static/src/webclient/actions/action_dialog.js @@ -3,21 +3,10 @@ import { Dialog } from "@web/core/dialog/dialog"; import { DebugMenu } from "@web/core/debug/debug_menu"; import { useOwnDebugContext } from "@web/core/debug/debug_context"; -import { useLegacyRefs } from "@web/legacy/utils"; import { useEffect } from "@odoo/owl"; -const LEGACY_SIZE_CLASSES = { - "extra-large": "xl", - large: "lg", - medium: "md", - small: "sm", -}; - -// ----------------------------------------------------------------------------- -// Action Dialog (Component) -// ----------------------------------------------------------------------------- -class ActionDialog extends Dialog { +export class ActionDialog extends Dialog { setup() { super.setup(); useOwnDebugContext(); @@ -49,35 +38,3 @@ ActionDialog.defaultProps = { ...Dialog.defaultProps, withBodyPadding: false, }; - -/** - * This LegacyAdaptedActionDialog class will disappear when legacy code will be entirely rewritten. - * The "ActionDialog" class should get exported from this file when the cleaning will occur, and it - * should stop extending Dialog and use it normally instead at that point. - */ -class LegacyAdaptedActionDialog extends ActionDialog { - setup() { - super.setup(); - const actionProps = this.props && this.props.actionProps; - const actionContext = actionProps && actionProps.context; - const actionDialogSize = actionContext && actionContext.dialog_size; - this.props.size = LEGACY_SIZE_CLASSES[actionDialogSize] || Dialog.defaultProps.size; - const ControllerComponent = this.props && this.props.ActionComponent; - const Controller = ControllerComponent && ControllerComponent.Component; - this.isLegacy = Controller && Controller.isLegacy; - const legacyRefs = useLegacyRefs(); - useEffect( - () => { - if (this.isLegacy) { - // Render legacy footer buttons - const footer = this.modalRef.el.querySelector("footer"); - legacyRefs.widget.renderButtons($(footer)); - } - }, - () => [] - ); - } -} -LegacyAdaptedActionDialog.template = "web.LegacyAdaptedActionDialog"; - -export { LegacyAdaptedActionDialog as ActionDialog }; diff --git a/addons/web/static/src/webclient/actions/action_dialog.xml b/addons/web/static/src/webclient/actions/action_dialog.xml index 8775f13daae..14cf92ba409 100644 --- a/addons/web/static/src/webclient/actions/action_dialog.xml +++ b/addons/web/static/src/webclient/actions/action_dialog.xml @@ -23,14 +23,4 @@ - - - - - - - - - - diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 6f2fce4f2cb..11c29947430 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -93,6 +93,13 @@ function parseActiveIds(ids) { return activeIds; } +const DIALOG_SIZES = { + "extra-large": "xl", + large: "lg", + medium: "md", + small: "sm", +}; + // ----------------------------------------------------------------------------- // Errors // ----------------------------------------------------------------------------- @@ -775,7 +782,6 @@ function makeActionManager(env) { if (action.target === "new") { cleanDomFromBootstrap(); const actionDialogProps = { - // TODO add size ActionComponent: ControllerComponent, actionProps: controller.props, actionType: action.type, @@ -783,6 +789,10 @@ function makeActionManager(env) { if (action.name) { actionDialogProps.title = action.name; } + const size = DIALOG_SIZES[action.context.dialog_size]; + if (size) { + actionDialogProps.size = size; + } const onClose = _removeDialog(); removeDialogFn = env.services.dialog.add(ActionDialog, actionDialogProps, {