Remove project panel trash action for remote projects (#21300)
Closes #20845 I'm uncertain about my placement for the logic to remove actions from the command palette list. If anyone has insights or alternative approaches, I'm open to changing the code. Release Notes: - Removed project panel `Trash` action for remote projects. --------- Co-authored-by: Finn Evers <dev@bahn.sh>
This commit is contained in:
parent
4137d1adb9
commit
aea6fa0c09
3 changed files with 17 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -9313,6 +9313,7 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"client",
|
"client",
|
||||||
"collections",
|
"collections",
|
||||||
|
"command_palette_hooks",
|
||||||
"db",
|
"db",
|
||||||
"editor",
|
"editor",
|
||||||
"file_icons",
|
"file_icons",
|
||||||
|
|
|
@ -15,6 +15,7 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
|
command_palette_hooks.workspace = true
|
||||||
db.workspace = true
|
db.workspace = true
|
||||||
editor.workspace = true
|
editor.workspace = true
|
||||||
file_icons.workspace = true
|
file_icons.workspace = true
|
||||||
|
|
|
@ -17,6 +17,7 @@ use file_icons::FileIcons;
|
||||||
|
|
||||||
use anyhow::{anyhow, Context as _, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use collections::{hash_map, BTreeSet, HashMap};
|
use collections::{hash_map, BTreeSet, HashMap};
|
||||||
|
use command_palette_hooks::CommandPaletteFilter;
|
||||||
use git::repository::GitFileStatus;
|
use git::repository::GitFileStatus;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, anchored, deferred, div, impl_actions, point, px, size, uniform_list, Action,
|
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 serde::{Deserialize, Serialize};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use std::any::TypeId;
|
||||||
use std::{
|
use std::{
|
||||||
cell::OnceCell,
|
cell::OnceCell,
|
||||||
cmp,
|
cmp,
|
||||||
|
@ -311,6 +313,15 @@ impl ProjectPanel {
|
||||||
})
|
})
|
||||||
.detach();
|
.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);
|
let filename_editor = cx.new_view(Editor::single_line);
|
||||||
|
|
||||||
cx.subscribe(
|
cx.subscribe(
|
||||||
|
@ -655,9 +666,11 @@ impl ProjectPanel {
|
||||||
.action("Copy Relative Path", Box::new(CopyRelativePath))
|
.action("Copy Relative Path", Box::new(CopyRelativePath))
|
||||||
.separator()
|
.separator()
|
||||||
.action("Rename", Box::new(Rename))
|
.action("Rename", Box::new(Rename))
|
||||||
.when(!is_root, |menu| {
|
.when(!is_root & !is_remote, |menu| {
|
||||||
menu.action("Trash", Box::new(Trash { skip_prompt: false }))
|
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| {
|
.when(!is_remote & is_root, |menu| {
|
||||||
menu.separator()
|
menu.separator()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue