Skip to content

Commit

Permalink
add rename to details
Browse files Browse the repository at this point in the history
  • Loading branch information
micielski committed Oct 26, 2024
1 parent fc6c2ab commit fd96069
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions rm-main/src/tui/tabs/torrents/popups/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ impl Component for DetailsPopup {
self.ctx.send_action(Action::ShowFiles);
ComponentAction::Quit
}
Action::Rename => {
self.ctx.send_action(Action::Rename);
ComponentAction::Quit
}
Action::ChangeCategory => {
self.ctx.send_action(Action::ChangeCategory);
ComponentAction::Quit
Expand Down Expand Up @@ -103,6 +107,17 @@ impl Component for DetailsPopup {
keybinding_style(),
));

let mut rename_line = Line::default();
rename_line.push_span(Span::raw("Rename: "));
rename_line.push_span(Span::styled(
CONFIG
.keybindings
.torrents_tab
.get_keys_for_action_joined(TorrentsAction::Rename)
.unwrap_or_default(),
keybinding_style(),
));

let mut delete_line = Line::default();
delete_line.push_span(Span::raw("Delete: "));
delete_line.push_span(Span::styled(
Expand Down Expand Up @@ -158,6 +173,7 @@ impl Component for DetailsPopup {
lines.push(padding_line);
lines.push(delete_line);
lines.push(show_files_line);
lines.push(rename_line);
lines.push(move_location_line);
lines.push(change_category_line);

Expand Down
8 changes: 7 additions & 1 deletion rm-main/src/tui/tabs/torrents/tasks/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Rename {

impl Rename {
pub fn new(ctx: app::Ctx, to_rename: Id, curr_name: String) -> Self {
let prompt = String::from("New name ");
let prompt = String::from("New name: ");

Self {
id: to_rename,
Expand All @@ -34,6 +34,12 @@ impl Rename {
}

fn rename(&self) {
let new_name = self.input_mgr.text();

if self.curr_name == new_name {
return;
}

let task = StatusTask::new_rename(self.curr_name.clone());

self.ctx
Expand Down

0 comments on commit fd96069

Please sign in to comment.