Skip to content

Only display keyboard shortcuts in V3 (#8153) #8377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/gitbutler-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fn main() {
) {
tauri_context.config_mut().app.security.csp = updated_csp;
};
let settings_for_menu = app_settings.clone();

inherit_interactive_login_shell_environment();

Expand Down Expand Up @@ -300,7 +301,7 @@ fn main() {
#[cfg(debug_assertions)]
env::env_vars,
])
.menu(menu::build)
.menu(move |handle| menu::build(handle, &settings_for_menu))
.on_window_event(|window, event| match event {
#[cfg(target_os = "macos")]
tauri::WindowEvent::CloseRequested { .. } => {
Expand Down
31 changes: 19 additions & 12 deletions crates/gitbutler-tauri/src/menu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::{env, fs};

use crate::error::Error;
use anyhow::Context;
use but_settings::AppSettingsWithDiskSync;
use gitbutler_error::error::{self, Code};
#[cfg(target_os = "macos")]
use tauri::menu::AboutMetadata;
Expand All @@ -11,8 +13,6 @@ use tauri::{
};
use tracing::instrument;

use crate::error::Error;

static SHORTCUT_EVENT: &str = "menu://shortcut";

#[tauri::command(async)]
Expand Down Expand Up @@ -58,7 +58,10 @@ fn check_if_installed(executable_name: &str) -> bool {
}
}

pub fn build<R: Runtime>(handle: &AppHandle<R>) -> tauri::Result<tauri::menu::Menu<R>> {
pub fn build<R: Runtime>(
handle: &AppHandle<R>,
settings: &AppSettingsWithDiskSync,
) -> tauri::Result<tauri::menu::Menu<R>> {
let check_for_updates =
MenuItemBuilder::with_id("global/update", "Check for updates…").build(handle)?;

Expand Down Expand Up @@ -186,17 +189,21 @@ pub fn build<R: Runtime>(handle: &AppHandle<R>) -> tauri::Result<tauri::menu::Me
])
.build()?;

let help_menu = &SubmenuBuilder::new(handle, "Help")
let mut help_menu = SubmenuBuilder::new(handle, "Help")
.text("help/documentation", "Documentation")
.text("help/github", "Source Code")
.text("help/release-notes", "Release Notes")
.separator()
.item(
&MenuItemBuilder::with_id("help/keyboard-shortcuts", "Keyboard Shortcuts")
.accelerator("CmdOrCtrl+/")
.build(handle)?,
)
.separator()
.separator();
if settings.get()?.feature_flags.v3 {
help_menu = help_menu
.item(
&MenuItemBuilder::with_id("help/keyboard-shortcuts", "Keyboard Shortcuts")
.accelerator("CmdOrCtrl+/")
.build(handle)?,
)
.separator();
};
let help_menu = help_menu
.text("help/share-debug-info", "Share Debug Info…")
.text("help/report-issue", "Report an Issue…")
.separator()
Expand Down Expand Up @@ -226,7 +233,7 @@ pub fn build<R: Runtime>(handle: &AppHandle<R>) -> tauri::Result<tauri::menu::Me
project_menu,
#[cfg(target_os = "macos")]
window_menu,
help_menu,
&help_menu,
],
)
}
Expand Down
Loading