Only show in-call share/unshare button if own project

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Julia 2023-02-22 13:40:43 -05:00
parent dbe5b0205c
commit 812145f9ab

View file

@ -103,7 +103,7 @@ impl View for CollabTitlebarItem {
if ActiveCall::global(cx).read(cx).room().is_some() { if ActiveCall::global(cx).read(cx).room().is_some() {
right_container right_container
.add_child(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); .add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx));
} else { } else {
right_container.add_child(self.render_outside_call_share_button(&theme, cx)); right_container.add_child(self.render_outside_call_share_button(&theme, cx));
} }
@ -396,8 +396,13 @@ impl CollabTitlebarItem {
workspace: &ViewHandle<Workspace>, workspace: &ViewHandle<Workspace>,
theme: &Theme, theme: &Theme,
cx: &mut RenderContext<Self>, cx: &mut RenderContext<Self>,
) -> ElementBox { ) -> Option<ElementBox> {
let is_shared = workspace.read(cx).project().read(cx).is_shared(); let project = workspace.read(cx).project();
if project.read(cx).is_remote() {
return None;
}
let is_shared = project.read(cx).is_shared();
let label = if is_shared { "Unshare" } else { "Share" }; let label = if is_shared { "Unshare" } else { "Share" };
let tooltip = if is_shared { let tooltip = if is_shared {
"Unshare project from call participants" "Unshare project from call participants"
@ -408,47 +413,49 @@ impl CollabTitlebarItem {
let titlebar = &theme.workspace.titlebar; let titlebar = &theme.workspace.titlebar;
enum ShareUnshare {} enum ShareUnshare {}
Stack::new() Some(
.with_child( Stack::new()
MouseEventHandler::<ShareUnshare>::new(0, cx, |state, _| { .with_child(
//TODO: Ensure this button has consistant width for both text variations MouseEventHandler::<ShareUnshare>::new(0, cx, |state, _| {
let style = titlebar.share_button.style_for( //TODO: Ensure this button has consistant width for both text variations
state, let style = titlebar.share_button.style_for(
self.contacts_popover.is_some() state,
&& self.contacts_popover_side == ContactsPopoverSide::Right, self.contacts_popover.is_some()
); && self.contacts_popover_side == ContactsPopoverSide::Right,
Label::new(label, style.text.clone()) );
.contained() Label::new(label, style.text.clone())
.with_style(style.container) .contained()
.boxed() .with_style(style.container)
}) .boxed()
.with_cursor_style(CursorStyle::PointingHand) })
.on_click(MouseButton::Left, move |_, cx| { .with_cursor_style(CursorStyle::PointingHand)
if is_shared { .on_click(MouseButton::Left, move |_, cx| {
cx.dispatch_action(UnshareProject); if is_shared {
} else { cx.dispatch_action(UnshareProject);
cx.dispatch_action(ShareProject); } else {
} cx.dispatch_action(ShareProject);
}) }
.with_tooltip::<ShareUnshare, _>( })
0, .with_tooltip::<ShareUnshare, _>(
tooltip.to_owned(), 0,
None, tooltip.to_owned(),
theme.tooltip.clone(), None,
cx, theme.tooltip.clone(),
cx,
)
.boxed(),
) )
.with_children(self.render_contacts_popover_host(
ContactsPopoverSide::Right,
titlebar,
cx,
))
.aligned()
.contained()
.with_margin_left(theme.workspace.titlebar.avatar_margin)
.with_margin_right(theme.workspace.titlebar.avatar_margin)
.boxed(), .boxed(),
) )
.with_children(self.render_contacts_popover_host(
ContactsPopoverSide::Right,
titlebar,
cx,
))
.aligned()
.contained()
.with_margin_left(theme.workspace.titlebar.avatar_margin)
.with_margin_right(theme.workspace.titlebar.avatar_margin)
.boxed()
} }
fn render_outside_call_share_button( fn render_outside_call_share_button(