Skip to content

Commit

Permalink
Show git items in the panel only when in a git repository (#24865)
Browse files Browse the repository at this point in the history
| Before | After | After2 |
| - | - | - |
| <img width="368" alt="Screenshot 2025-02-14 alle 13 45 41"
src="https://github.com/user-attachments/assets/9ed6f233-c7e3-45b4-b2cd-605b6f785cbe"
/> | <img width="367" alt="Screenshot 2025-02-14 alle 14 25 24"
src="https://github.com/user-attachments/assets/808da265-dd1d-4679-9b62-a4def459fc8f"
/> | <img width="371" alt="Screenshot 2025-02-14 alle 14 25 38"
src="https://github.com/user-attachments/assets/09d0e27e-1e58-43b4-9a35-eb14c0d14961"
/> |

Release Notes:

- If it is not a git repository it shows nothing.
- Fix stage and unstage title in context_menu
  • Loading branch information
Angelk90 authored Feb 21, 2025
1 parent 3759e0b commit 17323ed
Showing 1 changed file with 12 additions and 5 deletions.
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

0 comments on commit 17323ed

Please sign in to comment.