From 6aac2bec6f1249fe687cb372218f229b3438ccb7 Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Mon, 11 Apr 2022 11:23:33 +0200 Subject: [PATCH] [IMP] website_links: add link tracker menu item See merge commit for more information. task-2687506 --- addons/website_links/__manifest__.py | 6 +-- .../static/src/components/navbar/navbar.js | 38 +++++++------------ .../views/link_tracker_views.xml | 6 +++ 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/addons/website_links/__manifest__.py b/addons/website_links/__manifest__.py index 2af6b989591..a984667b483 100644 --- a/addons/website_links/__manifest__.py +++ b/addons/website_links/__manifest__.py @@ -22,12 +22,12 @@ Those trackers can be used in Google Analytics to track clicks and visitors, or 'website_links/static/src/js/website_links_charts.js', 'website_links/static/src/css/website_links.css', ], + 'web.assets_backend': [ + 'website_links/static/src/components/navbar/navbar.js', + ], 'web.assets_tests': [ 'website_links/static/tests/**/*', ], - 'website.assets_editor': [ - 'website_links/static/src/components/navbar/navbar.js', - ], 'web.assets_qweb': [ 'website_links/static/src/xml/*.xml', ], diff --git a/addons/website_links/static/src/components/navbar/navbar.js b/addons/website_links/static/src/components/navbar/navbar.js index b76b3615302..17e1d9dfc0c 100644 --- a/addons/website_links/static/src/components/navbar/navbar.js +++ b/addons/website_links/static/src/components/navbar/navbar.js @@ -1,30 +1,20 @@ -/** - * The purpose of this script is to copy the current URL of the website - * into the URL form of the URL shortener (module website_links) - * when the user clicks the link "Share this page" on top of the page. - */ +/** @odoo-module */ -odoo.define('website_links.website_links_menu', function (require) { -'use strict'; +import { patch } from 'web.utils'; +import { NavBar } from '@web/webclient/navbar/navbar'; -var publicWidget = require('web.public.widget'); +const { onWillStart } = owl; -const { registry } = require("@web/core/registry"); +patch(NavBar.prototype, 'website_links_navbar', { + setup() { + this._super(); -var WebsiteLinksMenu = publicWidget.Widget.extend({ - - /** - * @override - */ - start: function () { - this.$el.attr('href', '/r?u=' + encodeURIComponent(window.location.href)); - return this._super.apply(this, arguments); + onWillStart(() => { + this.websiteEditingMenus['website_links.menu_link_tracker'] = { + openWidget: () => this.websiteService.goToWebsite({ path: `/r?u=${encodeURIComponent(this.websiteService.contentWindow.location.href)}` }), + isDisplayed: () => this.websiteService.currentWebsite, + options: () => {}, + }; + }); }, }); - -registry.category("website_navbar_widgets").add("WebsiteLinksMenu", { - Widget: WebsiteLinksMenu, - selector: '#o_website_links_share_page', -}); - -}); diff --git a/addons/website_links/views/link_tracker_views.xml b/addons/website_links/views/link_tracker_views.xml index 9649f474dc3..f779704d266 100644 --- a/addons/website_links/views/link_tracker_views.xml +++ b/addons/website_links/views/link_tracker_views.xml @@ -10,4 +10,10 @@ + +