[FIX] website: ignore context params when client action is restored

Before this commit, the website context was configured with the params
of the client action, at all times. This was leading to weird
behaviours:
- Go to the website client action
- Install the "Blogs" module from the new content systray item
- Navigate on a blog post from the client action
- Click on the "Settings" systray item (last one from the right)
- Click on the "Website Preview" breadcrumb item
=> The "New Content" modal is displayed, again, when it should not.

Another flow, on enterprise:
- Start the client action with /@/?enable_editor=1
- Click on the top left icon to go back to the home screen
- Click on the top left icon to go back to the website
=> The editor is launched when it should not.

To prevent that, the action jsId key is registered at the website
service level. If the action is restored, the jsId will be the same, and
the params used to configure the context will be ignored.

Related to https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

Part-of: odoo/odoo#96401
This commit is contained in:
Younn Olivier
2022-08-08 12:32:51 +02:00
committed by qsm-odoo
parent d4bf7c4b46
commit 83501e38a3
2 changed files with 15 additions and 0 deletions
@@ -76,6 +76,14 @@ export class WebsitePreview extends Component {
useEffect(() => {
this.websiteService.currentWebsiteId = this.websiteId;
// The params used to configure the context should be ignored when
// the action is restored (example: click on the breadcrumb).
const isRestored = this.props.action.jsId === this.websiteService.actionJsId;
this.websiteService.actionJsId = this.props.action.jsId;
if (isRestored) {
return;
}
this.websiteService.context.showNewContentModal = this.props.action.context.params && this.props.action.context.params.display_new_content;
this.websiteService.context.edition = this.props.action.context.params && !!this.props.action.context.params.enable_editor;
this.websiteService.context.translation = this.props.action.context.params && !!this.props.action.context.params.edit_translations;
@@ -38,6 +38,7 @@ export const websiteService = {
let isPublisher;
let isDesigner;
let hasMultiWebsites;
let actionJsId;
const context = reactive({
showNewContentModal: false,
showAceEditor: false,
@@ -151,6 +152,12 @@ export const websiteService = {
get hasMultiWebsites() {
return hasMultiWebsites === true;
},
get actionJsId() {
return actionJsId;
},
set actionJsId(jsId) {
actionJsId = jsId;
},
openMenuDialog(Component, props) {
return dialog.add(Component, props);
},