Organize Project Panel context menus (#10456)
This design polish PR brings the project panel context menu into better alignment with other editors, better follows system patterns and identifies focus shifting actions with the `…` indicator (like adding a new folder to a project, which will open a modal window.) ## Before & After: **Root level**  **Folder level**  **File level**  Note: That double divider in the after has been fixed 😅 --- Release Notes: - Improved ordering and organization of context menus in the project panel to bring them closer to those in similar applications.
This commit is contained in:
parent
32806b8320
commit
27ba165046
1 changed files with 46 additions and 40 deletions
|
@ -419,48 +419,54 @@ impl ProjectPanel {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|menu| {
|
|menu| {
|
||||||
menu.when(is_local, |menu| {
|
menu.action("New File", Box::new(NewFile))
|
||||||
menu.action(
|
.action("New Folder", Box::new(NewDirectory))
|
||||||
"Add Folder to Project",
|
.separator()
|
||||||
Box::new(workspace::AddFolderToProject),
|
.action("Reveal in Finder", Box::new(RevealInFinder))
|
||||||
)
|
.when(is_dir, |menu| {
|
||||||
.when(is_root, |menu| {
|
menu.action("Open in Terminal…", Box::new(OpenInTerminal))
|
||||||
menu.entry(
|
|
||||||
"Remove from Project",
|
|
||||||
None,
|
|
||||||
cx.handler_for(&this, move |this, cx| {
|
|
||||||
this.project.update(cx, |project, cx| {
|
|
||||||
project.remove_worktree(worktree_id, cx)
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.action("Collapse All", Box::new(CollapseAllEntries))
|
|
||||||
})
|
})
|
||||||
})
|
.when(is_dir, |menu| {
|
||||||
.action("New File", Box::new(NewFile))
|
menu.separator()
|
||||||
.action("New Folder", Box::new(NewDirectory))
|
.action("Find in Folder…", Box::new(NewSearchInDirectory))
|
||||||
.separator()
|
})
|
||||||
.action("Cut", Box::new(Cut))
|
.separator()
|
||||||
.action("Copy", Box::new(Copy))
|
.action("Cut", Box::new(Cut))
|
||||||
.when_some(self.clipboard_entry, |menu, entry| {
|
.action("Copy", Box::new(Copy))
|
||||||
menu.when(entry.worktree_id() == worktree_id, |menu| {
|
// TODO: Paste should always be visible, but disabled when clipboard is empty
|
||||||
menu.action("Paste", Box::new(Paste))
|
.when_some(self.clipboard_entry, |menu, entry| {
|
||||||
|
menu.when(entry.worktree_id() == worktree_id, |menu| {
|
||||||
|
menu.action("Paste", Box::new(Paste))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.separator()
|
||||||
|
.action("Copy Path", Box::new(CopyPath))
|
||||||
|
.action("Copy Relative Path", Box::new(CopyRelativePath))
|
||||||
|
.separator()
|
||||||
|
.action("Rename", Box::new(Rename))
|
||||||
|
.when(!is_root, |menu| {
|
||||||
|
menu.action("Delete", Box::new(Delete { skip_prompt: false }))
|
||||||
|
})
|
||||||
|
.when(is_local & is_root, |menu| {
|
||||||
|
menu.separator()
|
||||||
|
.action(
|
||||||
|
"Add Folder to Project…",
|
||||||
|
Box::new(workspace::AddFolderToProject),
|
||||||
|
)
|
||||||
|
.entry(
|
||||||
|
"Remove from Project",
|
||||||
|
None,
|
||||||
|
cx.handler_for(&this, move |this, cx| {
|
||||||
|
this.project.update(cx, |project, cx| {
|
||||||
|
project.remove_worktree(worktree_id, cx)
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.when(is_local & is_root, |menu| {
|
||||||
|
menu.separator()
|
||||||
|
.action("Collapse All", Box::new(CollapseAllEntries))
|
||||||
})
|
})
|
||||||
})
|
|
||||||
.separator()
|
|
||||||
.action("Copy Path", Box::new(CopyPath))
|
|
||||||
.action("Copy Relative Path", Box::new(CopyRelativePath))
|
|
||||||
.separator()
|
|
||||||
.action("Reveal in Finder", Box::new(RevealInFinder))
|
|
||||||
.when(is_dir, |menu| {
|
|
||||||
menu.action("Open in Terminal", Box::new(OpenInTerminal))
|
|
||||||
.action("Search Inside", Box::new(NewSearchInDirectory))
|
|
||||||
})
|
|
||||||
.separator()
|
|
||||||
.action("Rename", Box::new(Rename))
|
|
||||||
.when(!is_root, |menu| {
|
|
||||||
menu.action("Delete", Box::new(Delete { skip_prompt: false }))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue