From ccfca271b902594bfd1d30f9baa94f076ff8f992 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Thu, 19 Nov 2020 15:25:45 +0000 Subject: [PATCH] [IMP] website: keep loader alive until editor is opened MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit the navigation toolbar was accessible after selecting a theme before the editor was opened, which on slow connections made it possible for users to leave the screen and miss the tour After this commit the loader animation of the theme installation is blocking the access to the screen until the editor is opened thus preventing user to navigate elsewhere before seeing the tour task-2387608 closes odoo/odoo#62029 Signed-off-by: Jérémy Kersten (jke) --- addons/website/models/ir_module_module.py | 8 ++++++-- addons/website/static/src/js/menu/edit.js | 10 ++++++++-- .../website/static/src/scss/website.backend.scss | 15 --------------- .../static/src/scss/website.theme_install.scss | 15 +++++++++++++++ addons/website/views/assets.xml | 2 ++ addons/website/views/website_navbar_templates.xml | 3 +++ 6 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 addons/website/static/src/scss/website.theme_install.scss diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 9ec53dcc519..b23052fe79f 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -361,10 +361,14 @@ class IrModuleModule(models.Model): self._theme_upgrade_upstream() active_todo = self.env['ir.actions.todo'].search([('state', '=', 'open')], limit=1) + result = None if active_todo: - return active_todo.action_launch() + result = active_todo.action_launch() else: - return website.button_go_website(mode_edit=True) + result = website.button_go_website(mode_edit=True) + if result.get('url') and 'enable_editor' in result['url']: + result['url'] = result['url'].replace('enable_editor', 'with_loader=1&enable_editor') + return result def button_remove_theme(self): """Remove the current theme of the current website.""" diff --git a/addons/website/static/src/js/menu/edit.js b/addons/website/static/src/js/menu/edit.js index d8006e0ddac..d3382932560 100644 --- a/addons/website/static/src/js/menu/edit.js +++ b/addons/website/static/src/js/menu/edit.js @@ -83,12 +83,14 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ this._editorAutoStart = (context.editable && window.location.search.indexOf('enable_editor') >= 0); this._mustEditTranslations = context.edit_translations; + var url = new URL(window.location.href) if (this._mustEditTranslations) { - var url = window.location.href.replace(/([?&])&*edit_translations[^&#]*&?/, '\$1'); + url.searchParams.delete('edit_translations') window.history.replaceState({}, null, url); this._startTranslateMode(); } else { - var url = window.location.href.replace(/([?&])&*enable_editor[^&#]*&?/, '\$1'); + url.searchParams.delete('enable_editor') + url.searchParams.delete('with_loader') window.history.replaceState({}, null, url); } }, @@ -147,6 +149,10 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ this.wysiwyg = await this._createWysiwyg(); await this.wysiwyg.attachTo($('#wrapwrap')); + const $loader = $('div.o_theme_install_loader_container'); + if ($loader) { + $loader.remove(); + } var res = await new Promise((resolve, reject) => { this.trigger_up('widgets_start_request', { diff --git a/addons/website/static/src/scss/website.backend.scss b/addons/website/static/src/scss/website.backend.scss index a3ec2034d62..058c779b341 100644 --- a/addons/website/static/src/scss/website.backend.scss +++ b/addons/website/static/src/scss/website.backend.scss @@ -424,18 +424,3 @@ display: none; } } - - -.o_theme_install_loader_container { - background-color: rgba($o-shadow-color, .9); - pointer-events: all; -} -.o_theme_install_loader { - position: relative; - display: inline-block; - width: 400px; - height: 220px; - background-image: url('/website/static/src/img/theme_loader.gif'); - background-size: cover; - border-radius: 6px; -} diff --git a/addons/website/static/src/scss/website.theme_install.scss b/addons/website/static/src/scss/website.theme_install.scss new file mode 100644 index 00000000000..cfa4a00cbcd --- /dev/null +++ b/addons/website/static/src/scss/website.theme_install.scss @@ -0,0 +1,15 @@ +.o_theme_install_loader_container { + background-color: rgba($o-shadow-color, .9); + pointer-events: all; + // above menu bar + z-index: $zindex-modal - 1; +} +.o_theme_install_loader { + position: relative; + display: inline-block; + width: 400px; + height: 220px; + background-image: url('/website/static/src/img/theme_loader.gif'); + background-size: cover; + border-radius: 6px; +} diff --git a/addons/website/views/assets.xml b/addons/website/views/assets.xml index b0f6c75596b..7ce8cb9c48a 100644 --- a/addons/website/views/assets.xml +++ b/addons/website/views/assets.xml @@ -35,6 +35,7 @@ +