fix(ux): add to desktop button on workspace

This commit is contained in:
sokumon 2026-02-03 19:52:32 +05:30
parent 5d86be2e76
commit 4eeeebc657
2 changed files with 39 additions and 0 deletions

View file

@ -320,3 +320,24 @@ def create_user_icons(user, data):
frappe.cache.hset("_user_settings", f"{'Desktop Icon'}::{user}", json.dumps(user_settings))
return json.dumps(user_settings)
return data
@frappe.whitelist()
def add_workspace_to_desktop(workspace):
sidebar = frappe.new_doc("Workspace Sidebar")
sidebar_item = frappe.new_doc("Workspace Sidebar Item")
sidebar_item.label = workspace
sidebar_item.type = "Link"
sidebar_item.link_to = workspace
sidebar_item.link_type = "Workspace"
sidebar.title = workspace
sidebar.append("items", sidebar_item)
sidebar.save()
new_icon = frappe.new_doc("Desktop Icon")
new_icon.label = workspace
new_icon.icon_type = "Link"
new_icon.link_to = workspace
new_icon.link_type = "Workspace Sidebar"
new_icon.insert()
return {"message": "Desktop Icon added successfully"}

View file

@ -8,6 +8,24 @@ frappe.ui.form.on("Workspace", {
refresh: function (frm) {
frm.enable_save();
if (frappe.app.sidebar.get_workspace_sidebars(frm.doc.title).length === 0) {
frm.add_custom_button(__("Add to Desktop"), function () {
frappe.call({
method: "frappe.desk.doctype.desktop_icon.desktop_icon.add_workspace_to_desktop",
args: {
workspace: frm.doc.name,
},
callback: function (r) {
if (r.message.status) {
frappe.toast({
message: __("Workspace added to desktop"),
indicator: "green",
});
}
},
});
});
}
let url = `/desk/${
frm.doc.public