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() {
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 {
right_container.add_child(self.render_outside_call_share_button(&theme, cx));
}
@ -396,8 +396,13 @@ impl CollabTitlebarItem {
workspace: &ViewHandle<Workspace>,
theme: &Theme,
cx: &mut RenderContext<Self>,
) -> ElementBox {
let is_shared = workspace.read(cx).project().read(cx).is_shared();
) -> Option<ElementBox> {
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 tooltip = if is_shared {
"Unshare project from call participants"
@ -408,6 +413,7 @@ impl CollabTitlebarItem {
let titlebar = &theme.workspace.titlebar;
enum ShareUnshare {}
Some(
Stack::new()
.with_child(
MouseEventHandler::<ShareUnshare>::new(0, cx, |state, _| {
@ -448,7 +454,8 @@ impl CollabTitlebarItem {
.contained()
.with_margin_left(theme.workspace.titlebar.avatar_margin)
.with_margin_right(theme.workspace.titlebar.avatar_margin)
.boxed()
.boxed(),
)
}
fn render_outside_call_share_button(