Skip to content
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

Show git items in the panel only when in a git repository #24865

Merged
merged 9 commits into from
Feb 21, 2025
17 changes: 12 additions & 5 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,11 @@ impl GitPanel {
let Some(entry) = self.entries.get(ix).and_then(|e| e.status_entry()) else {
return;
};
let stage_title = if entry.status.is_staged() == Some(true) {
"Unstage File"
} else {
"Stage File"
};
let revert_title = if entry.status.is_deleted() {
"Restore file"
} else if entry.status.is_created() {
Expand All @@ -2068,7 +2073,7 @@ impl GitPanel {
};
let context_menu = ContextMenu::build(window, cx, |context_menu, _, _| {
context_menu
.action("Stage File", ToggleStaged.boxed_clone())
.action(stage_title, ToggleStaged.boxed_clone())
.action(revert_title, git::RestoreFile.boxed_clone())
.separator()
.action("Open Diff", Confirm.boxed_clone())
Expand Down Expand Up @@ -2312,15 +2317,17 @@ impl Render for GitPanel {
.size_full()
.overflow_hidden()
.bg(ElevationIndex::Surface.bg(cx))
.children(self.render_panel_header(window, cx))
.child(if has_entries {
self.render_entries(has_write_access, window, cx)
v_flex()
.size_full()
.children(self.render_panel_header(window, cx))
.child(self.render_entries(has_write_access, window, cx))
.children(self.render_previous_commit(cx))
.child(self.render_commit_editor(window, cx))
.into_any_element()
} else {
self.render_empty_state(cx).into_any_element()
})
.children(self.render_previous_commit(cx))
.child(self.render_commit_editor(window, cx))
.children(self.context_menu.as_ref().map(|(menu, position, _)| {
deferred(
anchored()
Expand Down
Loading