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:
parent
ebbf02e25b
commit
729cde33f1
1 changed files with 27 additions and 0 deletions
|
@ -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();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue