From 6a0bcca9ec48ba6966983a10ac7538b94232ee70 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 29 Oct 2024 12:13:21 +0100 Subject: [PATCH] ssh remoting: Hide share button while connecting to project (#19885) Co-Authored-by: Thorsten Release Notes: - N/A Co-authored-by: Thorsten --- crates/recent_projects/src/recent_projects.rs | 2 +- crates/recent_projects/src/ssh_connections.rs | 4 ++++ crates/title_bar/src/collab.rs | 9 ++++++++- crates/workspace/src/workspace.rs | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index e5d28d16ca30b24f9d6b9c10ff9331ba7c90b2af..22068900c9badcf61e6cffa4074e8b5f1caa1fca 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -1,7 +1,7 @@ pub mod disconnected_overlay; mod remote_servers; mod ssh_connections; -pub use ssh_connections::open_ssh_project; +pub use ssh_connections::{is_connecting_over_ssh, open_ssh_project}; use disconnected_overlay::DisconnectedOverlay; use fuzzy::{StringMatch, StringMatchCandidate}; diff --git a/crates/recent_projects/src/ssh_connections.rs b/crates/recent_projects/src/ssh_connections.rs index a2964952eb0615e2eb31974ba8e4ca30d422faad..84618a2f491aa99eb131ed14a5ff7b75e0c58049 100644 --- a/crates/recent_projects/src/ssh_connections.rs +++ b/crates/recent_projects/src/ssh_connections.rs @@ -689,6 +689,10 @@ impl SshClientDelegate { } } +pub fn is_connecting_over_ssh(workspace: &Workspace, cx: &AppContext) -> bool { + workspace.active_modal::(cx).is_some() +} + pub fn connect_over_ssh( unique_identifier: String, connection_options: SshConnectionOptions, diff --git a/crates/title_bar/src/collab.rs b/crates/title_bar/src/collab.rs index edbc14792675f9e4f40d8d37f08cf89a2d5501aa..805c0e72029b20766747a0ce3b0882b3f66ef292 100644 --- a/crates/title_bar/src/collab.rs +++ b/crates/title_bar/src/collab.rs @@ -282,6 +282,13 @@ impl TitleBar { return Vec::new(); }; + let is_connecting_to_project = self + .workspace + .update(cx, |workspace, cx| { + recent_projects::is_connecting_over_ssh(workspace, cx) + }) + .unwrap_or(false); + let room = room.read(cx); let project = self.project.read(cx); let is_local = project.is_local() || project.is_via_ssh(); @@ -298,7 +305,7 @@ impl TitleBar { let mut children = Vec::new(); - if is_local && can_share_projects { + if is_local && can_share_projects && !is_connecting_to_project { children.push( Button::new( "toggle_sharing", diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 490851a56e3827d07e885b3aca3891f71caa49c2..24c681083b12cab06b7dc8a38d4e3880f343c7d4 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -4465,7 +4465,7 @@ impl Workspace { self.modal_layer.read(cx).has_active_modal() } - pub fn active_modal(&mut self, cx: &AppContext) -> Option> { + pub fn active_modal(&self, cx: &AppContext) -> Option> { self.modal_layer.read(cx).active_modal() }