From fa06586cdf41c37fc47ad760ae86d44964382938 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 16 Apr 2024 16:43:22 +0200 Subject: [PATCH] fix devtools on release builds --- .github/workflows/push.yaml | 1 + crates/gitbutler-tauri/src/menu.rs | 39 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index f1dd0c731..c047cf6f9 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -115,6 +115,7 @@ jobs: - check-tests features: - '' + - [devtools] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/check-crate diff --git a/crates/gitbutler-tauri/src/menu.rs b/crates/gitbutler-tauri/src/menu.rs index eff2d2f54..d6e1e0802 100644 --- a/crates/gitbutler-tauri/src/menu.rs +++ b/crates/gitbutler-tauri/src/menu.rs @@ -31,26 +31,30 @@ pub async fn menu_item_set_enabled( } pub fn build(package_info: &PackageInfo) -> Menu { + #[allow(unused_mut)] let mut menu = Menu::os_default(&package_info.name).add_submenu(Submenu::new( "Project", Menu::with_items([disabled_menu_item("project/settings", "Project Settings")]), )); - // Try to find the View menu and attach the dev tools item - let view_menu = menu.items.iter_mut().find(|item| match item { - MenuEntry::CustomItem(_) => false, - MenuEntry::Submenu(submenu) => submenu.title == "View", - MenuEntry::NativeItem(_) => false, - }); + #[cfg(any(debug_assertions, feature = "devtools"))] + { + // Try to find the View menu and attach the dev tools item + let view_menu = menu.items.iter_mut().find(|item| match item { + MenuEntry::CustomItem(_) => false, + MenuEntry::Submenu(submenu) => submenu.title == "View", + MenuEntry::NativeItem(_) => false, + }); - let devtools = CustomMenuItem::new("view/devtools", "Developer Tools"); - if let Some(MenuEntry::Submenu(view_menu)) = view_menu { - view_menu.inner.items.push(devtools.into()); - } else { - menu = menu.add_submenu(Submenu::new( - "Developer", - Menu::with_items([devtools.into()]), - )); + let devtools = CustomMenuItem::new("view/devtools", "Developer Tools"); + if let Some(MenuEntry::Submenu(view_menu)) = view_menu { + view_menu.inner.items.push(devtools.into()); + } else { + menu = menu.add_submenu(Submenu::new( + "Developer", + Menu::with_items([devtools.into()]), + )); + } } menu @@ -63,8 +67,11 @@ fn disabled_menu_item(id: &str, title: &str) -> MenuEntry { } pub fn handle_event(event: &WindowMenuEvent) { - if event.menu_item_id() == "view/devtools" { - event.window().open_devtools(); + #[cfg(any(debug_assertions, feature = "devtools"))] + { + if event.menu_item_id() == "view/devtools" { + event.window().open_devtools(); + } } emit( event.window(),