mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 00:10:38 +08:00
issue/list: Allow editing comments
This commit is contained in:
+31
-6
@@ -241,12 +241,37 @@ pub async fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> {
|
||||
)?;
|
||||
break;
|
||||
}
|
||||
IssueOperation::Edit { id } => {
|
||||
terminal::run_rad(
|
||||
Some("issue"),
|
||||
&["edit".into(), id.to_string().into()],
|
||||
Quiet::No,
|
||||
)?;
|
||||
IssueOperation::Edit {
|
||||
id,
|
||||
comment_id,
|
||||
search,
|
||||
} => {
|
||||
state = PreviousState {
|
||||
issue_id: Some(id),
|
||||
comment_id,
|
||||
search: Some(search),
|
||||
};
|
||||
match comment_id {
|
||||
Some(comment_id) => {
|
||||
terminal::run_rad(
|
||||
Some("issue"),
|
||||
&[
|
||||
"comment".into(),
|
||||
id.to_string().into(),
|
||||
"--edit".into(),
|
||||
comment_id.to_string().into(),
|
||||
],
|
||||
Quiet::No,
|
||||
)?;
|
||||
}
|
||||
_ => {
|
||||
terminal::run_rad(
|
||||
Some("issue"),
|
||||
&["edit".into(), id.to_string().into()],
|
||||
Quiet::No,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
IssueOperation::Solve { id } => {
|
||||
terminal::run_rad(
|
||||
|
||||
@@ -8,6 +8,8 @@ use radicle::{cob::thread::CommentId, issue::IssueId};
|
||||
pub enum IssueOperation {
|
||||
Edit {
|
||||
id: IssueId,
|
||||
comment_id: Option<CommentId>,
|
||||
search: String,
|
||||
},
|
||||
Show {
|
||||
id: IssueId,
|
||||
|
||||
@@ -247,6 +247,7 @@ impl TryFrom<(&Context, &TerminalInfo)> for State {
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum RequestedIssueOperation {
|
||||
Edit,
|
||||
EditComment,
|
||||
Show,
|
||||
Reply,
|
||||
Solve,
|
||||
@@ -300,7 +301,18 @@ impl store::Update<Message> for State {
|
||||
issue.map(|issue| IssueOperation::Show { id: issue.id })
|
||||
}
|
||||
Some(RequestedIssueOperation::Edit) => {
|
||||
issue.map(|issue| IssueOperation::Edit { id: issue.id })
|
||||
issue.map(|issue| IssueOperation::Edit {
|
||||
id: issue.id,
|
||||
comment_id: None,
|
||||
search: self.browser.read_search(),
|
||||
})
|
||||
}
|
||||
Some(RequestedIssueOperation::EditComment) => {
|
||||
issue.map(|issue| IssueOperation::Edit {
|
||||
id: issue.id,
|
||||
comment_id: comment.map(|c| c.id),
|
||||
search: self.browser.read_search(),
|
||||
})
|
||||
}
|
||||
Some(RequestedIssueOperation::Solve) => {
|
||||
issue.map(|issue| IssueOperation::Solve { id: issue.id })
|
||||
@@ -455,7 +467,7 @@ fn browser_page(channel: &Channel<Message>) -> Widget<State, Message> {
|
||||
}
|
||||
shortcuts
|
||||
}
|
||||
_ => [("c", "reply")].to_vec(),
|
||||
_ => [("e", "edit"), ("c", "reply")].to_vec(),
|
||||
}
|
||||
};
|
||||
let global_shortcuts = vec![("p", "toggle preview"), ("?", "help")];
|
||||
@@ -620,6 +632,9 @@ fn comment_tree(channel: &Channel<Message>) -> Widget<State, Message> {
|
||||
Event::Key(Key::Char('c')) => Some(Message::Exit {
|
||||
operation: Some(RequestedIssueOperation::Reply),
|
||||
}),
|
||||
Event::Key(Key::Char('e')) => Some(Message::Exit {
|
||||
operation: Some(RequestedIssueOperation::EditComment),
|
||||
}),
|
||||
_ => Some(Message::SelectComment {
|
||||
selected: s.and_then(|s| {
|
||||
s.unwrap_tree()
|
||||
|
||||
Reference in New Issue
Block a user