From 83501e38a338cabd5a064dd0db9f70df08a3aadc Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Wed, 20 Jul 2022 10:21:02 +0000 Subject: [PATCH] [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 --- .../src/client_actions/website_preview/website_preview.js | 8 ++++++++ addons/website/static/src/services/website_service.js | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/addons/website/static/src/client_actions/website_preview/website_preview.js b/addons/website/static/src/client_actions/website_preview/website_preview.js index 12ea7ae3abf..490c0b88a05 100644 --- a/addons/website/static/src/client_actions/website_preview/website_preview.js +++ b/addons/website/static/src/client_actions/website_preview/website_preview.js @@ -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; diff --git a/addons/website/static/src/services/website_service.js b/addons/website/static/src/services/website_service.js index a5cc2290c10..c69541278a3 100644 --- a/addons/website/static/src/services/website_service.js +++ b/addons/website/static/src/services/website_service.js @@ -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); },