mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-21 10:30:48 +08:00
feat(patch): Adds review action to list interface
This commit is contained in:
+18
-11
@@ -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<Rev>,
|
||||
revision_id: Option<Rev>,
|
||||
@@ -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::<Vec<_>>();
|
||||
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::<Vec<_>>();
|
||||
let _ = crate::terminal::run_rad(Some("patch"), &args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Operation::Review { ref opts } => {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -233,6 +233,7 @@ fn browser_page(_state: &State, channel: &Channel<Message>) -> Widget<State, Mes
|
||||
("enter", "show"),
|
||||
("c", "checkout"),
|
||||
("d", "diff"),
|
||||
("r", "review"),
|
||||
("/", "search"),
|
||||
("?", "help"),
|
||||
],
|
||||
@@ -266,6 +267,9 @@ fn browser_page(_state: &State, channel: &Channel<Message>) -> Widget<State, Mes
|
||||
Key::Char('d') => Some(Message::Exit {
|
||||
operation: Some(PatchOperation::Diff),
|
||||
}),
|
||||
Key::Char('r') => Some(Message::Exit {
|
||||
operation: Some(PatchOperation::Review),
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -277,6 +277,7 @@ impl Show<Message> for App {
|
||||
("enter", "show"),
|
||||
("c", "checkout"),
|
||||
("d", "diff"),
|
||||
("r", "review"),
|
||||
("/", "search"),
|
||||
("?", "help"),
|
||||
]
|
||||
@@ -300,6 +301,11 @@ impl Show<Message> 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),
|
||||
|
||||
Reference in New Issue
Block a user