Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Master simplify model startup vsc #4160

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

VincentSchippefilt
Copy link
Collaborator

Description:

preliminary work to split the model into core_model and all_the_rest_model

Task: : 3637435 (https://www.odoo.com/web#id=3637435&action=333&active_id=2328&model=project.task&view_type=form&cids=1&menu_id=4720)

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@VincentSchippefilt
Copy link
Collaborator Author

robodoo rebase-ff

@robodoo
Copy link
Collaborator

robodoo commented Apr 30, 2024

@robodoo
Copy link
Collaborator

robodoo commented Apr 30, 2024

Merge method set to rebase and fast-forward.

Copy link
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tchou tchou 🚂

Not a fan of the name CoreUIPlugin, but I don't have ideas either 🤷

@@ -27,7 +27,7 @@ export interface UIPluginConfig {
readonly custom: ModelConfig["custom"];
readonly session: Session;
readonly defaultCurrencyFormat?: Format;
readonly customColors: Color[];
// readonly customColors: Color[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment ?

Comment on lines 249 to +251
for (let Plugin of coreViewsPluginRegistry.getAll()) {
const plugin = this.setupUiPlugin(Plugin);
this.coreViewsPlugins.push(plugin);
const plugin = this.setupCoreUiPlugin(Plugin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think coreViewPlugin was a very good name, but IMO CoreUIPlugin is even more confusing.

Anyway the registry should also be renamed if we want to change the nomenclature

Comment on lines +326 to +335
for (let name of Plugin.getters) {
if (!(name in plugin)) {
throw new Error(`Invalid getter name: ${name} for plugin ${plugin.constructor}`);
}
if (name in this.getters) {
throw new Error(`Getter "${name}" is already defined.`);
}
this.getters[name] = plugin[name].bind(plugin);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to extract this loop in a method ? It's now copy/pasted 3 times in this file

Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the core_ui_plugins where of type UIPlugin, which is not correct

could you elaborate in the commit message why it's not correct?
It's actually not clear to me why it's not correct. Core UI plugins still handle UI commands, can use all getters. Except what's available in the plugin config, nothing changed much.

They should probably not be able to handle UI commands, but then this commit is not enough (there's currently a few exceptions: START, EVALUATE_CELLS, REFRESH_PIVOT, others?).

Also note that moving the evaluation to a worker will be very hard, even impossible. It depends on a loooot of things, especially for odoo pivots (rpc, web pivot model, and more)

@@ -587,13 +598,13 @@ export class Model extends EventBus<any> implements CommandDispatcher {
private dispatchToHandlers(handlers: CommandHandler<Command>[], command: Command) {
const isCommandCore = isCoreCommand(command);
for (const handler of handlers) {
if (!isCommandCore && handler instanceof CorePlugin) {
if (!isCommandCore && this.corePlugins.includes(handler as any)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is not improving performance :/
I tried autofilling 10k rows twice.
before: Replayed 19998 commands in 1266 ms
after: Replayed 19998 commands in 1412 ms => ~11% more
(average over 6 runs)
Maybe we can find another way

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I'm looking into it.

@@ -21,7 +21,7 @@ interface CellWithSize {
size: Pixel;
}

export class HeaderSizeUIPlugin extends UIPlugin<HeaderSizeState> implements HeaderSizeState {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this plugin depends on DOM api to create a canvas element. We won't be able to move it to a Worker as it is now, we'll have to refactor a bit more here.
private ctx = document.createElement("canvas").getContext("2d")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's only used to compute text size, it can be done in an offscreen canvas in a worker I think :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know OffscreenCanvas were a thing

Simplify the creation and binding on the history object.

This is preliminary work for separating Model.ts into multiple
independant parts.

Task: 3637435
Before this commit, the core_ui_plugins where of type UIPlugin, which is not correct

After this commit, they have their own type: CoreUiPlugin, which is basically a core
plugin that has access to all getters

Task: 3637435
Before this commit, the Custom Colors plugins was using its history for a transient value.
After this commit, it uses its local property without history.
…e for basically each command,

nothing works anymore.
…ry change for basically each command,"

This reverts commit 62177fa.
@VincentSchippefilt VincentSchippefilt force-pushed the master-simplify-model-startup-vsc branch from 4e511f5 to eb4af98 Compare May 22, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants