fix: customize sidebar header via standard navbar_items hook

This commit is contained in:
sokumon 2026-03-05 11:34:17 +05:30
parent 7933a201dd
commit fa822b31d4
2 changed files with 20 additions and 7 deletions

View file

@ -46,15 +46,22 @@ frappe.ui.menu = class ContextMenu {
make() {
this.template.empty();
this.menu_items_to_show = [];
this.menu_items.forEach((f) => {
f.condition =
f.condition ||
this.menu_items.forEach((item) => {
item.condition =
item.condition ||
function () {
return true;
};
if (f.condition()) {
this.add_menu_item(f);
this.menu_items_to_show.push(f);
console.log(typeof item.condition);
let render = false;
if (typeof item.condition == "function") {
render = item.condition();
} else {
render = frappe.utils.eval_expression(item.condition);
}
if (render) {
this.add_menu_item(item);
this.menu_items_to_show.push(item);
}
});

View file

@ -87,12 +87,18 @@ frappe.ui.SidebarHeader = class SidebarHeader {
}
);
}
this.add_navbar_items();
this.make();
this.setup_app_switcher();
this.populate_dropdown_menu();
this.setup_select_options();
}
add_navbar_items() {
frappe.boot.navbar_settings.settings_dropdown.forEach((item) => {
item.label = item.item_label;
this.dropdown_items.push(item);
});
}
fetch_related_icons() {
let sibling_workspaces = [];
let workspaces_not_to_show = ["My Workspaces"];