Skip to content

Delete dead code (mysterious-egg / website) #4578

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

Open
wants to merge 1 commit into
base: master-mysterious-egg
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { ResourceEditor } from "@website/components/resource_editor/resource_edi
import { isHTTPSorNakedDomainRedirection } from "./utils";
import { WebsiteSystrayItem } from "./website_systray_item";

const websiteSystrayRegistry = registry.category("website_systray");

export class WebsiteBuilder extends Component {
static template = "html_builder.WebsiteBuilder";
static components = { LazyComponent, LocalOverlayContainer, ResizablePanel, ResourceEditor };
Expand Down Expand Up @@ -64,9 +66,6 @@ export class WebsiteBuilder extends Component {
[this.websiteContext]
);
});
// TODO: to remove: this is only needed to not use the website systray
// when using the "website preview" app.
this.websiteService.useMysterious = true;
this.translation = !!this.props.action.context.params?.edit_translations;

this.overlayRef = useChildRef();
Expand Down Expand Up @@ -112,9 +111,9 @@ export class WebsiteBuilder extends Component {
});
this.publicRootReady = new Deferred();
this.setIframeLoaded();
this.addSystrayItems();
onWillDestroy(() => {
registry.category("systray").remove("website.WebsiteSystrayItem");
this.websiteService.useMysterious = false;
websiteSystrayRegistry.remove("website.WebsiteSystrayItem");
this.websiteService.currentWebsiteId = null;
});

Expand All @@ -132,7 +131,8 @@ export class WebsiteBuilder extends Component {
document.querySelector("body").classList.toggle("o_builder_open", isEditing);
if (isEditing) {
setTimeout(() => {
registry.category("systray").remove("website.WebsiteSystrayItem");
websiteSystrayRegistry.remove("website.WebsiteSystrayItem");
websiteSystrayRegistry.trigger("EDIT-WEBSITE");
}, 200);
}
},
Expand Down Expand Up @@ -165,14 +165,12 @@ export class WebsiteBuilder extends Component {
}

addSystrayItems() {
if (!registry.category("systray").contains("website.WebsiteSystrayItem")) {
registry
.category("systray")
.add(
"website.WebsiteSystrayItem",
{ Component: WebsiteSystrayItem, props: this.systrayProps },
{ sequence: -100 }
);
if (!websiteSystrayRegistry.contains("website.WebsiteSystrayItem")) {
websiteSystrayRegistry.add(
"website.WebsiteSystrayItem",
{ Component: WebsiteSystrayItem, props: this.systrayProps },
{ sequence: -100 }
);
}
}

Expand Down Expand Up @@ -359,6 +357,7 @@ export class WebsiteBuilder extends Component {

async reloadIframeAndCloseEditor() {
const isEditing = false;
this.addSystrayItems();
await this.reloadIframe(isEditing);
this.state.isEditing = isEditing;
}
Expand Down
3 changes: 2 additions & 1 deletion addons/html_builder/static/tests/snippets_menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ test("open BuilderSidebar and discard", async () => {
expect(".o_menu_systray .o-website-btn-custo-primary").toHaveCount(0);
await click(".o-snippets-top-actions button:contains(Discard)");
await websiteBuilder.iframeLoaded;
await animationFrame();
await animationFrame(); // WebsiteBuilder out of edit mode
await animationFrame(); // Navbar systray items updated
expect(".o_menu_systray .o-website-btn-custo-primary").toHaveCount(1);
});

Expand Down
22 changes: 10 additions & 12 deletions addons/website/static/src/components/navbar/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ patch(NavBar.prototype, {
},

get shouldDisplayWebsiteSystray() {
return this.websiteService.currentWebsite && this.websiteService.isRestrictedEditor && !this.websiteService.useMysterious;
return this.websiteService.currentWebsite && this.websiteService.isRestrictedEditor;
},

// Somehow a setter is needed in `patch()` to avoid an owl error.
Expand All @@ -55,17 +55,15 @@ patch(NavBar.prototype, {
* @override
*/
get systrayItems() {
if (this.shouldDisplayWebsiteSystray) {
const websiteItems = websiteSystrayRegistry
.getEntries()
.map(([key, value], index) => ({ key, ...value, index }))
.filter((item) => ('isDisplayed' in item ? item.isDisplayed(this.env) : true))
.reverse();
// Do not override the regular Odoo navbar if the only visible
// elements are the debug items.
if (!websiteItems.every((item) => ['burger_menu', 'web.debug_mode_menu'].includes(item.key))) {
return websiteItems;
}
const websiteItems = websiteSystrayRegistry
.getEntries()
.map(([key, value], index) => ({ key, ...value, index }))
.filter((item) => ('isDisplayed' in item ? item.isDisplayed(this.env) : true))
.reverse();
// Do not override the regular Odoo navbar if the only visible
// elements are the debug items.
if (!websiteItems.every((item) => ['burger_menu', 'web.debug_mode_menu'].includes(item.key))) {
return websiteItems;
}
return super.systrayItems;
},
Expand Down
2 changes: 1 addition & 1 deletion addons/website/static/src/services/website_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const websiteService = {
invalidateSnippetCache = value;
},

goToWebsite({ websiteId, path, edition, translation, lang, htmlBuilder=false } = {}) {
goToWebsite({ websiteId, path, edition, translation, lang } = {}) {
this.websiteRootInstance = undefined;
if (lang) {
invalidateSnippetCache = true;
Expand Down
40 changes: 0 additions & 40 deletions addons/website/static/src/systray_items/edit_in_backend.js

This file was deleted.

12 changes: 0 additions & 12 deletions addons/website/static/src/systray_items/edit_in_backend.xml

This file was deleted.

120 changes: 0 additions & 120 deletions addons/website/static/src/systray_items/edit_website.js

This file was deleted.

42 changes: 0 additions & 42 deletions addons/website/static/src/systray_items/edit_website.xml

This file was deleted.

19 changes: 0 additions & 19 deletions addons/website/static/src/systray_items/mobile_preview.js

This file was deleted.

12 changes: 0 additions & 12 deletions addons/website/static/src/systray_items/mobile_preview.xml

This file was deleted.

Loading