refactor: move navbar and help items to hooks

This commit is contained in:
barredterra 2023-10-15 19:23:44 +02:00
parent e9629bc04e
commit e212cad44e
2 changed files with 79 additions and 79 deletions

View file

@ -442,3 +442,80 @@ extend_bootinfo = [
]
export_python_type_annotations = True
standard_navbar_items = [
{
"item_label": "My Profile",
"item_type": "Route",
"route": "/app/user-profile",
"is_standard": 1,
},
{
"item_label": "My Settings",
"item_type": "Action",
"action": "frappe.ui.toolbar.route_to_user()",
"is_standard": 1,
},
{
"item_label": "Session Defaults",
"item_type": "Action",
"action": "frappe.ui.toolbar.setup_session_defaults()",
"is_standard": 1,
},
{
"item_label": "Reload",
"item_type": "Action",
"action": "frappe.ui.toolbar.clear_cache()",
"is_standard": 1,
},
{
"item_label": "View Website",
"item_type": "Action",
"action": "frappe.ui.toolbar.view_website()",
"is_standard": 1,
},
{
"item_label": "Toggle Full Width",
"item_type": "Action",
"action": "frappe.ui.toolbar.toggle_full_width()",
"is_standard": 1,
},
{
"item_label": "Toggle Theme",
"item_type": "Action",
"action": "new frappe.ui.ThemeSwitcher().show()",
"is_standard": 1,
},
{
"item_type": "Separator",
"is_standard": 1,
"item_label": "",
},
{
"item_label": "Log out",
"item_type": "Action",
"action": "frappe.app.logout()",
"is_standard": 1,
},
]
standard_help_items = [
{
"item_label": "About",
"item_type": "Action",
"action": "frappe.ui.toolbar.show_about()",
"is_standard": 1,
},
{
"item_label": "Keyboard Shortcuts",
"item_type": "Action",
"action": "frappe.ui.toolbar.show_shortcuts(event)",
"is_standard": 1,
},
{
"item_label": "Frappe Support",
"item_type": "Route",
"route": "https://frappe.io/support",
"is_standard": 1,
},
]

View file

@ -197,90 +197,13 @@ def add_standard_navbar_items():
if navbar_settings.settings_dropdown and navbar_settings.help_dropdown:
return
standard_navbar_items = [
{
"item_label": "My Profile",
"item_type": "Route",
"route": "/app/user-profile",
"is_standard": 1,
},
{
"item_label": "My Settings",
"item_type": "Action",
"action": "frappe.ui.toolbar.route_to_user()",
"is_standard": 1,
},
{
"item_label": "Session Defaults",
"item_type": "Action",
"action": "frappe.ui.toolbar.setup_session_defaults()",
"is_standard": 1,
},
{
"item_label": "Reload",
"item_type": "Action",
"action": "frappe.ui.toolbar.clear_cache()",
"is_standard": 1,
},
{
"item_label": "View Website",
"item_type": "Action",
"action": "frappe.ui.toolbar.view_website()",
"is_standard": 1,
},
{
"item_label": "Toggle Full Width",
"item_type": "Action",
"action": "frappe.ui.toolbar.toggle_full_width()",
"is_standard": 1,
},
{
"item_label": "Toggle Theme",
"item_type": "Action",
"action": "new frappe.ui.ThemeSwitcher().show()",
"is_standard": 1,
},
{
"item_type": "Separator",
"is_standard": 1,
"item_label": "",
},
{
"item_label": "Log out",
"item_type": "Action",
"action": "frappe.app.logout()",
"is_standard": 1,
},
]
standard_help_items = [
{
"item_label": "About",
"item_type": "Action",
"action": "frappe.ui.toolbar.show_about()",
"is_standard": 1,
},
{
"item_label": "Keyboard Shortcuts",
"item_type": "Action",
"action": "frappe.ui.toolbar.show_shortcuts(event)",
"is_standard": 1,
},
{
"item_label": "Frappe Support",
"item_type": "Route",
"route": "https://frappe.io/support",
"is_standard": 1,
},
]
navbar_settings.settings_dropdown = []
navbar_settings.help_dropdown = []
for item in standard_navbar_items:
for item in frappe.get_hooks("standard_navbar_items"):
navbar_settings.append("settings_dropdown", item)
for item in standard_help_items:
for item in frappe.get_hooks("standard_help_items"):
navbar_settings.append("help_dropdown", item)
navbar_settings.save()