diff --git a/bin/commands/patch.rs b/bin/commands/patch.rs index 21e8ba28..26620818 100644 --- a/bin/commands/patch.rs +++ b/bin/commands/patch.rs @@ -81,7 +81,7 @@ pub struct ListOptions { json: bool, } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct ReviewOptions { patch_id: Option, revision_id: Option, @@ -255,7 +255,7 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul let rid = options.repo.unwrap_or(rid); // Run TUI with patch list interface - let selection = interface::list(opts.clone(), profile, rid).await?; + let selection = interface::list(opts.clone(), profile.clone(), rid).await?; if opts.json { let selection = selection @@ -267,17 +267,24 @@ pub async fn run(options: Options, ctx: impl terminal::Context) -> anyhow::Resul eprint!("{selection}"); } else if let Some(selection) = selection { - let mut args = vec![]; + if let Some(operation) = selection.operation.clone() { + let mut args = vec![operation.to_string()]; - if let Some(operation) = selection.operation { - args.push(operation.to_string()); - } - if let Some(id) = selection.ids.first() { - args.push(format!("{id}")); - } + if let Some(id) = selection.ids.first() { + args.push(format!("{id}")); - let args = args.into_iter().map(OsString::from).collect::>(); - let _ = crate::terminal::run_rad(Some("patch"), &args); + match operation.as_str() { + "review" => { + let opts = ReviewOptions::default(); + interface::review(opts, profile, rid, *id).await?; + } + _ => { + let args = args.into_iter().map(OsString::from).collect::>(); + let _ = crate::terminal::run_rad(Some("patch"), &args); + } + } + } + } } } Operation::Review { ref opts } => { diff --git a/bin/commands/patch/common.rs b/bin/commands/patch/common.rs index 3f06948d..0a928b58 100644 --- a/bin/commands/patch/common.rs +++ b/bin/commands/patch/common.rs @@ -19,6 +19,7 @@ pub enum Mode { pub enum PatchOperation { Checkout, Diff, + Review, Show, } @@ -31,6 +32,9 @@ impl Display for PatchOperation { PatchOperation::Diff => { write!(f, "diff") } + PatchOperation::Review => { + write!(f, "review") + } PatchOperation::Show => { write!(f, "show") } diff --git a/bin/commands/patch/list.rs b/bin/commands/patch/list.rs index a80b8674..23e6ef87 100644 --- a/bin/commands/patch/list.rs +++ b/bin/commands/patch/list.rs @@ -233,6 +233,7 @@ fn browser_page(_state: &State, channel: &Channel) -> Widget) -> Widget Some(Message::Exit { operation: Some(PatchOperation::Diff), }), + Key::Char('r') => Some(Message::Exit { + operation: Some(PatchOperation::Review), + }), _ => None, } } else { diff --git a/bin/commands/patch/list/imui.rs b/bin/commands/patch/list/imui.rs index a81f5cfe..c091da7d 100644 --- a/bin/commands/patch/list/imui.rs +++ b/bin/commands/patch/list/imui.rs @@ -277,6 +277,7 @@ impl Show for App { ("enter", "show"), ("c", "checkout"), ("d", "diff"), + ("r", "review"), ("/", "search"), ("?", "help"), ] @@ -300,6 +301,11 @@ impl Show for App { operation: Some(PatchOperation::Diff), }); } + if ui.input_global(|key| key == Key::Char('r')) { + ui.send_message(Message::Exit { + operation: Some(PatchOperation::Review), + }); + } if ui.input_global(|key| key == Key::Char('c')) { ui.send_message(Message::Exit { operation: Some(PatchOperation::Checkout),