Skip to content

[IMP] website: show welcome message on homepage #4609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/html_builder/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
],
'web.assets_frontend': [
'html_builder/static/src/interactions/**/*',
'html_builder/static/src/website_preview/website_builder_action.editor.scss',
('remove', 'html_builder/static/src/interactions/**/*.edit.*'),
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_homepage_editor_welcome_message {
font-family: $o-font-family-sans-serif;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
onMounted,
onWillDestroy,
onWillStart,
useEffect,
useRef,
useState,
useSubEnv,
Expand All @@ -22,6 +23,7 @@ import { AddPageDialog } from "@website/components/dialog/add_page_dialog";
import { ResourceEditor } from "@website/components/resource_editor/resource_editor";
import { isHTTPSorNakedDomainRedirection } from "./utils";
import { WebsiteSystrayItem } from "./website_systray_item";
import { renderToElement } from "@web/core/utils/render";

export class WebsiteBuilder extends Component {
static template = "html_builder.WebsiteBuilder";
Expand Down Expand Up @@ -66,7 +68,13 @@ export class WebsiteBuilder extends Component {
useSubEnv({
localOverlayContainerKey: uniqueId("website"),
});

useEffect(
() => {
this.addWelcomeMessage();
return () => this.welcomeMessageEl?.remove();
},
() => [this.state.isEditing]
);
this.websitePreviewRef = useRef("website_preview");

onWillStart(async () => {
Expand Down Expand Up @@ -368,6 +376,19 @@ export class WebsiteBuilder extends Component {
);
}

async addWelcomeMessage() {
await this.iframeLoaded;
if (this.websiteService.isRestrictedEditor && !this.state.isEditing) {
const wrapEl = this.websiteContent.el.contentDocument.querySelector(
"#wrapwrap.homepage #wrap"
);
if (wrapEl && !wrapEl.innerHTML.trim()) {
this.welcomeMessageEl = renderToElement("website.homepage_editor_welcome_message");
wrapEl.replaceChildren(this.welcomeMessageEl);
}
}
}

setIframeLoaded() {
this.iframeLoaded = new Promise((resolve) => {
this.resolveIframeLoaded = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@
</div>
</t>

<t t-name="website.homepage_editor_welcome_message">
<div class="container o_homepage_editor_welcome_message text-center pt128 pb128 h-100">
<h2 class="mt0">Welcome to your <b>Homepage</b>!</h2>
<p class="lead d-none d-md-block">Click on <b>Edit</b> in the top right corner to start designing.</p>
</div>
</t>
</templates>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ registry.category("web_tour.tours").add('skip_website_configurator', {
},
{
content: "Check that the homepage is loaded",
trigger: ".o_website_preview[data-view-xmlid='website.homepage']",
trigger: ".o_website_preview :iframe html[data-view-xmlid='website.homepage']",
timeout: 30000,
},
{
Expand Down
1 change: 0 additions & 1 deletion addons/website/tests/test_skip_website_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@tagged('post_install', '-at_install')
class TestAutomaticEditor(TestConfiguratorCommon):

@unittest.skip
def test_skip_website_configurator(self):
# If not enabled (like in demo data), landing on res.config will try
# to disable module_sale_quotation_builder and raise an issue
Expand Down