Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Switch shortcuts on issue page
Erik Kundt committed 2 years ago
commit a99f769635cae0b280f02a76dee4d5763e3edbf7
parent ba019f652f18aa5b41278488e863ff014426580f
3 files changed +23 -7
modified src/app.rs
@@ -161,7 +161,7 @@ impl App {
        let repo = self.context.repository();

        if let Some(issue) = cob::issue::find(repo, &id)? {
-
            let view = Box::new(IssuePage::new(theme.clone(), (id, issue)));
+
            let view = Box::new(IssuePage::new(&self.context, theme, (id, issue)));
            self.pages.push(view, app, &self.context, theme)?;

            Ok(())
modified src/app/event.rs
@@ -79,7 +79,7 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<issue::LargeList> {
                code: Key::Enter, ..
            }) => Some(Message::Issue(IssueMessage::Focus(IssueCid::Details))),
            Event::Keyboard(KeyEvent {
-
                code: Key::Char('o'), ..
+
                code: Key::Char('n'), ..
            }) => {
                Some(Message::Issue(IssueMessage::OpenPopup(IssueCid::NewForm)))
            }
modified src/app/page.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

-
use anyhow::{Ok, Result};
+
use anyhow::Result;

use radicle::cob::issue::{Issue, IssueId};
use radicle::cob::patch::{Patch, PatchId};
@@ -281,8 +281,8 @@ pub struct IssuePage {
}

impl IssuePage {
-
    pub fn new(theme: Theme, issue: (IssueId, Issue)) -> Self {
-
        let shortcuts = Self::build_shortcuts(&theme);
+
    pub fn new(_context: &Context, theme: &Theme, issue: (IssueId, Issue)) -> Self {
+
        let shortcuts = Self::build_shortcuts(theme);
        let active_component = IssueCid::List;

        Self {
@@ -313,6 +313,7 @@ impl IssuePage {
                        widget::common::shortcut(theme, "esc", "back"),
                        widget::common::shortcut(theme, "↑/↓", "navigate"),
                        widget::common::shortcut(theme, "enter", "show"),
+
                        widget::common::shortcut(theme, "n", "new issue"),
                        widget::common::shortcut(theme, "q", "quit"),
                    ],
                ),
@@ -328,6 +329,17 @@ impl IssuePage {
                    ],
                ),
            ),
+
            (
+
                IssueCid::NewForm,
+
                widget::common::shortcuts(
+
                    theme,
+
                    vec![
+
                        widget::common::shortcut(theme, "esc", "back"),
+
                        widget::common::shortcut(theme, "shift + tab / tab", "navigate"),
+
                        widget::common::shortcut(theme, "alt + s", "submit"),
+
                    ],
+
                ),
+
            ),
        ]
        .iter()
        .cloned()
@@ -461,13 +473,17 @@ impl ViewPage for IssuePage {
            Message::Issue(IssueMessage::OpenPopup(cid)) => {
                if cid == IssueCid::NewForm {
                    let new_form = widget::issue::new_form(context, theme).to_boxed();
-
                    app.remount(Cid::Issue(IssueCid::NewForm), new_form, vec![])?;
-
                    app.active(&Cid::Issue(IssueCid::NewForm))?;
+
                    app.remount(Cid::Issue(cid.clone()), new_form, vec![])?;
+
                    app.active(&Cid::Issue(cid.clone()))?;
+

+
                    self.update_shortcuts(app, cid)?;
                }
            }
            Message::Issue(IssueMessage::ClosePopup(cid)) => {
                app.blur()?;
                app.umount(&Cid::Issue(cid))?;
+

+
                self.update_shortcuts(app, IssueCid::List)?;
            }
            _ => {}
        }