git: Improve co-author button (#29742)

This PR changes the tooltip label to say "Remove" when you have the
button toggled on and collaborators in the list.

Release Notes:

- N/A

Co-authored-by: Joseph T. Lyons <josephtlyons@gmail.com>
This commit is contained in:
Danilo Leal 2025-05-01 14:12:52 -03:00 committed by GitHub
parent 57610c9935
commit 96d785cb45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-round-check-icon lucide-user-round-check"><path d="M2 21a8 8 0 0 1 13.292-6"/><circle cx="10" cy="8" r="5"/><path d="m16 19 2 2 4-4"/></svg>

After

Width:  |  Height:  |  Size: 348 B

View file

@ -2755,18 +2755,26 @@ impl GitPanel {
pub(crate) fn render_co_authors(&self, cx: &Context<Self>) -> Option<AnyElement> { pub(crate) fn render_co_authors(&self, cx: &Context<Self>) -> Option<AnyElement> {
let potential_co_authors = self.potential_co_authors(cx); let potential_co_authors = self.potential_co_authors(cx);
let (tooltip_label, icon) = if self.add_coauthors {
("Add co-authored-by", IconName::UserCheck)
} else {
("Remove co-authored-by", IconName::Person)
};
if potential_co_authors.is_empty() { if potential_co_authors.is_empty() {
None None
} else { } else {
Some( Some(
IconButton::new("co-authors", IconName::Person) IconButton::new("co-authors", icon)
.shape(ui::IconButtonShape::Square) .shape(ui::IconButtonShape::Square)
.icon_color(Color::Disabled) .icon_color(Color::Disabled)
.selected_icon_color(Color::Selected) .selected_icon_color(Color::Selected)
.toggle_state(self.add_coauthors) .toggle_state(self.add_coauthors)
.tooltip(move |_, cx| { .tooltip(move |_, cx| {
let title = format!( let title = format!(
"Add co-authored-by:{}{}", "{}:{}{}",
tooltip_label,
if potential_co_authors.len() == 1 { if potential_co_authors.len() == 1 {
"" ""
} else { } else {

View file

@ -238,6 +238,7 @@ pub enum IconName {
Undo, Undo,
Unpin, Unpin,
Update, Update,
UserCheck,
UserGroup, UserGroup,
UserRoundPen, UserRoundPen,
Visible, Visible,