From e212cad44e8e12279a8cd40edfedabd2399eb60c Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sun, 15 Oct 2023 19:23:44 +0200 Subject: [PATCH] refactor: move navbar and help items to hooks --- frappe/hooks.py | 77 +++++++++++++++++++++++++++++++++++++++ frappe/utils/install.py | 81 +---------------------------------------- 2 files changed, 79 insertions(+), 79 deletions(-) diff --git a/frappe/hooks.py b/frappe/hooks.py index 60941df10d..746a0929f1 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -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, + }, +] diff --git a/frappe/utils/install.py b/frappe/utils/install.py index df918c27e0..a8e1f0e788 100644 --- a/frappe/utils/install.py +++ b/frappe/utils/install.py @@ -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()