[FIX] website: fix restricted editor warnings

Before this commit, the "Edit Menu" was displayed for the restricted
editors, even if they didn't have the right to access the website pages.
This was leading to a warning in the "click_all" test with the demo
user, and didn't make sense for the real user (who was prompted an
"access denied" modal).

Now, this menu is displayed only for the website designers.

Additionally to that, the website root instance would load the wysiwyg
assets if it is created inside an iframe which has the "load-wysiwyg"
data-attribute. But the test was not correctly written (as
data-load-wysiwyg was the string 'false'). This would lead to a warning
in the console when a user with no website rights was accessing the
website client action, introduced in [1].

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

closes odoo/odoo#96520

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Younn Olivier
2022-07-22 16:21:59 +02:00
parent a9f409c87d
commit 16c99f58ba
2 changed files with 2 additions and 2 deletions
@@ -30,7 +30,7 @@ patch(NavBar.prototype, 'website_navbar', {
this.websiteEditingMenus = {
'website.menu_edit_menu': {
Component: EditMenuDialog,
isDisplayed: () => !!this.websiteService.currentWebsite,
isDisplayed: () => !!this.websiteService.currentWebsite && this.websiteService.isDesigner,
},
'website.menu_optimize_seo': {
Component: OptimizeSEODialog,
@@ -7,7 +7,7 @@ import { loadWysiwyg } from "web_editor.loader";
export default createPublicRoot(WebsiteRoot).then(rootInstance => {
// This data attribute is set by the WebsitePreview client action for a
// publisher user.
if (window.frameElement && window.frameElement.dataset.loadWysiwyg) {
if (window.frameElement && window.frameElement.dataset.loadWysiwyg === 'true') {
loadWysiwyg(['website.compiled_assets_wysiwyg']).then(() => {
window.dispatchEvent(new CustomEvent('PUBLIC-ROOT-READY', {detail: {rootInstance}}));
});