Add tooltip to the toggle public button in the contacts panel
Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
98b54763b9
commit
6a3a3a1124
2 changed files with 55 additions and 27 deletions
|
@ -179,19 +179,24 @@ impl ContactsPanel {
|
||||||
|
|
||||||
let list_state = ListState::new(0, Orientation::Top, 1000., cx, move |this, ix, cx| {
|
let list_state = ListState::new(0, Orientation::Top, 1000., cx, move |this, ix, cx| {
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
let theme = &theme.contacts_panel;
|
|
||||||
let current_user_id = this.user_store.read(cx).current_user().map(|user| user.id);
|
let current_user_id = this.user_store.read(cx).current_user().map(|user| user.id);
|
||||||
let is_selected = this.selection == Some(ix);
|
let is_selected = this.selection == Some(ix);
|
||||||
|
|
||||||
match &this.entries[ix] {
|
match &this.entries[ix] {
|
||||||
ContactEntry::Header(section) => {
|
ContactEntry::Header(section) => {
|
||||||
let is_collapsed = this.collapsed_sections.contains(§ion);
|
let is_collapsed = this.collapsed_sections.contains(§ion);
|
||||||
Self::render_header(*section, theme, is_selected, is_collapsed, cx)
|
Self::render_header(
|
||||||
|
*section,
|
||||||
|
&theme.contacts_panel,
|
||||||
|
is_selected,
|
||||||
|
is_collapsed,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ContactEntry::IncomingRequest(user) => Self::render_contact_request(
|
ContactEntry::IncomingRequest(user) => Self::render_contact_request(
|
||||||
user.clone(),
|
user.clone(),
|
||||||
this.user_store.clone(),
|
this.user_store.clone(),
|
||||||
theme,
|
&theme.contacts_panel,
|
||||||
true,
|
true,
|
||||||
is_selected,
|
is_selected,
|
||||||
cx,
|
cx,
|
||||||
|
@ -199,13 +204,13 @@ impl ContactsPanel {
|
||||||
ContactEntry::OutgoingRequest(user) => Self::render_contact_request(
|
ContactEntry::OutgoingRequest(user) => Self::render_contact_request(
|
||||||
user.clone(),
|
user.clone(),
|
||||||
this.user_store.clone(),
|
this.user_store.clone(),
|
||||||
theme,
|
&theme.contacts_panel,
|
||||||
false,
|
false,
|
||||||
is_selected,
|
is_selected,
|
||||||
cx,
|
cx,
|
||||||
),
|
),
|
||||||
ContactEntry::Contact(contact) => {
|
ContactEntry::Contact(contact) => {
|
||||||
Self::render_contact(&contact.user, theme, is_selected)
|
Self::render_contact(&contact.user, &theme.contacts_panel, is_selected)
|
||||||
}
|
}
|
||||||
ContactEntry::ContactProject(contact, project_ix, open_project) => {
|
ContactEntry::ContactProject(contact, project_ix, open_project) => {
|
||||||
let is_last_project_for_contact =
|
let is_last_project_for_contact =
|
||||||
|
@ -221,15 +226,20 @@ impl ContactsPanel {
|
||||||
current_user_id,
|
current_user_id,
|
||||||
*project_ix,
|
*project_ix,
|
||||||
open_project.clone(),
|
open_project.clone(),
|
||||||
theme,
|
&theme.contacts_panel,
|
||||||
|
&theme.tooltip,
|
||||||
is_last_project_for_contact,
|
is_last_project_for_contact,
|
||||||
is_selected,
|
is_selected,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ContactEntry::PrivateProject(project) => {
|
ContactEntry::PrivateProject(project) => Self::render_private_project(
|
||||||
Self::render_private_project(project.clone(), theme, is_selected, cx)
|
project.clone(),
|
||||||
}
|
&theme.contacts_panel,
|
||||||
|
&theme.tooltip,
|
||||||
|
is_selected,
|
||||||
|
cx,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -335,6 +345,7 @@ impl ContactsPanel {
|
||||||
project_index: usize,
|
project_index: usize,
|
||||||
open_project: Option<WeakModelHandle<Project>>,
|
open_project: Option<WeakModelHandle<Project>>,
|
||||||
theme: &theme::ContactsPanel,
|
theme: &theme::ContactsPanel,
|
||||||
|
tooltip_style: &TooltipStyle,
|
||||||
is_last_project: bool,
|
is_last_project: bool,
|
||||||
is_selected: bool,
|
is_selected: bool,
|
||||||
cx: &mut RenderContext<Self>,
|
cx: &mut RenderContext<Self>,
|
||||||
|
@ -406,7 +417,7 @@ impl ContactsPanel {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut button = MouseEventHandler::new::<ToggleProjectPublic, _, _>(
|
let button = MouseEventHandler::new::<ToggleProjectPublic, _, _>(
|
||||||
project_id as usize,
|
project_id as usize,
|
||||||
cx,
|
cx,
|
||||||
|state, _| {
|
|state, _| {
|
||||||
|
@ -423,17 +434,27 @@ impl ContactsPanel {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if !is_becoming_private {
|
if is_becoming_private {
|
||||||
button = button
|
Some(button.boxed())
|
||||||
|
} else {
|
||||||
|
Some(
|
||||||
|
button
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_click(move |_, _, cx| {
|
.on_click(move |_, _, cx| {
|
||||||
cx.dispatch_action(ToggleProjectPublic {
|
cx.dispatch_action(ToggleProjectPublic {
|
||||||
project: Some(open_project.clone()),
|
project: Some(open_project.clone()),
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
|
.with_tooltip(
|
||||||
|
project_id as usize,
|
||||||
|
"Make project private".to_string(),
|
||||||
|
None,
|
||||||
|
tooltip_style.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(button.boxed())
|
|
||||||
}))
|
}))
|
||||||
.constrained()
|
.constrained()
|
||||||
.with_width(host_avatar_height)
|
.with_width(host_avatar_height)
|
||||||
|
@ -487,6 +508,7 @@ impl ContactsPanel {
|
||||||
fn render_private_project(
|
fn render_private_project(
|
||||||
project: WeakModelHandle<Project>,
|
project: WeakModelHandle<Project>,
|
||||||
theme: &theme::ContactsPanel,
|
theme: &theme::ContactsPanel,
|
||||||
|
tooltip_style: &TooltipStyle,
|
||||||
is_selected: bool,
|
is_selected: bool,
|
||||||
cx: &mut RenderContext<Self>,
|
cx: &mut RenderContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
|
@ -520,7 +542,7 @@ impl ContactsPanel {
|
||||||
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child({
|
.with_child({
|
||||||
let mut button =
|
let button =
|
||||||
MouseEventHandler::new::<TogglePublic, _, _>(project_id, cx, |state, _| {
|
MouseEventHandler::new::<TogglePublic, _, _>(project_id, cx, |state, _| {
|
||||||
let mut style = *theme.private_button.style_for(state, false);
|
let mut style = *theme.private_button.style_for(state, false);
|
||||||
if is_becoming_public {
|
if is_becoming_public {
|
||||||
|
@ -533,17 +555,25 @@ impl ContactsPanel {
|
||||||
.boxed()
|
.boxed()
|
||||||
});
|
});
|
||||||
|
|
||||||
if !is_becoming_public {
|
if is_becoming_public {
|
||||||
button = button
|
button.boxed()
|
||||||
|
} else {
|
||||||
|
button
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_click(move |_, _, cx| {
|
.on_click(move |_, _, cx| {
|
||||||
cx.dispatch_action(ToggleProjectPublic {
|
cx.dispatch_action(ToggleProjectPublic {
|
||||||
project: Some(project.clone()),
|
project: Some(project.clone()),
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
|
.with_tooltip(
|
||||||
|
project_id,
|
||||||
|
"Make project public".to_string(),
|
||||||
|
None,
|
||||||
|
tooltip_style.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
button.boxed()
|
|
||||||
})
|
})
|
||||||
.with_child(
|
.with_child(
|
||||||
Label::new(worktree_root_names, row.name.text.clone())
|
Label::new(worktree_root_names, row.name.text.clone())
|
||||||
|
|
|
@ -1056,7 +1056,6 @@ impl Workspace {
|
||||||
.unwrap_or_else(|| self.project.clone());
|
.unwrap_or_else(|| self.project.clone());
|
||||||
project.update(cx, |project, cx| {
|
project.update(cx, |project, cx| {
|
||||||
let public = !project.is_public();
|
let public = !project.is_public();
|
||||||
eprintln!("toggle_project_public => {}", public);
|
|
||||||
project.set_public(public, cx);
|
project.set_public(public, cx);
|
||||||
project.project_store().update(cx, |store, cx| {
|
project.project_store().update(cx, |store, cx| {
|
||||||
store
|
store
|
||||||
|
@ -2467,7 +2466,6 @@ pub fn open_paths(
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
if public {
|
if public {
|
||||||
project.update(&mut cx, |project, cx| {
|
project.update(&mut cx, |project, cx| {
|
||||||
eprintln!("initialize new project public");
|
|
||||||
project.set_public(true, cx);
|
project.set_public(true, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue