[FIX] website: prevent entering edit mode when the screen is too small

We don't want users to edit their websites on a too small screen. To do
this, we hide the edit button when the screen width is less than 768 px
(the MD breakpoint of Bootstrap). Unfortunately, when a user creates a
new website, they go through the website configurator and are then
redirected to their new website with the edit mode enabled. We don't
want that when the screen is small. This commit only opens edit mode
after a website is created if the screen is large enough. Note that this
commit will also prevent users from forcing edit mode with the url
(enable_editor=1) when their screen is too small.

task-3316267

closes odoo/odoo#123992

X-original-commit: 00ea187ce641013feea00650cb2cadab73ebe636
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
This commit is contained in:
Guillaume (gdi)
2023-06-07 15:58:42 +02:00
parent 1fed41319e
commit bc877cbf3f
@@ -14,6 +14,7 @@ import { routeToUrl } from "@web/core/browser/router_service";
import { getActiveHotkey } from "@web/core/hotkeys/hotkey_service";
import { sprintf } from "@web/core/utils/strings";
import wUtils from 'website.utils';
import config from "web.config";
const { Component, onWillStart, onMounted, onWillUnmount, useRef, useEffect, useState } = owl;
@@ -89,6 +90,14 @@ export class WebsitePreview extends Component {
if (this.isRestored) {
return;
}
const isScreenLargeEnoughForEdit =
config.device.size_class >= config.device.SIZES.MD;
if (!isScreenLargeEnoughForEdit && this.props.action.context.params) {
this.props.action.context.params.enable_editor = false;
this.props.action.context.params.with_loader = false;
}
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;