git_ui: Git panel polish (#25164)

- Hides header when no active repo/no repo
- Entire commit editor now has i-beam cursor on hover
- Adds an icon to the project diff tab

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2025-02-19 10:33:41 -05:00 committed by GitHub
parent c0c48d30db
commit 086f002f44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 13 deletions

View file

@ -1539,7 +1539,7 @@ impl GitPanel {
&self,
window: &mut Window,
cx: &mut Context<Self>,
) -> impl IntoElement {
) -> Option<impl IntoElement> {
let all_repositories = self
.project
.read(cx)
@ -1554,17 +1554,21 @@ impl GitPanel {
.is_above_project()
});
self.panel_header_container(window, cx).when(
all_repositories.len() > 1 || has_repo_above,
|el| {
el.child(
Label::new("Repository")
.size(LabelSize::Small)
.color(Color::Muted),
)
.child(self.render_repository_selector(cx))
},
)
let has_visible_repo = all_repositories.len() > 0 || has_repo_above;
if has_visible_repo {
Some(
self.panel_header_container(window, cx)
.child(
Label::new("Repository")
.size(LabelSize::Small)
.color(Color::Muted),
)
.child(self.render_repository_selector(cx)),
)
} else {
None
}
}
pub fn render_repository_selector(&self, cx: &mut Context<Self>) -> impl IntoElement {
@ -1690,6 +1694,7 @@ impl GitPanel {
.border_t_1()
.border_color(cx.theme().colors().border)
.bg(cx.theme().colors().editor_background)
.cursor_text()
.on_click(cx.listener(move |_, _: &ClickEvent, window, _cx| {
window.focus(&editor_focus_handle);
}))
@ -2260,7 +2265,7 @@ impl Render for GitPanel {
.size_full()
.overflow_hidden()
.bg(ElevationIndex::Surface.bg(cx))
.child(self.render_panel_header(window, cx))
.children(self.render_panel_header(window, cx))
.child(if has_entries {
self.render_entries(has_write_access, window, cx)
.into_any_element()

View file

@ -386,6 +386,10 @@ impl Focusable for ProjectDiff {
impl Item for ProjectDiff {
type Event = EditorEvent;
fn tab_icon(&self, _window: &Window, _cx: &App) -> Option<Icon> {
Some(Icon::new(IconName::GitBranch).color(Color::Muted))
}
fn to_item_events(event: &EditorEvent, f: impl FnMut(ItemEvent)) {
Editor::to_item_events(event, f)
}