Show git items in the panel only when in a git repository (#24865)
| 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
This commit is contained in:
parent
3759e0bf55
commit
17323ed7b2
1 changed files with 12 additions and 5 deletions
|
@ -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() {
|
||||
|
@ -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())
|
||||
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue