project_panel: Add rename, delete and duplicate actions to workspace (#34478)

Release Notes:

- Added `project panel: rename`, `project panel: delete` and `project
panel: duplicate` actions to workspace.

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
Smit Barmase 2025-07-15 23:41:53 +05:30 committed by GitHub
parent ebbf02e25b
commit 729cde33f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -320,6 +320,33 @@ pub fn init(cx: &mut App) {
});
}
});
workspace.register_action(|workspace, action: &Rename, window, cx| {
if let Some(panel) = workspace.panel::<ProjectPanel>(cx) {
panel.update(cx, |panel, cx| {
if let Some(first_marked) = panel.marked_entries.first() {
let first_marked = *first_marked;
panel.marked_entries.clear();
panel.selection = Some(first_marked);
}
panel.rename(action, window, cx);
});
}
});
workspace.register_action(|workspace, action: &Duplicate, window, cx| {
if let Some(panel) = workspace.panel::<ProjectPanel>(cx) {
panel.update(cx, |panel, cx| {
panel.duplicate(action, window, cx);
});
}
});
workspace.register_action(|workspace, action: &Delete, window, cx| {
if let Some(panel) = workspace.panel::<ProjectPanel>(cx) {
panel.update(cx, |panel, cx| panel.delete(action, window, cx));
}
});
})
.detach();
}