From 6ce1af636d0564ff64236e1a711549cf76eb43d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 19 Feb 2019 09:33:09 +0100 Subject: [PATCH] move env from widget to env --- web/static/src/ts/env.ts | 36 +++++++++++++++++++++++++---- web/static/src/ts/widgets/root.ts | 3 ++- web/static/src/ts/widgets/widget.ts | 30 ++---------------------- web/static/tests/helpers.ts | 2 +- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/web/static/src/ts/env.ts b/web/static/src/ts/env.ts index 982ace92..8403d524 100644 --- a/web/static/src/ts/env.ts +++ b/web/static/src/ts/env.ts @@ -1,18 +1,44 @@ +import { WEnv } from "./core/component"; import { QWeb } from "./core/qweb_vdom"; +import { Registry } from "./core/registry"; import { idGenerator, memoize } from "./core/utils"; import { TemplateLoader } from "./loaders/templates"; import { actionRegistry } from "./registries"; import { RPC } from "./services/ajax"; -import { ActionManager } from "./store/action_manager"; -import { Ajax } from "./store/ajax"; -import { NotificationManager } from "./store/notifications"; -import { Router } from "./store/router"; -import { Env } from "./widgets/widget"; +import { + ActionManager, + ActionWidget, + IActionManager +} from "./store/action_manager"; +import { Ajax, IAjax } from "./store/ajax"; +import { + INotificationManager, + NotificationManager +} from "./store/notifications"; +import { IRouter, Router } from "./store/router"; //------------------------------------------------------------------------------ // Types //------------------------------------------------------------------------------ +export interface Env extends WEnv { + // services + actionManager: IActionManager; + ajax: IAjax; + notifications: INotificationManager; + router: IRouter; + + // registries + actionRegistry: Registry; + + // helpers + rpc: IAjax["rpc"]; + + // configuration + debug: boolean; + isMobile: boolean; +} + interface Loaders { loadTemplates: TemplateLoader; } diff --git a/web/static/src/ts/widgets/root.ts b/web/static/src/ts/widgets/root.ts index 67f1de08..958d26ff 100644 --- a/web/static/src/ts/widgets/root.ts +++ b/web/static/src/ts/widgets/root.ts @@ -6,7 +6,8 @@ import { ActionContainer } from "./action_container"; import { HomeMenu } from "./home_menu"; import { Navbar } from "./navbar"; import { Notification } from "./notification"; -import { Env, Widget } from "./widget"; +import { Widget } from "./widget"; +import { Env } from "../env"; //------------------------------------------------------------------------------ // Types diff --git a/web/static/src/ts/widgets/widget.ts b/web/static/src/ts/widgets/widget.ts index 71a622f7..74e7ad4d 100644 --- a/web/static/src/ts/widgets/widget.ts +++ b/web/static/src/ts/widgets/widget.ts @@ -1,31 +1,5 @@ -import { IAjax } from "../store/ajax"; -import { Component, PureComponent, WEnv } from "../core/component"; -import { INotificationManager } from "../store/notifications"; -import { Registry } from "../core/registry"; -import { IRouter } from "../store/router"; -import { ActionWidget, IActionManager } from "../store/action_manager"; - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -export interface Env extends WEnv { - // services - actionManager: IActionManager; - ajax: IAjax; - notifications: INotificationManager; - router: IRouter; - - // registries - actionRegistry: Registry; - - // helpers - rpc: IAjax["rpc"]; - - // configuration - debug: boolean; - isMobile: boolean; -} +import { Component, PureComponent } from "../core/component"; +import { Env } from "../env"; //------------------------------------------------------------------------------ // Widget classes diff --git a/web/static/tests/helpers.ts b/web/static/tests/helpers.ts index 32e3bbce..ee3c96b7 100644 --- a/web/static/tests/helpers.ts +++ b/web/static/tests/helpers.ts @@ -9,7 +9,7 @@ import { getMenuInfo, MenuInfo } from "../src/ts/loaders/menus"; import { actionRegistry } from "../src/ts/registries"; import { ActionManager } from "../src/ts/store/action_manager"; import { Ajax } from "../src/ts/store/ajax"; -import { Env } from "../src/ts/widgets/widget"; +import { Env } from "../src/ts/env"; export function makeTestFixture() { let fixture = document.createElement("div");