-
Notifications
You must be signed in to change notification settings - Fork 23.2k
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
[FIX] mail: splicing schedule method #160069
base: saas-16.3
Are you sure you want to change the base?
[FIX] mail: splicing schedule method #160069
Conversation
203a0c4
to
d3bb1fd
Compare
d3bb1fd
to
92a45ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @somu-odoo,
Just added a small comment about the "Mark as Done" that is not working anymore because it is still calling the props onUpdate instead of the method.
@@ -72,6 +72,10 @@ export class Activity extends Component { | |||
return computeDelay(this.props.data.date_deadline); | |||
} | |||
|
|||
get onUpdate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support updating the main view when using the "mark as done" button, you should also use this function in onClickMarkAsDone.
async onClickMarkAsDone(ev) {
// ...
this.popover.open(ev.currentTarget, {
// ...
reload: this.onUpdate, // (instead of this.props.onUpdate)
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my bad, might have missed this one.
92a45ab
to
d43e86f
Compare
It's not great to introduce so many artificial splits to enable so much overrides. This makes refactoring the code far more complicated than necessary. Considering that |
Hi @alexkuhn |
@somu-odoo You could have the flag in the The gain is to reduce drastically the footprint of patches / overrides. This is desirable because every patch / override makes the code much less flexible due to them adding feature on top of existing components by relying on their current code structure. The shape of code is mostly arbitrary, so reducing its flexibility can make refactoring very hard. Also in general, the maintainer of the original component is not necessarily the same as the maintainer of the patch, so that's another reason to reduce drastically the work of the patcher if any is necessary. I get that in the past we went a lot with patching and overriding stuffs in JS, but we learned that they worsen code maintenance. Ideally all features are available in original code and you just have to use the component. Customising the component in an non-official way like with patching / overriding methods should be very rare and minimal. |
f3cb15a
to
52c9074
Compare
@alexkuhn I've pushed another approach which should work as you have suggested, if I understood it correct. Let me know if this needs any changes |
useEffect( | ||
() => { | ||
if (this.state.reloadParentView) { | ||
this.reloadParentView(); | ||
} | ||
}, | ||
() => [this.state.reloadParentView] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look necessary to make a state.reloadParentView
and have this useEffect
.
You could use this.reloadParentView()
like before, but make this function available in useChildSubEnv
. In documents override, it just has to this.env.reloadParentView()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setup made sense since we wished to use flag, but if we omit that, then we can also use this.props.reloadParentView()
in our patch, that would remove the need for adding it in env unless we wish to remove that prop as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either I miss something or using this.state.reloadParentView
is just a complicated way to just this.reloadParentView()
.
Using a flag in state
, so that it triggers a useEffect
that actually reloadParentView()
... This looks complicated for the sake of being complicated.
The only part that may require something like this is if you have 2 triggers of the flag and you rely on useEffect
to result in a single reloadParentView()
rather than 2... Is it what you try to solve? If not, then I see no point to make the code more complicated than necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I understand the reason behind removing the flag.
I've pushed the changes as suggested.
Now, since we added the method in env
, should we remove the method from props
and adapt accordingly? or keep them both for older patches to work properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but it's best to do that in master
. This is a fix in 16.3 so we should be cautious not to break community code like OCA modules, which could rely on this.props.reloadParentView
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright in that case, I have implemented it and have updated both branches accordingly
This is much better! I like the reduced code in the patch. Thanks :) |
efaeeb4
to
8252b64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
async schedule(threadId) { | ||
await this.activityService.schedule(this.props.threadModel, threadId); | ||
this.load(this.props.threadId, ["activities", "messages"]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for master / 17.3: this.activityService.schedule()
has been replaced by this.store.scheduleActivity()
(fyi, reasoning was that discuss code looked very complex with many services, so we killed most of them)
This commit modifies childSubEnv to add a support for reloadParentView. Two methods are splitted in order to allow some additional modifications - schedule - onUpdate Implementation of these splits can be seen here: odoo-dev/enterprise@767b8b0 Task - 3786861
8252b64
to
772faea
Compare
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
This PR separates the schedule method from scheduleActivity method, so that it can be overridden.
Needed to be done to trigger reloadParentView method for documents.document.
See here: odoo-dev/enterprise@14c7a95
Task - 3786861
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr