From e5fc5ea366fdb06404b97bc886755bc65a257fd5 Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Fri, 8 Nov 2024 06:29:07 -0800 Subject: [PATCH] Disable repl in non-local projects (#20397) Release Notes: - Disable REPL buttons and actions for remote projects and collaboration (only the host should have access). --- crates/quick_action_bar/src/repl_menu.rs | 10 ++++++++++ crates/repl/src/repl_sessions_ui.rs | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/quick_action_bar/src/repl_menu.rs b/crates/quick_action_bar/src/repl_menu.rs index f4e4cd2d1ad20e097690c2e281af847467a6c2cc..987432f8d3cfc91be671f7e010013eb220e43f2b 100644 --- a/crates/quick_action_bar/src/repl_menu.rs +++ b/crates/quick_action_bar/src/repl_menu.rs @@ -41,6 +41,16 @@ impl QuickActionBar { let editor = self.active_editor()?; + let is_local_project = editor + .read(cx) + .workspace() + .map(|workspace| workspace.read(cx).project().read(cx).is_local()) + .unwrap_or(false); + + if !is_local_project { + return None; + } + let has_nonempty_selection = { editor.update(cx, |this, cx| { this.selections diff --git a/crates/repl/src/repl_sessions_ui.rs b/crates/repl/src/repl_sessions_ui.rs index efc5f14d07931b3891172b7b94f7494611a5c977..1e9792b1f6fd6ab6c2ed1402b0292495251ff3c4 100644 --- a/crates/repl/src/repl_sessions_ui.rs +++ b/crates/repl/src/repl_sessions_ui.rs @@ -61,6 +61,15 @@ pub fn init(cx: &mut AppContext) { return; } + let is_local_project = editor + .workspace() + .map(|workspace| workspace.read(cx).project().read(cx).is_local()) + .unwrap_or(false); + + if !is_local_project { + return; + } + let editor_handle = cx.view().downgrade(); editor