From e756d417901b755ff2e65de97dddca06d25ee658 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Tue, 28 Mar 2023 17:24:20 +0530 Subject: [PATCH] chore: add insights banner (#20487) * chore: add insights banner * chore: cleanup message and title [skip ci] --------- Co-authored-by: Ankush Menat --- frappe/public/js/frappe/list/list_sidebar.js | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/frappe/public/js/frappe/list/list_sidebar.js b/frappe/public/js/frappe/list/list_sidebar.js index f845f3a375..fe5f0b810f 100644 --- a/frappe/public/js/frappe/list/list_sidebar.js +++ b/frappe/public/js/frappe/list/list_sidebar.js @@ -38,6 +38,8 @@ frappe.views.ListSidebar = class ListSidebar { this.reload_stats(); }); } + + this.add_insights_banner(); } setup_views() { @@ -239,4 +241,43 @@ frappe.views.ListSidebar = class ListSidebar { this.sidebar.find(".stat-no-records").remove(); this.get_stats(); } + + add_insights_banner() { + try { + if (this.list_view.view != "Report") { + return; + } + + if (localStorage.getItem("show_insights_banner") == "false") { + return; + } + + if (this.insights_banner) { + this.insights_banner.remove(); + } + + const message = "Get more insights from your data with Frappe Insights."; + const link = "https://frappe.io/s/insights"; + const cta = "Get Frappe Insights"; + + this.insights_banner = $(` +
+
+ ${message} +
+ +
+ + + +
+
+ `).appendTo(this.sidebar); + } catch (error) { + console.error(error); + } + } };