From 09675d43b36b75ca7a0aaf4ce2b1f407ecb97868 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 372c46b21216c485a9181d93eb0233492e15d3d6..e9bf99850627c65a696ae4483371d3d72aafcb31 100644 --- a/crates/quick_action_bar/src/repl_menu.rs +++ b/crates/quick_action_bar/src/repl_menu.rs @@ -43,6 +43,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 3a835f74a81435f9ce58f8ce64728513ec62c717..5f2f9f3bfd41dc58530e8eab5b951290f7311e88 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