Don't render "Initialize Repository" button when no worktrees (#26713)

Closes #26676  

Release Notes:

- Fixed the git panel to not show an "Initialize Repositories" button in
empty projects
This commit is contained in:
Cole Miller 2025-03-13 16:17:23 -04:00 committed by GitHub
parent f3703fa8be
commit a7f3b22051
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3048,7 +3048,9 @@ impl GitPanel {
"No Git repositories" "No Git repositories"
}, },
)) ))
.children(self.active_repository.is_none().then(|| { .children({
let worktree_count = self.project.read(cx).visible_worktrees(cx).count();
(worktree_count > 0 && self.active_repository.is_none()).then(|| {
h_flex().w_full().justify_around().child( h_flex().w_full().justify_around().child(
panel_filled_button("Initialize Repository") panel_filled_button("Initialize Repository")
.tooltip(Tooltip::for_action_title_in( .tooltip(Tooltip::for_action_title_in(
@ -3062,7 +3064,8 @@ impl GitPanel {
}) })
}), }),
) )
})) })
})
.text_ui_sm(cx) .text_ui_sm(cx)
.mx_auto() .mx_auto()
.text_color(Color::Placeholder.color(cx)), .text_color(Color::Placeholder.color(cx)),