From cfc5da5b30f02ec72d8a14be690bc2aa4e8f1ac7 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 14 Feb 2023 16:08:35 +0000 Subject: [PATCH] [REF] web: remove unused legacy stuff This commit removes the legacy CustomCheckbox and the backward compatibility layer for the systray items. Both of them are no longer used. closes odoo/odoo#112718 Signed-off-by: Mathieu Duckerts-Antoine --- addons/web/__manifest__.py | 2 - .../legacy/js/components/custom_checkbox.js | 66 ------------------- addons/web/static/src/legacy/systray_menu.js | 3 - .../static/src/legacy/systray_menu_item.js | 56 ---------------- addons/web/static/src/legacy/xml/base.xml | 16 ----- .../components/custom_checkbox_tests.js | 52 --------------- 6 files changed, 195 deletions(-) delete mode 100644 addons/web/static/src/legacy/js/components/custom_checkbox.js delete mode 100644 addons/web/static/src/legacy/systray_menu.js delete mode 100644 addons/web/static/src/legacy/systray_menu_item.js delete mode 100644 addons/web/static/tests/legacy/components/custom_checkbox_tests.js diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 60f19ca9a89..e5afe5e6654 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -236,8 +236,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/legacy_promise_error_handler.js', 'web/static/src/legacy/legacy_rpc_error_handler.js', 'web/static/src/legacy/root_widget.js', - 'web/static/src/legacy/systray_menu.js', - 'web/static/src/legacy/systray_menu_item.js', 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/web_client.js', diff --git a/addons/web/static/src/legacy/js/components/custom_checkbox.js b/addons/web/static/src/legacy/js/components/custom_checkbox.js deleted file mode 100644 index fee2457fbae..00000000000 --- a/addons/web/static/src/legacy/js/components/custom_checkbox.js +++ /dev/null @@ -1,66 +0,0 @@ -odoo.define('web.CustomCheckbox', function (require) { - "use strict"; - - const utils = require('web.utils'); - const { LegacyComponent } = require("@web/legacy/legacy_component"); - - /** - * Custom checkbox - * - * Component that can be used in templates to render the custom checkbox of Odoo. - * - * - * - * @extends Component - */ - class CustomCheckbox extends LegacyComponent { - /** - * @param {Object} [props] - * @param {string | number | null} [props.id] - * @param {boolean} [props.value=false] - * @param {boolean} [props.disabled=false] - * @param {string} [props.text] - */ - setup() { - this._id = `checkbox-comp-${utils.generateID()}`; - } - } - CustomCheckbox.defaultProps = { - onChange: () => {}, - }; - CustomCheckbox.props = { - id: { - type: [String, Number], - optional: 1, - }, - class: { - type: String, - optional: 1, - }, - disabled: { - type: Boolean, - optional: 1, - }, - onChange: { - type: Function, - optional: 1, - }, - value: { - type: Boolean, - optional: 1, - }, - text: { - type: String, - optional: 1, - }, - }; - - CustomCheckbox.template = 'web.CustomCheckbox'; - - return CustomCheckbox; -}); diff --git a/addons/web/static/src/legacy/systray_menu.js b/addons/web/static/src/legacy/systray_menu.js deleted file mode 100644 index 4be77b575d2..00000000000 --- a/addons/web/static/src/legacy/systray_menu.js +++ /dev/null @@ -1,3 +0,0 @@ -odoo.define("web.SystrayMenu", function () { - return { Items: [] }; -}); diff --git a/addons/web/static/src/legacy/systray_menu_item.js b/addons/web/static/src/legacy/systray_menu_item.js deleted file mode 100644 index 7cbfe7cc8a0..00000000000 --- a/addons/web/static/src/legacy/systray_menu_item.js +++ /dev/null @@ -1,56 +0,0 @@ -/** @odoo-module **/ - -import { ComponentAdapter } from "web.OwlCompatibility"; -import * as legacySystrayMenu from "web.SystrayMenu"; -import { registry } from "../core/registry"; -import { LegacyComponent } from "@web/legacy/legacy_component"; - -import { Component, xml } from "@odoo/owl"; -const systrayRegistry = registry.category("systray"); - -class SystrayItemAdapter extends ComponentAdapter { - constructor() { - super(...arguments); - this.env = Component.env; - } -} - -// registers the legacy systray menu items from the legacy systray registry -// to the wowl one, but wrapped into Owl components -const legacySystrayMenuItems = legacySystrayMenu.Items; -const convertedItems = []; -let id = 1; - -const legacySystrayItemTemplate = xml``; - -function addSystrayItem(Widget) { - const name = `_legacy_systray_item_${id++}`; - - class SystrayItem extends LegacyComponent { - setup() { - this.Widget = Widget; - } - } - SystrayItem.template = legacySystrayItemTemplate; - SystrayItem.components = { SystrayItemAdapter }; - - systrayRegistry.add(name, { Component: SystrayItem }, { sequence: Widget.prototype.sequence }); - - convertedItems.push(Widget); -} - -legacySystrayMenuItems.forEach(addSystrayItem); -const push = legacySystrayMenuItems.push.bind(legacySystrayMenuItems); -legacySystrayMenuItems.push = function (Widget) { - push(Widget); - addSystrayItem(Widget); -}; -const splice = legacySystrayMenuItems.splice.bind(legacySystrayMenuItems); -legacySystrayMenuItems.splice = function () { - splice(...arguments); - legacySystrayMenuItems.forEach((Widget) => { - if (!convertedItems.includes(Widget)) { - addSystrayItem(Widget); - } - }); -}; diff --git a/addons/web/static/src/legacy/xml/base.xml b/addons/web/static/src/legacy/xml/base.xml index f6d0b22af20..25ce87cc3d2 100644 --- a/addons/web/static/src/legacy/xml/base.xml +++ b/addons/web/static/src/legacy/xml/base.xml @@ -80,22 +80,6 @@ - -
- - -
-
- diff --git a/addons/web/static/tests/legacy/components/custom_checkbox_tests.js b/addons/web/static/tests/legacy/components/custom_checkbox_tests.js deleted file mode 100644 index b9de73b1abc..00000000000 --- a/addons/web/static/tests/legacy/components/custom_checkbox_tests.js +++ /dev/null @@ -1,52 +0,0 @@ -odoo.define('web.custom_checkbox_tests', function (require) { - "use strict"; - - const CustomCheckbox = require('web.CustomCheckbox'); - const testUtils = require('web.test_utils'); - - const { createComponent, dom: testUtilsDom } = testUtils; - - QUnit.module('Components', {}, function () { - - QUnit.module('CustomCheckbox'); - - QUnit.test('test checkbox: default values', async function(assert) { - assert.expect(6); - - const checkbox = await createComponent(CustomCheckbox, {}); - - assert.containsOnce(checkbox.el, 'input'); - assert.containsNone(checkbox.el, 'input:disabled'); - assert.containsOnce(checkbox.el, 'label'); - - const input = checkbox.el.querySelector('input'); - assert.notOk(input.checked, 'checkbox should be unchecked'); - assert.ok(input.id.startsWith('checkbox-comp-')); - - await testUtilsDom.click(checkbox.el.querySelector('label')); - assert.ok(input.checked, 'checkbox should be checked'); - }); - - QUnit.test('test checkbox: custom values', async function(assert) { - assert.expect(6); - - const checkbox = await createComponent(CustomCheckbox, { - props: { - id: 'my-form-check', - disabled: true, - value: true, - text: 'checkbox', - } - }); - - assert.containsOnce(checkbox.el, 'input'); - assert.containsOnce(checkbox.el, 'input:disabled'); - assert.containsOnce(checkbox.el, 'label'); - - const input = checkbox.el.querySelector('input'); - assert.ok(input.checked, 'checkbox should be checked'); - assert.strictEqual(input.id, 'my-form-check'); - assert.ok(input.checked, 'checkbox should be checked'); - }); - }); -});