diff --git a/src/app.rs b/src/app.rs index fc700da4..8c4b70c6 100644 --- a/src/app.rs +++ b/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(()) diff --git a/src/app/event.rs b/src/app/event.rs index 7163a984..6616ee95 100644 --- a/src/app/event.rs +++ b/src/app/event.rs @@ -79,7 +79,7 @@ impl tuirealm::Component for Widget { 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))) } diff --git a/src/app/page.rs b/src/app/page.rs index 2e19afc7..d8425b7f 100644 --- a/src/app/page.rs +++ b/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)?; } _ => {} }