diff --git a/addons/website/static/src/js/content/redirect.js b/addons/website/static/src/js/content/redirect.js
index 7ef56e832c6..1e028d57ca5 100644
--- a/addons/website/static/src/js/content/redirect.js
+++ b/addons/website/static/src/js/content/redirect.js
@@ -1,8 +1,6 @@
/** @odoo-module */
import { session } from '@web/session';
-// import { _t } from "@web/core/l10n/translation"; // FIXME don't know why it does not work
-const _t = str => str;
/**
* This script, served with frontend pages, displays buttons in the top left
@@ -16,62 +14,22 @@ document.addEventListener('DOMContentLoaded', () => {
}
if (!window.frameElement) {
- const websiteId = document.documentElement.dataset.websiteId;
- const {pathname, search} = window.location;
- const params = new URLSearchParams(search);
- const enableEditor = params.get('enable_editor');
- const editTranslations = params.get('edit_translations');
- params.delete('enable_editor');
- let newSearch = params.toString();
- if (newSearch) {
- newSearch = '?' + newSearch;
+ const frontendToBackendNavEl = document.querySelector('.o_frontend_to_backend_nav');
+ if (frontendToBackendNavEl) {
+ frontendToBackendNavEl.classList.add('d-flex');
+ frontendToBackendNavEl.classList.remove('d-none');
}
- const backendPath = `/web#action=website.website_preview&path=${encodeURIComponent(`${pathname}${newSearch}`)}&website_id=${websiteId}`;
-
- const autoredirectToBackendAction = enableEditor || editTranslations;
- if (autoredirectToBackendAction) {
+ // Auto redirect to frontend if edit/translation mode is requested
+ const currentUrl = new URL(window.location.href);
+ currentUrl.pathname = `/@${currentUrl.pathname}`;
+ if (currentUrl.searchParams.get('enable_editor') || currentUrl.searchParams.get('edit_translations')) {
document.body.innerHTML = '';
- if (enableEditor) {
- window.location.replace(`${backendPath}&enable_editor=1`);
- } else if (editTranslations) {
- window.location.replace(`${backendPath}&edit_translations=1`);
- } else {
- window.location.replace(backendPath);
- }
- } else {
- // FIXME this UI does not respect access rights yet but we will
- // probably end up doing it in XML instead of JS anyway.
- const frontendToBackendBtnClasses = ['position-relative', 'd-flex', 'align-items-center', 'justify-content-center', 'text-decoration-none'];
- const frontendToBackendNavEl = document.createElement('div');
- frontendToBackendNavEl.classList.add('o_frontend_to_backend_nav', 'position-fixed', 'd-flex');
-
- const loadingIconEl = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
- loadingIconEl.classList.add('o_frontend_to_backend_icon', 'position-absolute');
- loadingIconEl.setAttribute('width', "24px");
- loadingIconEl.setAttribute('height', "24px");
- loadingIconEl.setAttribute('viewBox', "-7 -7 24 24");
- loadingIconEl.setAttribute('xmlns', "http://www.w3.org/2000/svg");
- loadingIconEl.setAttribute('preserveAspectRatio', "xMinYMin");
- loadingIconEl.innerHTML = "