Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Remove project panel trash action for remote projects (#21300)

moshyfawnaea6fa0c0982
diff --git a/Cargo.lock b/Cargo.lock
index bdb839e78b3..7768dac710f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9313,6 +9313,7 @@ dependencies = [
"anyhow",
"client",
"collections",
+ "command_palette_hooks",
"db",
"editor",
"file_icons",
diff --git a/crates/project_panel/Cargo.toml b/crates/project_panel/Cargo.toml
index dbcabc9f83e..af913d9d6b4 100644
--- a/crates/project_panel/Cargo.toml
+++ b/crates/project_panel/Cargo.toml
@@ -15,6 +15,7 @@ doctest = false
[dependencies]
anyhow.workspace = true
collections.workspace = true
+command_palette_hooks.workspace = true
db.workspace = true
editor.workspace = true
file_icons.workspace = true
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index 98037429661..bfb07fc7fd1 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -17,6 +17,7 @@ use file_icons::FileIcons;
use anyhow::{anyhow, Context as _, Result};
use collections::{hash_map, BTreeSet, HashMap};
+use command_palette_hooks::CommandPaletteFilter;
use git::repository::GitFileStatus;
use gpui::{
actions, anchored, deferred, div, impl_actions, point, px, size, uniform_list, Action,
@@ -38,6 +39,7 @@ use project_panel_settings::{
};
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
+use std::any::TypeId;
use std::{
cell::OnceCell,
cmp,
@@ -311,6 +313,15 @@ impl ProjectPanel {
})
.detach();
+ let trash_action = [TypeId::of::<Trash>()];
+ let is_remote = project.read(cx).is_via_collab();
+
+ if is_remote {
+ CommandPaletteFilter::update_global(cx, |filter, _cx| {
+ filter.hide_action_types(&trash_action);
+ });
+ }
+
let filename_editor = cx.new_view(Editor::single_line);
cx.subscribe(
@@ -655,9 +666,11 @@ impl ProjectPanel {
.action("Copy Relative Path", Box::new(CopyRelativePath))
.separator()
.action("Rename", Box::new(Rename))
- .when(!is_root, |menu| {
+ .when(!is_root & !is_remote, |menu| {
menu.action("Trash", Box::new(Trash { skip_prompt: false }))
- .action("Delete", Box::new(Delete { skip_prompt: false }))
+ })
+ .when(!is_root, |menu| {
+ menu.action("Delete", Box::new(Delete { skip_prompt: false }))
})
.when(!is_remote & is_root, |menu| {
menu.separator()