mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Categorize Auth activity msg
This commit is contained in:
committed by
Christian Visintin
parent
4e802f1dc5
commit
84cb775679
@@ -25,7 +25,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
use super::Msg;
|
||||
use super::{FormMsg, Msg, UiMsg};
|
||||
|
||||
use tui_realm_stdlib::{Input, List, Radio};
|
||||
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
||||
@@ -99,16 +99,20 @@ impl Component<Msg, NoUserEvent> for BookmarksList {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => match self.state() {
|
||||
State::One(StateValue::Usize(choice)) => Some(Msg::LoadBookmark(choice)),
|
||||
State::One(StateValue::Usize(choice)) => {
|
||||
Some(Msg::Form(FormMsg::LoadBookmark(choice)))
|
||||
}
|
||||
_ => Some(Msg::None),
|
||||
},
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Right, ..
|
||||
}) => Some(Msg::BookmarksListBlur),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::BookmarksTabBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::BookmarksListBlur)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::BookmarksTabBlur))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Delete, ..
|
||||
}) => Some(Msg::ShowDeleteBookmarkPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowDeleteBookmarkPopup)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -180,16 +184,20 @@ impl Component<Msg, NoUserEvent> for RecentsList {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => match self.state() {
|
||||
State::One(StateValue::Usize(choice)) => Some(Msg::LoadRecent(choice)),
|
||||
State::One(StateValue::Usize(choice)) => {
|
||||
Some(Msg::Form(FormMsg::LoadRecent(choice)))
|
||||
}
|
||||
_ => Some(Msg::None),
|
||||
},
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => Some(Msg::RececentsListBlur),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::BookmarksTabBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::RececentsListBlur)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::BookmarksTabBlur))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Delete, ..
|
||||
}) => Some(Msg::ShowDeleteRecentPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowDeleteRecentPopup)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -223,7 +231,9 @@ impl DeleteBookmarkPopup {
|
||||
impl Component<Msg, NoUserEvent> for DeleteBookmarkPopup {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
match ev {
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::CloseDeleteBookmark),
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::CloseDeleteBookmark))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => {
|
||||
@@ -243,9 +253,9 @@ impl Component<Msg, NoUserEvent> for DeleteBookmarkPopup {
|
||||
self.perform(Cmd::Submit),
|
||||
CmdResult::Submit(State::One(StateValue::Usize(0)))
|
||||
) {
|
||||
Some(Msg::DeleteBookmark)
|
||||
Some(Msg::Form(FormMsg::DeleteBookmark))
|
||||
} else {
|
||||
Some(Msg::CloseDeleteBookmark)
|
||||
Some(Msg::Ui(UiMsg::CloseDeleteBookmark))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
@@ -281,7 +291,9 @@ impl DeleteRecentPopup {
|
||||
impl Component<Msg, NoUserEvent> for DeleteRecentPopup {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
match ev {
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::CloseDeleteRecent),
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::CloseDeleteRecent))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => {
|
||||
@@ -301,9 +313,9 @@ impl Component<Msg, NoUserEvent> for DeleteRecentPopup {
|
||||
self.perform(Cmd::Submit),
|
||||
CmdResult::Submit(State::One(StateValue::Usize(0)))
|
||||
) {
|
||||
Some(Msg::DeleteRecent)
|
||||
Some(Msg::Form(FormMsg::DeleteRecent))
|
||||
} else {
|
||||
Some(Msg::CloseDeleteRecent)
|
||||
Some(Msg::Ui(UiMsg::CloseDeleteRecent))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
@@ -342,7 +354,9 @@ impl BookmarkSavePassword {
|
||||
impl Component<Msg, NoUserEvent> for BookmarkSavePassword {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
match ev {
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::CloseSaveBookmark),
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::CloseSaveBookmark))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => {
|
||||
@@ -357,8 +371,10 @@ impl Component<Msg, NoUserEvent> for BookmarkSavePassword {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::SaveBookmark),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::SaveBookmarkPasswordBlur),
|
||||
}) => Some(Msg::Form(FormMsg::SaveBookmark)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::SaveBookmarkPasswordBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -391,7 +407,9 @@ impl BookmarkName {
|
||||
impl Component<Msg, NoUserEvent> for BookmarkName {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
match ev {
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::CloseSaveBookmark),
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::CloseSaveBookmark))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => {
|
||||
@@ -436,10 +454,10 @@ impl Component<Msg, NoUserEvent> for BookmarkName {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::SaveBookmark),
|
||||
}) => Some(Msg::Form(FormMsg::SaveBookmark)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::BookmarkNameBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::BookmarkNameBlur)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
use super::{FileTransferProtocol, Msg};
|
||||
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
|
||||
|
||||
use tui_realm_stdlib::{Input, Radio};
|
||||
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
||||
@@ -91,18 +91,22 @@ impl Component<Msg, NoUserEvent> for ProtocolRadio {
|
||||
}) => self.perform(Cmd::Move(Direction::Right)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => return Some(Msg::Connect),
|
||||
}) => return Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => return Some(Msg::ProtocolBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => return Some(Msg::ProtocolBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => return Some(Msg::ParamsFormBlur),
|
||||
}) => return Some(Msg::Ui(UiMsg::ProtocolBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||
return Some(Msg::Ui(UiMsg::ProtocolBlurUp))
|
||||
}
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
return Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
match result {
|
||||
CmdResult::Changed(State::One(StateValue::Usize(choice))) => {
|
||||
Some(Msg::ProtocolChanged(Self::protocol_opt_to_enum(choice)))
|
||||
}
|
||||
CmdResult::Changed(State::One(StateValue::Usize(choice))) => Some(Msg::Form(
|
||||
FormMsg::ProtocolChanged(Self::protocol_opt_to_enum(choice)),
|
||||
)),
|
||||
_ => Some(Msg::None),
|
||||
}
|
||||
}
|
||||
@@ -180,12 +184,14 @@ impl Component<Msg, NoUserEvent> for InputAddress {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::AddressBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::AddressBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::AddressBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::Ui(UiMsg::AddressBlurUp)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -264,12 +270,14 @@ impl Component<Msg, NoUserEvent> for InputPort {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::PortBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::PortBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::PortBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::Ui(UiMsg::PortBlurUp)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -347,12 +355,14 @@ impl Component<Msg, NoUserEvent> for InputUsername {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::UsernameBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::UsernameBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::UsernameBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::Ui(UiMsg::UsernameBlurUp)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -429,12 +439,14 @@ impl Component<Msg, NoUserEvent> for InputPassword {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::PasswordBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::PasswordBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::PasswordBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::Ui(UiMsg::PasswordBlurUp)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -512,12 +524,14 @@ impl Component<Msg, NoUserEvent> for InputS3Bucket {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::S3BucketBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::S3BucketBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::S3BucketBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::Ui(UiMsg::S3BucketBlurUp)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -595,12 +609,14 @@ impl Component<Msg, NoUserEvent> for InputS3Region {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::S3RegionBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::S3RegionBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::S3RegionBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::Ui(UiMsg::S3RegionBlurUp)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -678,12 +694,16 @@ impl Component<Msg, NoUserEvent> for InputS3Profile {
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Enter, ..
|
||||
}) => Some(Msg::Connect),
|
||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => Some(Msg::S3ProfileBlurDown),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => Some(Msg::S3ProfileBlurUp),
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => Some(Msg::ParamsFormBlur),
|
||||
}) => Some(Msg::Ui(UiMsg::S3ProfileBlurDown)),
|
||||
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::S3ProfileBlurUp))
|
||||
}
|
||||
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::ParamsFormBlur))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
use super::{FileTransferProtocol, Msg};
|
||||
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
|
||||
|
||||
mod bookmarks;
|
||||
mod form;
|
||||
@@ -63,27 +63,27 @@ impl Component<Msg, NoUserEvent> for GlobalListener {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Esc | Key::Function(10),
|
||||
..
|
||||
}) => Some(Msg::ShowQuitPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowQuitPopup)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Char('c'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}) => Some(Msg::EnterSetup),
|
||||
}) => Some(Msg::Form(FormMsg::EnterSetup)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Char('h'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}) => Some(Msg::ShowKeybindingsPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowKeybindingsPopup)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Function(1),
|
||||
..
|
||||
}) => Some(Msg::ShowKeybindingsPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowKeybindingsPopup)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Char('r'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}) => Some(Msg::ShowReleaseNotes),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowReleaseNotes)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Char('s'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
}) => Some(Msg::ShowSaveBookmarkPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::ShowSaveBookmarkPopup)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
use super::Msg;
|
||||
use super::{FormMsg, Msg, UiMsg};
|
||||
|
||||
use tui_realm_stdlib::{List, Paragraph, Radio, Textarea};
|
||||
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
||||
@@ -63,7 +63,7 @@ impl Component<Msg, NoUserEvent> for ErrorPopup {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Esc | Key::Enter,
|
||||
..
|
||||
}) => Some(Msg::CloseErrorPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::CloseErrorPopup)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ impl Component<Msg, NoUserEvent> for InfoPopup {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Esc | Key::Enter,
|
||||
..
|
||||
}) => Some(Msg::CloseInfoPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::CloseInfoPopup)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,9 @@ impl QuitPopup {
|
||||
impl Component<Msg, NoUserEvent> for QuitPopup {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
match ev {
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::CloseQuitPopup),
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::CloseQuitPopup))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => {
|
||||
@@ -214,9 +216,9 @@ impl Component<Msg, NoUserEvent> for QuitPopup {
|
||||
self.perform(Cmd::Submit),
|
||||
CmdResult::Submit(State::One(StateValue::Usize(0)))
|
||||
) {
|
||||
Some(Msg::Quit)
|
||||
Some(Msg::Form(FormMsg::Quit))
|
||||
} else {
|
||||
Some(Msg::CloseQuitPopup)
|
||||
Some(Msg::Ui(UiMsg::CloseQuitPopup))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
@@ -251,7 +253,9 @@ impl InstallUpdatePopup {
|
||||
impl Component<Msg, NoUserEvent> for InstallUpdatePopup {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
match ev {
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::CloseInstallUpdatePopup),
|
||||
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
|
||||
Some(Msg::Ui(UiMsg::CloseInstallUpdatePopup))
|
||||
}
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
}) => {
|
||||
@@ -271,9 +275,9 @@ impl Component<Msg, NoUserEvent> for InstallUpdatePopup {
|
||||
self.perform(Cmd::Submit),
|
||||
CmdResult::Submit(State::One(StateValue::Usize(0)))
|
||||
) {
|
||||
Some(Msg::InstallUpdate)
|
||||
Some(Msg::Form(FormMsg::InstallUpdate))
|
||||
} else {
|
||||
Some(Msg::CloseInstallUpdatePopup)
|
||||
Some(Msg::Ui(UiMsg::CloseInstallUpdatePopup))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
@@ -316,7 +320,7 @@ impl Component<Msg, NoUserEvent> for ReleaseNotes {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Esc | Key::Enter,
|
||||
..
|
||||
}) => Some(Msg::CloseInstallUpdatePopup),
|
||||
}) => Some(Msg::Ui(UiMsg::CloseInstallUpdatePopup)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => {
|
||||
@@ -412,7 +416,7 @@ impl Component<Msg, NoUserEvent> for Keybindings {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Esc | Key::Enter,
|
||||
..
|
||||
}) => Some(Msg::CloseKeybindingsPopup),
|
||||
}) => Some(Msg::Ui(UiMsg::CloseKeybindingsPopup)),
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Down, ..
|
||||
}) => {
|
||||
|
||||
@@ -78,6 +78,27 @@ pub enum Id {
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Msg {
|
||||
Form(FormMsg),
|
||||
Ui(UiMsg),
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum FormMsg {
|
||||
Connect,
|
||||
DeleteBookmark,
|
||||
DeleteRecent,
|
||||
EnterSetup,
|
||||
InstallUpdate,
|
||||
LoadBookmark(usize),
|
||||
LoadRecent(usize),
|
||||
ProtocolChanged(FileTransferProtocol),
|
||||
Quit,
|
||||
SaveBookmark,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum UiMsg {
|
||||
AddressBlurDown,
|
||||
AddressBlurUp,
|
||||
BookmarksListBlur,
|
||||
@@ -90,13 +111,6 @@ pub enum Msg {
|
||||
CloseKeybindingsPopup,
|
||||
CloseQuitPopup,
|
||||
CloseSaveBookmark,
|
||||
Connect,
|
||||
DeleteBookmark,
|
||||
DeleteRecent,
|
||||
EnterSetup,
|
||||
InstallUpdate,
|
||||
LoadBookmark(usize),
|
||||
LoadRecent(usize),
|
||||
ParamsFormBlur,
|
||||
PasswordBlurDown,
|
||||
PasswordBlurUp,
|
||||
@@ -104,8 +118,6 @@ pub enum Msg {
|
||||
PortBlurUp,
|
||||
ProtocolBlurDown,
|
||||
ProtocolBlurUp,
|
||||
ProtocolChanged(FileTransferProtocol),
|
||||
Quit,
|
||||
RececentsListBlur,
|
||||
S3BucketBlurDown,
|
||||
S3BucketBlurUp,
|
||||
@@ -113,7 +125,6 @@ pub enum Msg {
|
||||
S3ProfileBlurUp,
|
||||
S3RegionBlurDown,
|
||||
S3RegionBlurUp,
|
||||
SaveBookmark,
|
||||
BookmarkNameBlur,
|
||||
SaveBookmarkPasswordBlur,
|
||||
ShowDeleteBookmarkPopup,
|
||||
@@ -124,7 +135,6 @@ pub enum Msg {
|
||||
ShowSaveBookmarkPopup,
|
||||
UsernameBlurDown,
|
||||
UsernameBlurUp,
|
||||
None,
|
||||
}
|
||||
|
||||
/// Auth form input mask
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
use super::{AuthActivity, ExitReason, Id, InputMask, Msg, Update};
|
||||
use super::{AuthActivity, ExitReason, FormMsg, Id, InputMask, Msg, UiMsg, Update};
|
||||
|
||||
use tuirealm::{State, StateValue};
|
||||
|
||||
@@ -33,46 +33,17 @@ impl Update<Msg> for AuthActivity {
|
||||
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {
|
||||
self.redraw = true;
|
||||
match msg.unwrap_or(Msg::None) {
|
||||
Msg::AddressBlurDown => {
|
||||
assert!(self.app.active(&Id::Port).is_ok());
|
||||
}
|
||||
Msg::AddressBlurUp => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
Msg::BookmarksListBlur => {
|
||||
assert!(self.app.active(&Id::RecentsList).is_ok());
|
||||
}
|
||||
Msg::BookmarkNameBlur => {
|
||||
assert!(self.app.active(&Id::BookmarkSavePassword).is_ok());
|
||||
}
|
||||
Msg::BookmarksTabBlur => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
Msg::CloseDeleteBookmark => {
|
||||
assert!(self.app.umount(&Id::DeleteBookmarkPopup).is_ok());
|
||||
}
|
||||
Msg::CloseDeleteRecent => {
|
||||
assert!(self.app.umount(&Id::DeleteRecentPopup).is_ok());
|
||||
}
|
||||
Msg::CloseErrorPopup => {
|
||||
self.umount_error();
|
||||
}
|
||||
Msg::CloseInfoPopup => {
|
||||
self.umount_info();
|
||||
}
|
||||
Msg::CloseInstallUpdatePopup => {
|
||||
assert!(self.app.umount(&Id::NewVersionChangelog).is_ok());
|
||||
assert!(self.app.umount(&Id::InstallUpdatePopup).is_ok());
|
||||
}
|
||||
Msg::CloseKeybindingsPopup => {
|
||||
self.umount_help();
|
||||
}
|
||||
Msg::CloseQuitPopup => self.umount_quit(),
|
||||
Msg::CloseSaveBookmark => {
|
||||
assert!(self.app.umount(&Id::BookmarkName).is_ok());
|
||||
assert!(self.app.umount(&Id::BookmarkSavePassword).is_ok());
|
||||
}
|
||||
Msg::Connect => {
|
||||
Msg::Form(msg) => self.update_form(msg),
|
||||
Msg::Ui(msg) => self.update_ui(msg),
|
||||
Msg::None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AuthActivity {
|
||||
fn update_form(&mut self, msg: FormMsg) -> Option<Msg> {
|
||||
match msg {
|
||||
FormMsg::Connect => {
|
||||
match self.collect_host_params() {
|
||||
Err(err) => {
|
||||
// mount error
|
||||
@@ -87,7 +58,7 @@ impl Update<Msg> for AuthActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg::DeleteBookmark => {
|
||||
FormMsg::DeleteBookmark => {
|
||||
if let Ok(State::One(StateValue::Usize(idx))) = self.app.state(&Id::BookmarksList) {
|
||||
// Umount dialog
|
||||
self.umount_bookmark_del_dialog();
|
||||
@@ -97,7 +68,7 @@ impl Update<Msg> for AuthActivity {
|
||||
self.view_bookmarks()
|
||||
}
|
||||
}
|
||||
Msg::DeleteRecent => {
|
||||
FormMsg::DeleteRecent => {
|
||||
if let Ok(State::One(StateValue::Usize(idx))) = self.app.state(&Id::RecentsList) {
|
||||
// Umount dialog
|
||||
self.umount_recent_del_dialog();
|
||||
@@ -107,13 +78,13 @@ impl Update<Msg> for AuthActivity {
|
||||
self.view_recent_connections();
|
||||
}
|
||||
}
|
||||
Msg::EnterSetup => {
|
||||
FormMsg::EnterSetup => {
|
||||
self.exit_reason = Some(ExitReason::EnterSetup);
|
||||
}
|
||||
Msg::InstallUpdate => {
|
||||
FormMsg::InstallUpdate => {
|
||||
self.install_update();
|
||||
}
|
||||
Msg::LoadBookmark(i) => {
|
||||
FormMsg::LoadBookmark(i) => {
|
||||
self.load_bookmark(i);
|
||||
// Give focus to input password (or to protocol if not generic)
|
||||
assert!(self
|
||||
@@ -124,7 +95,7 @@ impl Update<Msg> for AuthActivity {
|
||||
})
|
||||
.is_ok());
|
||||
}
|
||||
Msg::LoadRecent(i) => {
|
||||
FormMsg::LoadRecent(i) => {
|
||||
self.load_recent(i);
|
||||
// Give focus to input password (or to protocol if not generic)
|
||||
assert!(self
|
||||
@@ -135,40 +106,7 @@ impl Update<Msg> for AuthActivity {
|
||||
})
|
||||
.is_ok());
|
||||
}
|
||||
Msg::ParamsFormBlur => {
|
||||
assert!(self.app.active(&Id::BookmarksList).is_ok());
|
||||
}
|
||||
Msg::PasswordBlurDown => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
Msg::PasswordBlurUp => {
|
||||
assert!(self.app.active(&Id::Username).is_ok());
|
||||
}
|
||||
Msg::PortBlurDown => {
|
||||
assert!(self.app.active(&Id::Username).is_ok());
|
||||
}
|
||||
Msg::PortBlurUp => {
|
||||
assert!(self.app.active(&Id::Address).is_ok());
|
||||
}
|
||||
Msg::ProtocolBlurDown => {
|
||||
assert!(self
|
||||
.app
|
||||
.active(match self.input_mask() {
|
||||
InputMask::Generic => &Id::Address,
|
||||
InputMask::AwsS3 => &Id::S3Bucket,
|
||||
})
|
||||
.is_ok());
|
||||
}
|
||||
Msg::ProtocolBlurUp => {
|
||||
assert!(self
|
||||
.app
|
||||
.active(match self.input_mask() {
|
||||
InputMask::Generic => &Id::Password,
|
||||
InputMask::AwsS3 => &Id::S3Profile,
|
||||
})
|
||||
.is_ok());
|
||||
}
|
||||
Msg::ProtocolChanged(protocol) => {
|
||||
FormMsg::ProtocolChanged(protocol) => {
|
||||
self.protocol = protocol;
|
||||
// Update port
|
||||
let port: u16 = self.get_input_port();
|
||||
@@ -176,31 +114,10 @@ impl Update<Msg> for AuthActivity {
|
||||
self.mount_port(Self::get_default_port_for_protocol(protocol));
|
||||
}
|
||||
}
|
||||
Msg::Quit => {
|
||||
FormMsg::Quit => {
|
||||
self.exit_reason = Some(ExitReason::Quit);
|
||||
}
|
||||
Msg::RececentsListBlur => {
|
||||
assert!(self.app.active(&Id::BookmarksList).is_ok());
|
||||
}
|
||||
Msg::S3BucketBlurDown => {
|
||||
assert!(self.app.active(&Id::S3Region).is_ok());
|
||||
}
|
||||
Msg::S3BucketBlurUp => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
Msg::S3RegionBlurDown => {
|
||||
assert!(self.app.active(&Id::S3Profile).is_ok());
|
||||
}
|
||||
Msg::S3RegionBlurUp => {
|
||||
assert!(self.app.active(&Id::S3Bucket).is_ok());
|
||||
}
|
||||
Msg::S3ProfileBlurDown => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
Msg::S3ProfileBlurUp => {
|
||||
assert!(self.app.active(&Id::S3Region).is_ok());
|
||||
}
|
||||
Msg::SaveBookmark => {
|
||||
FormMsg::SaveBookmark => {
|
||||
// get bookmark name
|
||||
let (name, save_password) = self.get_new_bookmark();
|
||||
// Save bookmark
|
||||
@@ -212,35 +129,134 @@ impl Update<Msg> for AuthActivity {
|
||||
// Reload bookmarks
|
||||
self.view_bookmarks()
|
||||
}
|
||||
Msg::SaveBookmarkPasswordBlur => {
|
||||
assert!(self.app.active(&Id::BookmarkName).is_ok());
|
||||
}
|
||||
Msg::ShowDeleteBookmarkPopup => {
|
||||
self.mount_bookmark_del_dialog();
|
||||
}
|
||||
Msg::ShowDeleteRecentPopup => {
|
||||
self.mount_recent_del_dialog();
|
||||
}
|
||||
Msg::ShowKeybindingsPopup => {
|
||||
self.mount_keybindings();
|
||||
}
|
||||
Msg::ShowQuitPopup => {
|
||||
self.mount_quit();
|
||||
}
|
||||
Msg::ShowReleaseNotes => {
|
||||
self.mount_release_notes();
|
||||
}
|
||||
Msg::ShowSaveBookmarkPopup => {
|
||||
self.mount_bookmark_save_dialog();
|
||||
}
|
||||
Msg::UsernameBlurDown => {
|
||||
assert!(self.app.active(&Id::Password).is_ok());
|
||||
}
|
||||
Msg::UsernameBlurUp => {
|
||||
assert!(self.app.active(&Id::Port).is_ok());
|
||||
}
|
||||
Msg::None => {}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn update_ui(&mut self, msg: UiMsg) -> Option<Msg> {
|
||||
match msg {
|
||||
UiMsg::AddressBlurDown => {
|
||||
assert!(self.app.active(&Id::Port).is_ok());
|
||||
}
|
||||
UiMsg::AddressBlurUp => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
UiMsg::BookmarksListBlur => {
|
||||
assert!(self.app.active(&Id::RecentsList).is_ok());
|
||||
}
|
||||
UiMsg::BookmarkNameBlur => {
|
||||
assert!(self.app.active(&Id::BookmarkSavePassword).is_ok());
|
||||
}
|
||||
UiMsg::BookmarksTabBlur => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
UiMsg::CloseDeleteBookmark => {
|
||||
assert!(self.app.umount(&Id::DeleteBookmarkPopup).is_ok());
|
||||
}
|
||||
UiMsg::CloseDeleteRecent => {
|
||||
assert!(self.app.umount(&Id::DeleteRecentPopup).is_ok());
|
||||
}
|
||||
UiMsg::CloseErrorPopup => {
|
||||
self.umount_error();
|
||||
}
|
||||
UiMsg::CloseInfoPopup => {
|
||||
self.umount_info();
|
||||
}
|
||||
UiMsg::CloseInstallUpdatePopup => {
|
||||
assert!(self.app.umount(&Id::NewVersionChangelog).is_ok());
|
||||
assert!(self.app.umount(&Id::InstallUpdatePopup).is_ok());
|
||||
}
|
||||
UiMsg::CloseKeybindingsPopup => {
|
||||
self.umount_help();
|
||||
}
|
||||
UiMsg::CloseQuitPopup => self.umount_quit(),
|
||||
UiMsg::CloseSaveBookmark => {
|
||||
assert!(self.app.umount(&Id::BookmarkName).is_ok());
|
||||
assert!(self.app.umount(&Id::BookmarkSavePassword).is_ok());
|
||||
}
|
||||
UiMsg::ParamsFormBlur => {
|
||||
assert!(self.app.active(&Id::BookmarksList).is_ok());
|
||||
}
|
||||
UiMsg::PasswordBlurDown => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
UiMsg::PasswordBlurUp => {
|
||||
assert!(self.app.active(&Id::Username).is_ok());
|
||||
}
|
||||
UiMsg::PortBlurDown => {
|
||||
assert!(self.app.active(&Id::Username).is_ok());
|
||||
}
|
||||
UiMsg::PortBlurUp => {
|
||||
assert!(self.app.active(&Id::Address).is_ok());
|
||||
}
|
||||
UiMsg::ProtocolBlurDown => {
|
||||
assert!(self
|
||||
.app
|
||||
.active(match self.input_mask() {
|
||||
InputMask::Generic => &Id::Address,
|
||||
InputMask::AwsS3 => &Id::S3Bucket,
|
||||
})
|
||||
.is_ok());
|
||||
}
|
||||
UiMsg::ProtocolBlurUp => {
|
||||
assert!(self
|
||||
.app
|
||||
.active(match self.input_mask() {
|
||||
InputMask::Generic => &Id::Password,
|
||||
InputMask::AwsS3 => &Id::S3Profile,
|
||||
})
|
||||
.is_ok());
|
||||
}
|
||||
UiMsg::RececentsListBlur => {
|
||||
assert!(self.app.active(&Id::BookmarksList).is_ok());
|
||||
}
|
||||
UiMsg::S3BucketBlurDown => {
|
||||
assert!(self.app.active(&Id::S3Region).is_ok());
|
||||
}
|
||||
UiMsg::S3BucketBlurUp => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
UiMsg::S3RegionBlurDown => {
|
||||
assert!(self.app.active(&Id::S3Profile).is_ok());
|
||||
}
|
||||
UiMsg::S3RegionBlurUp => {
|
||||
assert!(self.app.active(&Id::S3Bucket).is_ok());
|
||||
}
|
||||
UiMsg::S3ProfileBlurDown => {
|
||||
assert!(self.app.active(&Id::Protocol).is_ok());
|
||||
}
|
||||
UiMsg::S3ProfileBlurUp => {
|
||||
assert!(self.app.active(&Id::S3Region).is_ok());
|
||||
}
|
||||
UiMsg::SaveBookmarkPasswordBlur => {
|
||||
assert!(self.app.active(&Id::BookmarkName).is_ok());
|
||||
}
|
||||
UiMsg::ShowDeleteBookmarkPopup => {
|
||||
self.mount_bookmark_del_dialog();
|
||||
}
|
||||
UiMsg::ShowDeleteRecentPopup => {
|
||||
self.mount_recent_del_dialog();
|
||||
}
|
||||
UiMsg::ShowKeybindingsPopup => {
|
||||
self.mount_keybindings();
|
||||
}
|
||||
UiMsg::ShowQuitPopup => {
|
||||
self.mount_quit();
|
||||
}
|
||||
UiMsg::ShowReleaseNotes => {
|
||||
self.mount_release_notes();
|
||||
}
|
||||
UiMsg::ShowSaveBookmarkPopup => {
|
||||
self.mount_bookmark_save_dialog();
|
||||
}
|
||||
UiMsg::UsernameBlurDown => {
|
||||
assert!(self.app.active(&Id::Password).is_ok());
|
||||
}
|
||||
UiMsg::UsernameBlurUp => {
|
||||
assert!(self.app.active(&Id::Port).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user