From f90d9d26a55eb4730cd700c6814c6cee73bd94d7 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 3 Dec 2025 17:56:51 -0500 Subject: [PATCH] Prefer to disable options over hiding (git panel entry context menu) (#44102) When adding the File History option here, I used the pattern to hide the option, since that's what another option was already doing here, but I see other menus in the git panel (`...`) that use disabling over hiding, which is what I think is a nicer experience (allows you to learn of actions, the full range of actions is always visible, don't have to worry about how multiple hidden items might interact in various configurations, etc). SCR-20251203-pnpy SCR-20251203-pobg In general, I think it would be good to move to being more consistent with disabling over hiding - there are other places in the app that are hiding - some might be valid, but others might just choices made on a whim. Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 1c9b817be2507f806eab505555163f72b2fd148a..62bd118daf1751e32dd0b805a773be47e19e4357 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4004,28 +4004,21 @@ impl GitPanel { "Restore File" }; let context_menu = ContextMenu::build(window, cx, |context_menu, _, _| { - let mut context_menu = context_menu + let is_created = entry.status.is_created(); + context_menu .context(self.focus_handle.clone()) .action(stage_title, ToggleStaged.boxed_clone()) - .action(restore_title, git::RestoreFile::default().boxed_clone()); - - if entry.status.is_created() { - context_menu = - context_menu.action("Add to .gitignore", git::AddToGitignore.boxed_clone()) - } - - context_menu = context_menu + .action(restore_title, git::RestoreFile::default().boxed_clone()) + .action_disabled_when( + !is_created, + "Add to .gitignore", + git::AddToGitignore.boxed_clone(), + ) .separator() .action("Open Diff", Confirm.boxed_clone()) - .action("Open File", SecondaryConfirm.boxed_clone()); - - if !entry.status.is_created() { - context_menu = context_menu - .separator() - .action("File History", Box::new(git::FileHistory)); - } - - context_menu + .action("Open File", SecondaryConfirm.boxed_clone()) + .separator() + .action_disabled_when(is_created, "File History", Box::new(git::FileHistory)) }); self.selected_entry = Some(ix); self.set_context_menu(context_menu, position, window, cx);