From 131d8615b7cf0432be06ba216bad9ce265537ad7 Mon Sep 17 00:00:00 2001 From: sokumon Date: Tue, 28 Oct 2025 02:47:28 +0530 Subject: [PATCH] fix: add support for adding external urls as sidebar items --- frappe/boot.py | 1 + .../workspace_sidebar_item.json | 13 ++++++++++--- .../workspace_sidebar_item.py | 3 ++- frappe/public/icons/timeless/icons.svg | 5 +++++ .../public/js/frappe/ui/sidebar/sidebar_item.html | 2 +- frappe/public/js/frappe/ui/sidebar/sidebar_item.js | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index f5ced18cfd..c946154521 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -543,6 +543,7 @@ def get_sidebar_items(): "indent": si.indent, "keep_closed": si.keep_closed, "display_depends_on": si.display_depends_on, + "url": si.url, } if si.link_type == "Report": report_type, ref_doctype = frappe.db.get_value( diff --git a/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.json b/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.json index f8a8ed5482..4d30a13fa5 100644 --- a/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.json +++ b/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.json @@ -13,6 +13,7 @@ "type", "link_to", "child", + "url", "display_section", "collapsible_column", "collapsible", @@ -43,10 +44,10 @@ "fieldtype": "Select", "in_list_view": 1, "label": "Link Type", - "options": "DocType\nPage\nReport\nWorkspace\nDashboard" + "options": "DocType\nPage\nReport\nWorkspace\nDashboard\nURL" }, { - "depends_on": "eval: doc.type == 'Link' || doc.indent == 1", + "depends_on": "eval: doc.link_type != \"URL\" && doc.type == 'Link' || doc.indent == 1", "fieldname": "link_to", "fieldtype": "Dynamic Link", "in_list_view": 1, @@ -119,13 +120,19 @@ "label": "Display Depends On (JS)", "options": "JS", "width": "30" + }, + { + "depends_on": "eval: doc.link_type == \"URL\"", + "fieldname": "url", + "fieldtype": "Data", + "label": "URL" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-10-27 23:53:14.138033", + "modified": "2025-10-28 02:05:07.887104", "modified_by": "Administrator", "module": "Desk", "name": "Workspace Sidebar Item", diff --git a/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.py b/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.py index e80aeca427..9dc7c17bda 100644 --- a/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.py +++ b/frappe/desk/doctype/workspace_sidebar_item/workspace_sidebar_item.py @@ -21,11 +21,12 @@ class WorkspaceSidebarItem(Document): keep_closed: DF.Check label: DF.Data | None link_to: DF.DynamicLink | None - link_type: DF.Literal["DocType", "Page", "Report", "Workspace", "Dashboard"] + link_type: DF.Literal["DocType", "Page", "Report", "Workspace", "Dashboard", "URL"] parent: DF.Data parentfield: DF.Data parenttype: DF.Data type: DF.Literal["Link", "Section Break", "Spacer"] + url: DF.Data | None # end: auto-generated types pass diff --git a/frappe/public/icons/timeless/icons.svg b/frappe/public/icons/timeless/icons.svg index e9bf016560..c92a93c31c 100644 --- a/frappe/public/icons/timeless/icons.svg +++ b/frappe/public/icons/timeless/icons.svg @@ -223,6 +223,11 @@ Tip: use lucide.svg in /icons for all downloaded icons + + + + + diff --git a/frappe/public/js/frappe/ui/sidebar/sidebar_item.html b/frappe/public/js/frappe/ui/sidebar/sidebar_item.html index d3119981be..2673f8f7c5 100644 --- a/frappe/public/js/frappe/ui/sidebar/sidebar_item.html +++ b/frappe/public/js/frappe/ui/sidebar/sidebar_item.html @@ -17,7 +17,7 @@ {% } else { %} diff --git a/frappe/public/js/frappe/ui/sidebar/sidebar_item.js b/frappe/public/js/frappe/ui/sidebar/sidebar_item.js index 330f33b595..9fbd04e54f 100644 --- a/frappe/public/js/frappe/ui/sidebar/sidebar_item.js +++ b/frappe/public/js/frappe/ui/sidebar/sidebar_item.js @@ -30,14 +30,14 @@ frappe.ui.sidebar_item.TypeLink = class SidebarItem { if (this.item.route) { path = this.item.route; } + } else if (this.item.link_type === "URL") { + path = this.item.url; } else { path = frappe.utils.generate_route({ type: this.item.link_type, name: this.item.link_to, }); } - } else if (this.item.type === "URL") { - path = this.item.external_link; } return path; }