[REF] web, project: remove the component NotUpdatable

With the new fine-grained reactivity in owl 2, this component is not
necessary any more.

Part-of: odoo/odoo#84314
This commit is contained in:
Géry Debongnie
2022-02-25 12:35:43 +00:00
committed by Jorge Pinna Puissant
parent f96c88ee1a
commit d90f481448
10 changed files with 23 additions and 72 deletions
@@ -4,7 +4,7 @@ import { useBus, useService } from '@web/core/utils/hooks';
import { ActionContainer } from '@web/webclient/actions/action_container';
import { MainComponentsContainer } from "@web/core/main_components_container";
import { useOwnDebugContext } from "@web/core/debug/debug_context";
import { ErrorHandler, NotUpdatable } from "@web/core/utils/components";
import { ErrorHandler } from "@web/core/utils/components";
import { session } from '@web/session';
const { Component, useEffect } = owl;
@@ -59,5 +59,5 @@ export class ProjectSharingWebClient extends Component {
}
}
ProjectSharingWebClient.components = { ActionContainer, ErrorHandler, NotUpdatable, MainComponentsContainer };
ProjectSharingWebClient.components = { ActionContainer, ErrorHandler, MainComponentsContainer };
ProjectSharingWebClient.template = 'project.ProjectSharingWebClient';
@@ -2,9 +2,7 @@
<templates xml:space="preserve">
<t t-name="project.ProjectSharingWebClient" owl="1">
<NotUpdatable>
<ActionContainer />
</NotUpdatable>
<ActionContainer />
<MainComponentsContainer/>
</t>
@@ -1,6 +1,6 @@
/** @odoo-module **/
import { ErrorHandler, NotUpdatable } from "../utils/components";
import { ErrorHandler } from "../utils/components";
const { Component, xml } = owl;
@@ -22,18 +22,16 @@ export class DialogContainer extends Component {
});
}
}
DialogContainer.components = { ErrorHandler, NotUpdatable };
DialogContainer.components = { ErrorHandler };
//Legacy : The div wrapping the t-foreach, is placed to avoid owl to delete non-owl dialogs.
//This div can be removed after removing all legacy dialogs.
DialogContainer.template = xml`
<div class="o_dialog_container" t-att-class="{'modal-open': Object.keys(props.dialogs).length > 0}">
<div>
<t t-foreach="Object.values(props.dialogs)" t-as="dialog" t-key="dialog.id">
<NotUpdatable>
<ErrorHandler onError="(error) => this.handleError(error, dialog.id)">
<t t-component="dialog.class" t-props="dialog.props" isActive="dialog_last"/>
</ErrorHandler>
</NotUpdatable>
<ErrorHandler onError="(error) => this.handleError(error, dialog.id)">
<t t-component="dialog.class" t-props="dialog.props" isActive="dialog_last"/>
</ErrorHandler>
</t>
</div>
</div>
@@ -1,6 +1,6 @@
/** @odoo-module */
import { registry } from "./registry";
import { NotUpdatable, ErrorHandler } from "./utils/components";
import { ErrorHandler } from "./utils/components";
const { Component, xml } = owl;
@@ -27,12 +27,10 @@ export class MainComponentsContainer extends Component {
MainComponentsContainer.template = xml`
<div>
<t t-foreach="Components" t-as="C" t-key="C[0]">
<NotUpdatable>
<ErrorHandler onError="error => this.handleComponentError(error, C)">
<t t-component="C[1].Component" t-props="C[1].props"/>
</ErrorHandler>
</NotUpdatable>
<ErrorHandler onError="error => this.handleComponentError(error, C)">
<t t-component="C[1].Component" t-props="C[1].props"/>
</ErrorHandler>
</t>
</div>
`;
MainComponentsContainer.components = { NotUpdatable, ErrorHandler };
MainComponentsContainer.components = { ErrorHandler };
@@ -2,15 +2,6 @@
const { Component, onError, useComponent, xml } = owl;
export class NotUpdatable extends Component {
setup() {
const node = useComponent().__owl__;
node.patch = () => {};
node.updateAndRender = () => Promise.resolve();
}
}
NotUpdatable.template = xml`<t t-slot="default" />`;
export class ErrorHandler extends Component {
setup() {
onError((error) => {
@@ -5,7 +5,7 @@ import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { useService, useBus } from "@web/core/utils/hooks";
import { registry } from "@web/core/registry";
import { debounce } from "@web/core/utils/timing";
import { ErrorHandler, NotUpdatable } from "@web/core/utils/components";
import { ErrorHandler } from "@web/core/utils/components";
const { Component, onWillDestroy, useExternalListener, useEffect, useRef } = owl;
const systrayRegistry = registry.category("systray");
@@ -185,4 +185,4 @@ export class NavBar extends Component {
}
}
NavBar.template = "web.NavBar";
NavBar.components = { Dropdown, DropdownItem, MenuDropdown, NotUpdatable, ErrorHandler };
NavBar.components = { Dropdown, DropdownItem, MenuDropdown, ErrorHandler };
@@ -30,11 +30,9 @@
<!-- Systray -->
<div class="o_menu_systray d-flex flex-shrink-0 ml-auto" role="menu">
<t t-foreach="systrayItems" t-as="item" t-key="item.key">
<NotUpdatable>
<ErrorHandler onError="error => this.handleItemError(error, item)">
<t t-component="item.Component" t-props="item.props"/>
</ErrorHandler>
</NotUpdatable>
<ErrorHandler onError="error => this.handleItemError(error, item)">
<t t-component="item.Component" t-props="item.props"/>
</ErrorHandler>
</t>
</div>
</nav>
@@ -5,7 +5,6 @@ import { DebugMenu } from "@web/core/debug/debug_menu";
import { localization } from "@web/core/l10n/localization";
import { MainComponentsContainer } from "@web/core/main_components_container";
import { registry } from "@web/core/registry";
import { NotUpdatable } from "@web/core/utils/components";
import { useBus, useService } from "@web/core/utils/hooks";
import { ActionContainer } from "./actions/action_container";
import { NavBar } from "./navbar/navbar";
@@ -112,7 +111,6 @@ export class WebClient extends Component {
WebClient.components = {
ActionContainer,
NavBar,
NotUpdatable,
MainComponentsContainer,
};
WebClient.template = "web.WebClient";
@@ -2,12 +2,10 @@
<templates xml:space="preserve">
<t t-name="web.WebClient" owl="1">
<NotUpdatable t-if="!state.fullscreen">
<t t-if="!state.fullscreen">
<NavBar/>
</NotUpdatable>
<NotUpdatable>
<ActionContainer/>
</NotUpdatable>
</t>
<ActionContainer/>
<MainComponentsContainer/>
</t>
@@ -1,42 +1,14 @@
/** @odoo-module **/
import { NotUpdatable, ErrorHandler } from "@web/core/utils/components";
import { ErrorHandler } from "@web/core/utils/components";
import { makeTestEnv } from "../../helpers/mock_env";
import { getFixture, mount } from "../../helpers/utils";
const { Component, onMounted, onWillUpdateProps, xml } = owl;
const { Component, xml } = owl;
QUnit.module("utils", () => {
QUnit.module("components");
QUnit.test("NotUpdatable component", async function (assert) {
class Child extends Component {
setup() {
onMounted(() => {
assert.step("mounted");
});
onWillUpdateProps(() => {
assert.step("willupdateprops");
});
}
}
Child.template = xml`<div>hey</div>`;
class Parent extends Component {}
Parent.template = xml`
<div>
<Child/>
<NotUpdatable><Child/></NotUpdatable>
</div>`;
Parent.components = { Child, NotUpdatable };
const target = getFixture();
const parent = await mount(Parent, target, { env: makeTestEnv() });
assert.verifySteps(["mounted", "mounted"]);
await parent.render();
assert.verifySteps(["willupdateprops"]);
});
QUnit.test("ErrorHandler component", async function (assert) {
class Boom extends Component {}
Boom.template = xml`<div><t t-esc="this.will.throw"/></div>`;