Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
issue/list: Allow editing comments
Erik Kundt committed 4 months ago
commit 66ea0d5915d453771d5d59dc5d93a8278f7cd9cb
parent 8ade256
3 files changed +50 -8
modified bin/commands/issue.rs
@@ -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(
modified bin/commands/issue/common.rs
@@ -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,
modified bin/commands/issue/list.rs
@@ -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()