mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 18:46:49 +00:00
Read only permissions for project panel too
This commit is contained in:
parent
1930258d39
commit
427e7f6b4f
1 changed files with 20 additions and 10 deletions
|
@ -388,8 +388,13 @@ impl ProjectPanel {
|
||||||
let is_dir = entry.is_dir();
|
let is_dir = entry.is_dir();
|
||||||
let worktree_id = worktree.id();
|
let worktree_id = worktree.id();
|
||||||
let is_local = project.is_local();
|
let is_local = project.is_local();
|
||||||
|
let is_read_only = project.is_read_only();
|
||||||
|
|
||||||
let context_menu = ContextMenu::build(cx, |mut menu, cx| {
|
let context_menu = ContextMenu::build(cx, |mut menu, cx| {
|
||||||
|
if is_read_only {
|
||||||
|
return menu.action("Copy Relative Path", Box::new(CopyRelativePath));
|
||||||
|
}
|
||||||
|
|
||||||
if is_local {
|
if is_local {
|
||||||
menu = menu.action(
|
menu = menu.action(
|
||||||
"Add Folder to Project",
|
"Add Folder to Project",
|
||||||
|
@ -1482,6 +1487,7 @@ impl ProjectPanel {
|
||||||
impl Render for ProjectPanel {
|
impl Render for ProjectPanel {
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
|
||||||
let has_worktree = self.visible_entries.len() != 0;
|
let has_worktree = self.visible_entries.len() != 0;
|
||||||
|
let project = self.project.read(cx);
|
||||||
|
|
||||||
if has_worktree {
|
if has_worktree {
|
||||||
div()
|
div()
|
||||||
|
@ -1494,21 +1500,25 @@ impl Render for ProjectPanel {
|
||||||
.on_action(cx.listener(Self::expand_selected_entry))
|
.on_action(cx.listener(Self::expand_selected_entry))
|
||||||
.on_action(cx.listener(Self::collapse_selected_entry))
|
.on_action(cx.listener(Self::collapse_selected_entry))
|
||||||
.on_action(cx.listener(Self::collapse_all_entries))
|
.on_action(cx.listener(Self::collapse_all_entries))
|
||||||
.on_action(cx.listener(Self::new_file))
|
|
||||||
.on_action(cx.listener(Self::new_directory))
|
|
||||||
.on_action(cx.listener(Self::rename))
|
|
||||||
.on_action(cx.listener(Self::delete))
|
|
||||||
.on_action(cx.listener(Self::confirm))
|
|
||||||
.on_action(cx.listener(Self::open_file))
|
.on_action(cx.listener(Self::open_file))
|
||||||
|
.on_action(cx.listener(Self::confirm))
|
||||||
.on_action(cx.listener(Self::cancel))
|
.on_action(cx.listener(Self::cancel))
|
||||||
.on_action(cx.listener(Self::cut))
|
|
||||||
.on_action(cx.listener(Self::copy))
|
|
||||||
.on_action(cx.listener(Self::copy_path))
|
.on_action(cx.listener(Self::copy_path))
|
||||||
.on_action(cx.listener(Self::copy_relative_path))
|
.on_action(cx.listener(Self::copy_relative_path))
|
||||||
.on_action(cx.listener(Self::paste))
|
|
||||||
.on_action(cx.listener(Self::reveal_in_finder))
|
|
||||||
.on_action(cx.listener(Self::open_in_terminal))
|
|
||||||
.on_action(cx.listener(Self::new_search_in_directory))
|
.on_action(cx.listener(Self::new_search_in_directory))
|
||||||
|
.when(!project.is_read_only(), |el| {
|
||||||
|
el.on_action(cx.listener(Self::new_file))
|
||||||
|
.on_action(cx.listener(Self::new_directory))
|
||||||
|
.on_action(cx.listener(Self::rename))
|
||||||
|
.on_action(cx.listener(Self::delete))
|
||||||
|
.on_action(cx.listener(Self::cut))
|
||||||
|
.on_action(cx.listener(Self::copy))
|
||||||
|
.on_action(cx.listener(Self::paste))
|
||||||
|
})
|
||||||
|
.when(project.is_local(), |el| {
|
||||||
|
el.on_action(cx.listener(Self::reveal_in_finder))
|
||||||
|
.on_action(cx.listener(Self::open_in_terminal))
|
||||||
|
})
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.child(
|
.child(
|
||||||
uniform_list(
|
uniform_list(
|
||||||
|
|
Loading…
Reference in a new issue