From 0ce1455aac7d95154b92daa98fb8ffbf27d12f1a Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Mon, 26 May 2025 15:55:04 +0200 Subject: [PATCH] [FIX] theme_test_custo: adapt design themes to the new website builder Since [this commit], the website builder has been rewritten. Due to it, `we-` options are deprecated. This commit adapts all the `xpath` to old options into the new way of doing. This commit also adapts the `theme_menu_hierarchies` tour for it to work with the new builder. [this commit]: https://github.com/odoo/odoo/commit/9fe45e2b7ddbbfd0445ffe25a859e67a316d02b2 Related to task-4367641 runbot-223813 runbot-223815 closes odoo/design-themes#1087 Related: odoo/odoo#211725 Signed-off-by: Quentin Smetz (qsm) --- theme_test_custo/__manifest__.py | 3 +++ theme_test_custo/data/shapes.xml | 17 ------------- .../builder/background_shape_option_plugin.js | 20 ++++++++++++++++ .../static/src/builder/footer.xml | 15 ++++++++++++ .../static/src/builder/header.xml | 24 +++++++++++++++++++ .../src/builder/image_shape_option_plugin.js | 20 ++++++++++++++++ .../tests/tours/theme_menu_hierarchies.js | 8 +++---- theme_test_custo/views/footer.xml | 10 -------- theme_test_custo/views/header.xml | 10 -------- 9 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 theme_test_custo/static/src/builder/background_shape_option_plugin.js create mode 100644 theme_test_custo/static/src/builder/footer.xml create mode 100644 theme_test_custo/static/src/builder/header.xml create mode 100644 theme_test_custo/static/src/builder/image_shape_option_plugin.js diff --git a/theme_test_custo/__manifest__.py b/theme_test_custo/__manifest__.py index 369226ea3..c2753cf27 100644 --- a/theme_test_custo/__manifest__.py +++ b/theme_test_custo/__manifest__.py @@ -16,6 +16,9 @@ 'web.assets_tests': [ 'theme_test_custo/static/tests/tours/**/*', ], + 'html_builder.assets': [ + 'theme_test_custo/static/src/builder/**/*', + ], }, 'author': 'Odoo S.A.', 'license': 'LGPL-3', diff --git a/theme_test_custo/data/shapes.xml b/theme_test_custo/data/shapes.xml index b351b312a..8175ecaf2 100644 --- a/theme_test_custo/data/shapes.xml +++ b/theme_test_custo/data/shapes.xml @@ -2,15 +2,6 @@ - Hexagon Shape 01 theme_test_custo.shape_hexagon_01 @@ -23,14 +14,6 @@ - Blob Shape 01 theme_test_custo.img_shape_blob_01 diff --git a/theme_test_custo/static/src/builder/background_shape_option_plugin.js b/theme_test_custo/static/src/builder/background_shape_option_plugin.js new file mode 100644 index 000000000..485b52429 --- /dev/null +++ b/theme_test_custo/static/src/builder/background_shape_option_plugin.js @@ -0,0 +1,20 @@ +import { BackgroundShapeOptionPlugin } from "@website/builder/plugins/background_option/background_shape_option_plugin"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; + +patch(BackgroundShapeOptionPlugin.prototype, { + getBackgroundShapeGroups() { + const bgShapeGroups = super.getBackgroundShapeGroups(); + bgShapeGroups.basic.subgroups["custom_shape"] = { + label: "Custom Shapes", + shapes: { + "theme_test_custo/curves/01": { + selectLabel: _t("Curve 01"), + transform: false, + togglableRatio: true, + }, + }, + }; + return bgShapeGroups; + }, +}); diff --git a/theme_test_custo/static/src/builder/footer.xml b/theme_test_custo/static/src/builder/footer.xml new file mode 100644 index 000000000..1925e08e8 --- /dev/null +++ b/theme_test_custo/static/src/builder/footer.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/theme_test_custo/static/src/builder/header.xml b/theme_test_custo/static/src/builder/header.xml new file mode 100644 index 000000000..6dff00655 --- /dev/null +++ b/theme_test_custo/static/src/builder/header.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/theme_test_custo/static/src/builder/image_shape_option_plugin.js b/theme_test_custo/static/src/builder/image_shape_option_plugin.js new file mode 100644 index 000000000..fedc9e823 --- /dev/null +++ b/theme_test_custo/static/src/builder/image_shape_option_plugin.js @@ -0,0 +1,20 @@ +import { ImageShapeOptionPlugin } from "@website/builder/plugins/image/image_shape_option_plugin"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; + +patch(ImageShapeOptionPlugin.prototype, { + getImageShapeGroups() { + const imageShapeGroups = super.getImageShapeGroups(); + imageShapeGroups.basic.subgroups["custom_shape"] = { + label: "Custom Shapes", + shapes: { + "theme_test_custo/blob/01": { + selectLabel: _t("Blob 01"), + transform: false, + togglableRatio: true, + }, + }, + }; + return imageShapeGroups; + }, +}); diff --git a/theme_test_custo/static/tests/tours/theme_menu_hierarchies.js b/theme_test_custo/static/tests/tours/theme_menu_hierarchies.js index 52a671879..3c6b55d46 100644 --- a/theme_test_custo/static/tests/tours/theme_menu_hierarchies.js +++ b/theme_test_custo/static/tests/tours/theme_menu_hierarchies.js @@ -39,7 +39,7 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', { run: "click", }, { content: 'The theme custom footer template should be listed and selected', - trigger: 'we-select[data-variable="footer-template"] we-toggler img[src*="/theme_test_custo"]', + trigger: '[data-container-title="Footer"] [data-label="Template"] button.btn-primary img[src*="/theme_test_custo"]', run: () => null, // It's a check. }, { content: 'Click on header', @@ -47,7 +47,7 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', { run: "click", }, { content: 'The theme custom header template should be listed and selected', - trigger: 'we-select[data-variable="header-template"] we-toggler img[src*="/theme_test_custo"]', + trigger: '[data-container-title="Header"] [data-label="Template"] button.btn-primary img[src*="/theme_test_custo"]', run: () => null, // It's a check. }, { content: 'Click on image which has a shape', @@ -55,7 +55,7 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', { run: "click", }, { content: 'The theme custom "Blob 01" shape should be listed and selected', - trigger: 'we-select[data-name="shape_img_opt"] we-toggler:contains("Blob 01")', + trigger: '[data-container-title="Image"] [data-label="Shape"] div.dropdown:contains("Blob 01")', run: () => null, // It's a check. }, { content: 'Click on section which has a bg shape', @@ -63,7 +63,7 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', { run: "click", }, { content: 'The theme custom "Curve 01" shape should be listed and selected', - trigger: 'we-select[data-name="bg_shape_opt"] we-toggler:contains("Curve 01")', + trigger: '[data-container-title="Text"] [data-label="Shape"] button.btn-primary:contains("Curve 01")', run: () => null, // It's a check. }, ]); diff --git a/theme_test_custo/views/footer.xml b/theme_test_custo/views/footer.xml index 1e1d24cef..df2c0acad 100644 --- a/theme_test_custo/views/footer.xml +++ b/theme_test_custo/views/footer.xml @@ -1,16 +1,6 @@ - - -