From eac8bf59036b16cd2127e453396821dcc5781c05 Mon Sep 17 00:00:00 2001 From: Christian Visintin Date: Sat, 21 Mar 2026 13:34:18 +0100 Subject: [PATCH] refactor: split auth update handlers by context --- src/ui/activities/auth/update.rs | 1130 ++++++++++++------------------ 1 file changed, 461 insertions(+), 669 deletions(-) diff --git a/src/ui/activities/auth/update.rs b/src/ui/activities/auth/update.rs index 67e132a..12bf27c 100644 --- a/src/ui/activities/auth/update.rs +++ b/src/ui/activities/auth/update.rs @@ -171,72 +171,22 @@ impl AuthActivity { fn update_ui(&mut self, msg: UiMsg) -> Option { match msg { - UiMsg::HostBridge(UiAuthFormMsg::AddressBlurDown) => { - let id = if cfg!(windows) && self.host_bridge_input_mask() == InputMask::Smb { - &Id::HostBridge(AuthFormId::SmbShare) - } else { - &Id::HostBridge(AuthFormId::Port) - }; - if let Err(err) = self.app.active(id) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::AddressBlurDown) => { - let id = if cfg!(windows) && self.remote_input_mask() == InputMask::Smb { - &Id::Remote(AuthFormId::SmbShare) - } else { - &Id::Remote(AuthFormId::Port) - }; - if let Err(err) = self.app.active(id) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::AddressBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::AddressBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } + UiMsg::HostBridge(msg) => self.update_host_bridge_ui(msg), + UiMsg::Remote(msg) => self.update_remote_ui(msg), UiMsg::BookmarksListBlur => { - if let Err(err) = self.app.active(&Id::RecentsList) { - error!("Failed to activate component: {err}"); - } + self.activate_component(Id::RecentsList); } UiMsg::BookmarkNameBlur => { - if let Err(err) = self.app.active(&Id::BookmarkSavePassword) { - error!("Failed to activate component: {err}"); - } + self.activate_component(Id::BookmarkSavePassword); } UiMsg::BookmarksTabBlur => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::ChangeFormTab) => { - self.last_form_tab = FormTab::Remote; - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::ChangeFormTab) => { - self.last_form_tab = FormTab::HostBridge; - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } + self.activate_component(Id::HostBridge(AuthFormId::Protocol)); } UiMsg::CloseDeleteBookmark => { - if let Err(err) = self.app.umount(&Id::DeleteBookmarkPopup) { - error!("Failed to umount component: {err}"); - } + self.umount_component(Id::DeleteBookmarkPopup); } UiMsg::CloseDeleteRecent => { - if let Err(err) = self.app.umount(&Id::DeleteRecentPopup) { - error!("Failed to umount component: {err}"); - } + self.umount_component(Id::DeleteRecentPopup); } UiMsg::CloseErrorPopup => { self.umount_error(); @@ -245,574 +195,22 @@ impl AuthActivity { self.umount_info(); } UiMsg::CloseInstallUpdatePopup => { - if let Err(err) = self.app.umount(&Id::NewVersionChangelog) { - error!("Failed to umount component: {err}"); - } - if let Err(err) = self.app.umount(&Id::InstallUpdatePopup) { - error!("Failed to umount component: {err}"); - } + self.umount_component(Id::NewVersionChangelog); + self.umount_component(Id::InstallUpdatePopup); } UiMsg::CloseKeybindingsPopup => { self.umount_help(); } UiMsg::CloseQuitPopup => self.umount_quit(), UiMsg::CloseSaveBookmark => { - if let Err(err) = self.app.umount(&Id::BookmarkName) { - error!("Failed to umount component: {err}"); - } - if let Err(err) = self.app.umount(&Id::BookmarkSavePassword) { - error!("Failed to umount component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::LocalDirectoryBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::LocalDirectoryBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::LocalDirectoryBlurUp) => { - if let Err(err) = self.app.active(match self.host_bridge_input_mask() { - InputMask::Localhost => &Id::HostBridge(AuthFormId::Protocol), - _ => &Id::HostBridge(AuthFormId::RemoteDirectory), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::LocalDirectoryBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::RemoteDirectory)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::ParamsFormBlur) => { - if let Err(err) = self.app.active(&Id::BookmarksList) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::ParamsFormBlur) => { - if let Err(err) = self.app.active(&Id::BookmarksList) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::PasswordBlurDown) => { - if let Err(err) = self.app.active(match self.host_bridge_input_mask() { - InputMask::Localhost => unreachable!(), - InputMask::Generic => &Id::HostBridge(AuthFormId::RemoteDirectory), - #[cfg(posix)] - InputMask::Smb => &Id::HostBridge(AuthFormId::SmbWorkgroup), - #[cfg(win)] - InputMask::Smb => &Id::HostBridge(AuthFormId::RemoteDirectory), - InputMask::AwsS3 => unreachable!("this shouldn't happen (password on s3)"), - InputMask::Kube => unreachable!("this shouldn't happen (password on kube)"), - InputMask::WebDAV => &Id::HostBridge(AuthFormId::RemoteDirectory), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::PasswordBlurDown) => { - if let Err(err) = self.app.active(match self.remote_input_mask() { - InputMask::Localhost => unreachable!(), - InputMask::Generic => &Id::Remote(AuthFormId::RemoteDirectory), - #[cfg(posix)] - InputMask::Smb => &Id::Remote(AuthFormId::SmbWorkgroup), - #[cfg(win)] - InputMask::Smb => &Id::Remote(AuthFormId::RemoteDirectory), - InputMask::AwsS3 => unreachable!("this shouldn't happen (password on s3)"), - InputMask::Kube => unreachable!("this shouldn't happen (password on kube)"), - InputMask::WebDAV => &Id::Remote(AuthFormId::RemoteDirectory), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::PasswordBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Username)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::PasswordBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Username)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::PortBlurDown) => { - if let Err(err) = self.app.active(match self.host_bridge_input_mask() { - InputMask::Generic => &Id::HostBridge(AuthFormId::Username), - InputMask::Smb => &Id::HostBridge(AuthFormId::SmbShare), - InputMask::Localhost - | InputMask::AwsS3 - | InputMask::Kube - | InputMask::WebDAV => { - unreachable!("this shouldn't happen (port on s3/kube/webdav)") - } - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::PortBlurDown) => { - if let Err(err) = self.app.active(match self.remote_input_mask() { - InputMask::Generic => &Id::Remote(AuthFormId::Username), - InputMask::Smb => &Id::Remote(AuthFormId::SmbShare), - InputMask::Localhost - | InputMask::AwsS3 - | InputMask::Kube - | InputMask::WebDAV => { - unreachable!("this shouldn't happen (port on s3/kube/webdav)") - } - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::PortBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Address)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::PortBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Address)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::ProtocolBlurDown) => { - if let Err(err) = self.app.active(match self.host_bridge_input_mask() { - InputMask::Localhost => &Id::HostBridge(AuthFormId::LocalDirectory), - InputMask::Generic => &Id::HostBridge(AuthFormId::Address), - InputMask::Smb => &Id::HostBridge(AuthFormId::Address), - InputMask::AwsS3 => &Id::HostBridge(AuthFormId::S3Bucket), - InputMask::Kube => &Id::HostBridge(AuthFormId::KubeNamespace), - InputMask::WebDAV => &Id::HostBridge(AuthFormId::WebDAVUri), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::ProtocolBlurDown) => { - if let Err(err) = self.app.active(match self.remote_input_mask() { - InputMask::Localhost => &Id::Remote(AuthFormId::LocalDirectory), - InputMask::Generic => &Id::Remote(AuthFormId::Address), - InputMask::Smb => &Id::Remote(AuthFormId::Address), - InputMask::AwsS3 => &Id::Remote(AuthFormId::S3Bucket), - InputMask::Kube => &Id::Remote(AuthFormId::KubeNamespace), - InputMask::WebDAV => &Id::Remote(AuthFormId::WebDAVUri), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::ProtocolBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::LocalDirectory)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::ProtocolBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::LocalDirectory)) { - error!("Failed to activate component: {err}"); - } + self.umount_component(Id::BookmarkName); + self.umount_component(Id::BookmarkSavePassword); } UiMsg::RececentsListBlur => { - if let Err(err) = self.app.active(&Id::BookmarksList) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::RemoteDirectoryBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::LocalDirectory)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::RemoteDirectoryBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::LocalDirectory)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::RemoteDirectoryBlurUp) => { - if let Err(err) = self.app.active(match self.host_bridge_input_mask() { - InputMask::Localhost => unreachable!(), - InputMask::Generic => &Id::HostBridge(AuthFormId::Password), - #[cfg(posix)] - InputMask::Smb => &Id::HostBridge(AuthFormId::SmbWorkgroup), - #[cfg(win)] - InputMask::Smb => &Id::HostBridge(AuthFormId::Password), - InputMask::Kube => &Id::HostBridge(AuthFormId::KubeClientKey), - InputMask::AwsS3 => &Id::HostBridge(AuthFormId::S3NewPathStyle), - InputMask::WebDAV => &Id::HostBridge(AuthFormId::Password), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::RemoteDirectoryBlurUp) => { - if let Err(err) = self.app.active(match self.remote_input_mask() { - InputMask::Localhost => unreachable!(), - InputMask::Generic => &Id::Remote(AuthFormId::Password), - #[cfg(posix)] - InputMask::Smb => &Id::Remote(AuthFormId::SmbWorkgroup), - #[cfg(win)] - InputMask::Smb => &Id::Remote(AuthFormId::Password), - InputMask::Kube => &Id::Remote(AuthFormId::KubeClientKey), - InputMask::AwsS3 => &Id::Remote(AuthFormId::S3NewPathStyle), - InputMask::WebDAV => &Id::Remote(AuthFormId::Password), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3BucketBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Region)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3BucketBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Region)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3BucketBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3BucketBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3RegionBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Endpoint)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3RegionBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Endpoint)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3RegionBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Bucket)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3RegionBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Bucket)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3EndpointBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Profile)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3EndpointBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Profile)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3EndpointBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Region)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3EndpointBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Region)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3ProfileBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3AccessKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3ProfileBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3AccessKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3ProfileBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Endpoint)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3ProfileBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Endpoint)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3AccessKeyBlurDown) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::S3SecretAccessKey)) - { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3AccessKeyBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3SecretAccessKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3AccessKeyBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3Profile)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3AccessKeyBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3Profile)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3SecretAccessKeyBlurDown) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::S3SecurityToken)) - { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3SecretAccessKeyBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3SecurityToken)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3SecretAccessKeyBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3AccessKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3SecretAccessKeyBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3AccessKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3SecurityTokenBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3SessionToken)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3SecurityTokenBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3SessionToken)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3SecurityTokenBlurUp) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::S3SecretAccessKey)) - { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3SecurityTokenBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3SecretAccessKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3SessionTokenBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3NewPathStyle)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3SessionTokenBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3NewPathStyle)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3SessionTokenBlurUp) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::S3SecurityToken)) - { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3SessionTokenBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3SecurityToken)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3NewPathStyleBlurDown) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::RemoteDirectory)) - { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3NewPathStyleBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::RemoteDirectory)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::S3NewPathStyleBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::S3SessionToken)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::S3NewPathStyleBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::S3SessionToken)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeClientCertBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeClientKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeClientCertBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeClientKey)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeClientCertBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeUsername)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeClientCertBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeUsername)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeClientKeyBlurDown) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::RemoteDirectory)) - { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeClientKeyBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::RemoteDirectory)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeClientKeyBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeClientCert)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeClientKeyBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeClientCert)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeNamespaceBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeClusterUrl)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeNamespaceBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeClusterUrl)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeNamespaceBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeNamespaceBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeClusterUrlBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeUsername)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeClusterUrlBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeUsername)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeClusterUrlBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeNamespace)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeClusterUrlBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeNamespace)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeUsernameBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeClientCert)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeUsernameBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeClientCert)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::KubeUsernameBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::KubeClusterUrl)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::KubeUsernameBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::KubeClusterUrl)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::SmbShareBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Username)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::SmbShareBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Username)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::SmbShareBlurUp) => { - let id = if cfg!(windows) && self.host_bridge_input_mask() == InputMask::Smb { - &Id::HostBridge(AuthFormId::Address) - } else { - &Id::HostBridge(AuthFormId::Port) - }; - if let Err(err) = self.app.active(id) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::SmbShareBlurUp) => { - let id = if cfg!(windows) && self.remote_input_mask() == InputMask::Smb { - &Id::Remote(AuthFormId::Address) - } else { - &Id::Remote(AuthFormId::Port) - }; - if let Err(err) = self.app.active(id) { - error!("Failed to activate component: {err}"); - } - } - #[cfg(posix)] - UiMsg::HostBridge(UiAuthFormMsg::SmbWorkgroupDown) => { - if let Err(err) = self - .app - .active(&Id::HostBridge(AuthFormId::RemoteDirectory)) - { - error!("Failed to activate component: {err}"); - } - } - #[cfg(posix)] - UiMsg::Remote(UiAuthFormMsg::SmbWorkgroupDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::RemoteDirectory)) { - error!("Failed to activate component: {err}"); - } - } - #[cfg(posix)] - UiMsg::HostBridge(UiAuthFormMsg::SmbWorkgroupUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Password)) { - error!("Failed to activate component: {err}"); - } - } - #[cfg(posix)] - UiMsg::Remote(UiAuthFormMsg::SmbWorkgroupUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Password)) { - error!("Failed to activate component: {err}"); - } + self.activate_component(Id::BookmarksList); } UiMsg::SaveBookmarkPasswordBlur => { - if let Err(err) = self.app.active(&Id::BookmarkName) { - error!("Failed to activate component: {err}"); - } + self.activate_component(Id::BookmarkName); } UiMsg::ShowDeleteBookmarkPopup => { self.mount_bookmark_del_dialog(); @@ -832,60 +230,6 @@ impl AuthActivity { UiMsg::ShowSaveBookmarkPopup => { self.mount_bookmark_save_dialog(self.get_current_form_tab()); } - UiMsg::HostBridge(UiAuthFormMsg::UsernameBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Password)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::UsernameBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Password)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::UsernameBlurUp) => { - if let Err(err) = self.app.active(match self.host_bridge_input_mask() { - InputMask::Localhost => unreachable!(), - InputMask::Generic => &Id::HostBridge(AuthFormId::Port), - InputMask::Smb => &Id::HostBridge(AuthFormId::SmbShare), - InputMask::Kube => unreachable!("this shouldn't happen (username on kube)"), - InputMask::AwsS3 => unreachable!("this shouldn't happen (username on s3)"), - InputMask::WebDAV => &Id::HostBridge(AuthFormId::WebDAVUri), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::UsernameBlurUp) => { - if let Err(err) = self.app.active(match self.remote_input_mask() { - InputMask::Localhost => unreachable!(), - InputMask::Generic => &Id::Remote(AuthFormId::Port), - InputMask::Smb => &Id::Remote(AuthFormId::SmbShare), - InputMask::Kube => unreachable!("this shouldn't happen (username on kube)"), - InputMask::AwsS3 => unreachable!("this shouldn't happen (username on s3)"), - InputMask::WebDAV => &Id::Remote(AuthFormId::WebDAVUri), - }) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::WebDAVUriBlurDown) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Username)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::WebDAVUriBlurDown) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Username)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::HostBridge(UiAuthFormMsg::WebDAVUriBlurUp) => { - if let Err(err) = self.app.active(&Id::HostBridge(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } - UiMsg::Remote(UiAuthFormMsg::WebDAVUriBlurUp) => { - if let Err(err) = self.app.active(&Id::Remote(AuthFormId::Protocol)) { - error!("Failed to activate component: {err}"); - } - } UiMsg::WindowResized => { self.redraw = true; } @@ -893,4 +237,452 @@ impl AuthActivity { None } + + fn update_host_bridge_ui(&mut self, msg: UiAuthFormMsg) { + match msg { + UiAuthFormMsg::AddressBlurDown => { + let id = if cfg!(windows) && self.host_bridge_input_mask() == InputMask::Smb { + Id::HostBridge(AuthFormId::SmbShare) + } else { + Id::HostBridge(AuthFormId::Port) + }; + self.activate_component(id); + } + UiAuthFormMsg::AddressBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::Protocol)); + } + UiAuthFormMsg::ChangeFormTab => { + self.last_form_tab = FormTab::Remote; + self.activate_component(Id::Remote(AuthFormId::Protocol)); + } + UiAuthFormMsg::LocalDirectoryBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::Protocol)); + } + UiAuthFormMsg::LocalDirectoryBlurUp => { + let id = match self.host_bridge_input_mask() { + InputMask::Localhost => Id::HostBridge(AuthFormId::Protocol), + _ => Id::HostBridge(AuthFormId::RemoteDirectory), + }; + self.activate_component(id); + } + UiAuthFormMsg::ParamsFormBlur => { + self.activate_component(Id::BookmarksList); + } + UiAuthFormMsg::PasswordBlurDown => { + let id = match self.host_bridge_input_mask() { + InputMask::Localhost => unreachable!(), + InputMask::Generic => Id::HostBridge(AuthFormId::RemoteDirectory), + #[cfg(posix)] + InputMask::Smb => Id::HostBridge(AuthFormId::SmbWorkgroup), + #[cfg(win)] + InputMask::Smb => Id::HostBridge(AuthFormId::RemoteDirectory), + InputMask::AwsS3 => unreachable!("this shouldn't happen (password on s3)"), + InputMask::Kube => unreachable!("this shouldn't happen (password on kube)"), + InputMask::WebDAV => Id::HostBridge(AuthFormId::RemoteDirectory), + }; + self.activate_component(id); + } + UiAuthFormMsg::PasswordBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::Username)); + } + UiAuthFormMsg::PortBlurDown => { + let id = match self.host_bridge_input_mask() { + InputMask::Generic => Id::HostBridge(AuthFormId::Username), + InputMask::Smb => Id::HostBridge(AuthFormId::SmbShare), + InputMask::Localhost + | InputMask::AwsS3 + | InputMask::Kube + | InputMask::WebDAV => { + unreachable!("this shouldn't happen (port on s3/kube/webdav)") + } + }; + self.activate_component(id); + } + UiAuthFormMsg::PortBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::Address)); + } + UiAuthFormMsg::ProtocolBlurDown => { + let id = match self.host_bridge_input_mask() { + InputMask::Localhost => Id::HostBridge(AuthFormId::LocalDirectory), + InputMask::Generic => Id::HostBridge(AuthFormId::Address), + InputMask::Smb => Id::HostBridge(AuthFormId::Address), + InputMask::AwsS3 => Id::HostBridge(AuthFormId::S3Bucket), + InputMask::Kube => Id::HostBridge(AuthFormId::KubeNamespace), + InputMask::WebDAV => Id::HostBridge(AuthFormId::WebDAVUri), + }; + self.activate_component(id); + } + UiAuthFormMsg::ProtocolBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::LocalDirectory)); + } + UiAuthFormMsg::RemoteDirectoryBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::LocalDirectory)); + } + UiAuthFormMsg::RemoteDirectoryBlurUp => { + let id = match self.host_bridge_input_mask() { + InputMask::Localhost => unreachable!(), + InputMask::Generic => Id::HostBridge(AuthFormId::Password), + #[cfg(posix)] + InputMask::Smb => Id::HostBridge(AuthFormId::SmbWorkgroup), + #[cfg(win)] + InputMask::Smb => Id::HostBridge(AuthFormId::Password), + InputMask::Kube => Id::HostBridge(AuthFormId::KubeClientKey), + InputMask::AwsS3 => Id::HostBridge(AuthFormId::S3NewPathStyle), + InputMask::WebDAV => Id::HostBridge(AuthFormId::Password), + }; + self.activate_component(id); + } + UiAuthFormMsg::S3BucketBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3Region)) + } + UiAuthFormMsg::S3BucketBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::Protocol)) + } + UiAuthFormMsg::S3RegionBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3Endpoint)) + } + UiAuthFormMsg::S3RegionBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3Bucket)) + } + UiAuthFormMsg::S3EndpointBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3Profile)) + } + UiAuthFormMsg::S3EndpointBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3Region)) + } + UiAuthFormMsg::S3ProfileBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3AccessKey)) + } + UiAuthFormMsg::S3ProfileBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3Endpoint)) + } + UiAuthFormMsg::S3AccessKeyBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3SecretAccessKey)) + } + UiAuthFormMsg::S3AccessKeyBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3Profile)) + } + UiAuthFormMsg::S3SecretAccessKeyBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3SecurityToken)) + } + UiAuthFormMsg::S3SecretAccessKeyBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3AccessKey)) + } + UiAuthFormMsg::S3SecurityTokenBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3SessionToken)) + } + UiAuthFormMsg::S3SecurityTokenBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3SecretAccessKey)) + } + UiAuthFormMsg::S3SessionTokenBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::S3NewPathStyle)) + } + UiAuthFormMsg::S3SessionTokenBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3SecurityToken)) + } + UiAuthFormMsg::S3NewPathStyleBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::RemoteDirectory)) + } + UiAuthFormMsg::S3NewPathStyleBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::S3SessionToken)) + } + UiAuthFormMsg::KubeClientCertBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::KubeClientKey)) + } + UiAuthFormMsg::KubeClientCertBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::KubeUsername)) + } + UiAuthFormMsg::KubeClientKeyBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::RemoteDirectory)) + } + UiAuthFormMsg::KubeClientKeyBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::KubeClientCert)) + } + UiAuthFormMsg::KubeNamespaceBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::KubeClusterUrl)) + } + UiAuthFormMsg::KubeNamespaceBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::Protocol)) + } + UiAuthFormMsg::KubeClusterUrlBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::KubeUsername)) + } + UiAuthFormMsg::KubeClusterUrlBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::KubeNamespace)) + } + UiAuthFormMsg::KubeUsernameBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::KubeClientCert)) + } + UiAuthFormMsg::KubeUsernameBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::KubeClusterUrl)) + } + UiAuthFormMsg::SmbShareBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::Username)) + } + UiAuthFormMsg::SmbShareBlurUp => { + let id = if cfg!(windows) && self.host_bridge_input_mask() == InputMask::Smb { + Id::HostBridge(AuthFormId::Address) + } else { + Id::HostBridge(AuthFormId::Port) + }; + self.activate_component(id); + } + #[cfg(posix)] + UiAuthFormMsg::SmbWorkgroupDown => { + self.activate_component(Id::HostBridge(AuthFormId::RemoteDirectory)) + } + #[cfg(posix)] + UiAuthFormMsg::SmbWorkgroupUp => { + self.activate_component(Id::HostBridge(AuthFormId::Password)) + } + UiAuthFormMsg::UsernameBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::Password)) + } + UiAuthFormMsg::UsernameBlurUp => { + let id = match self.host_bridge_input_mask() { + InputMask::Localhost => unreachable!(), + InputMask::Generic => Id::HostBridge(AuthFormId::Port), + InputMask::Smb => Id::HostBridge(AuthFormId::SmbShare), + InputMask::Kube => unreachable!("this shouldn't happen (username on kube)"), + InputMask::AwsS3 => unreachable!("this shouldn't happen (username on s3)"), + InputMask::WebDAV => Id::HostBridge(AuthFormId::WebDAVUri), + }; + self.activate_component(id); + } + UiAuthFormMsg::WebDAVUriBlurDown => { + self.activate_component(Id::HostBridge(AuthFormId::Username)) + } + UiAuthFormMsg::WebDAVUriBlurUp => { + self.activate_component(Id::HostBridge(AuthFormId::Protocol)) + } + } + } + + fn update_remote_ui(&mut self, msg: UiAuthFormMsg) { + match msg { + UiAuthFormMsg::AddressBlurDown => { + let id = if cfg!(windows) && self.remote_input_mask() == InputMask::Smb { + Id::Remote(AuthFormId::SmbShare) + } else { + Id::Remote(AuthFormId::Port) + }; + self.activate_component(id); + } + UiAuthFormMsg::AddressBlurUp => { + self.activate_component(Id::Remote(AuthFormId::Protocol)); + } + UiAuthFormMsg::ChangeFormTab => { + self.last_form_tab = FormTab::HostBridge; + self.activate_component(Id::HostBridge(AuthFormId::Protocol)); + } + UiAuthFormMsg::LocalDirectoryBlurDown => { + self.activate_component(Id::Remote(AuthFormId::Protocol)); + } + UiAuthFormMsg::LocalDirectoryBlurUp => { + self.activate_component(Id::Remote(AuthFormId::RemoteDirectory)); + } + UiAuthFormMsg::ParamsFormBlur => { + self.activate_component(Id::BookmarksList); + } + UiAuthFormMsg::PasswordBlurDown => { + let id = match self.remote_input_mask() { + InputMask::Localhost => unreachable!(), + InputMask::Generic => Id::Remote(AuthFormId::RemoteDirectory), + #[cfg(posix)] + InputMask::Smb => Id::Remote(AuthFormId::SmbWorkgroup), + #[cfg(win)] + InputMask::Smb => Id::Remote(AuthFormId::RemoteDirectory), + InputMask::AwsS3 => unreachable!("this shouldn't happen (password on s3)"), + InputMask::Kube => unreachable!("this shouldn't happen (password on kube)"), + InputMask::WebDAV => Id::Remote(AuthFormId::RemoteDirectory), + }; + self.activate_component(id); + } + UiAuthFormMsg::PasswordBlurUp => { + self.activate_component(Id::Remote(AuthFormId::Username)); + } + UiAuthFormMsg::PortBlurDown => { + let id = match self.remote_input_mask() { + InputMask::Generic => Id::Remote(AuthFormId::Username), + InputMask::Smb => Id::Remote(AuthFormId::SmbShare), + InputMask::Localhost + | InputMask::AwsS3 + | InputMask::Kube + | InputMask::WebDAV => { + unreachable!("this shouldn't happen (port on s3/kube/webdav)") + } + }; + self.activate_component(id); + } + UiAuthFormMsg::PortBlurUp => { + self.activate_component(Id::Remote(AuthFormId::Address)); + } + UiAuthFormMsg::ProtocolBlurDown => { + let id = match self.remote_input_mask() { + InputMask::Localhost => Id::Remote(AuthFormId::LocalDirectory), + InputMask::Generic => Id::Remote(AuthFormId::Address), + InputMask::Smb => Id::Remote(AuthFormId::Address), + InputMask::AwsS3 => Id::Remote(AuthFormId::S3Bucket), + InputMask::Kube => Id::Remote(AuthFormId::KubeNamespace), + InputMask::WebDAV => Id::Remote(AuthFormId::WebDAVUri), + }; + self.activate_component(id); + } + UiAuthFormMsg::ProtocolBlurUp => { + self.activate_component(Id::Remote(AuthFormId::LocalDirectory)); + } + UiAuthFormMsg::RemoteDirectoryBlurDown => { + self.activate_component(Id::Remote(AuthFormId::LocalDirectory)); + } + UiAuthFormMsg::RemoteDirectoryBlurUp => { + let id = match self.remote_input_mask() { + InputMask::Localhost => unreachable!(), + InputMask::Generic => Id::Remote(AuthFormId::Password), + #[cfg(posix)] + InputMask::Smb => Id::Remote(AuthFormId::SmbWorkgroup), + #[cfg(win)] + InputMask::Smb => Id::Remote(AuthFormId::Password), + InputMask::Kube => Id::Remote(AuthFormId::KubeClientKey), + InputMask::AwsS3 => Id::Remote(AuthFormId::S3NewPathStyle), + InputMask::WebDAV => Id::Remote(AuthFormId::Password), + }; + self.activate_component(id); + } + UiAuthFormMsg::S3BucketBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3Region)) + } + UiAuthFormMsg::S3BucketBlurUp => { + self.activate_component(Id::Remote(AuthFormId::Protocol)) + } + UiAuthFormMsg::S3RegionBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3Endpoint)) + } + UiAuthFormMsg::S3RegionBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3Bucket)) + } + UiAuthFormMsg::S3EndpointBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3Profile)) + } + UiAuthFormMsg::S3EndpointBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3Region)) + } + UiAuthFormMsg::S3ProfileBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3AccessKey)) + } + UiAuthFormMsg::S3ProfileBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3Endpoint)) + } + UiAuthFormMsg::S3AccessKeyBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3SecretAccessKey)) + } + UiAuthFormMsg::S3AccessKeyBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3Profile)) + } + UiAuthFormMsg::S3SecretAccessKeyBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3SecurityToken)) + } + UiAuthFormMsg::S3SecretAccessKeyBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3AccessKey)) + } + UiAuthFormMsg::S3SecurityTokenBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3SessionToken)) + } + UiAuthFormMsg::S3SecurityTokenBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3SecretAccessKey)) + } + UiAuthFormMsg::S3SessionTokenBlurDown => { + self.activate_component(Id::Remote(AuthFormId::S3NewPathStyle)) + } + UiAuthFormMsg::S3SessionTokenBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3SecurityToken)) + } + UiAuthFormMsg::S3NewPathStyleBlurDown => { + self.activate_component(Id::Remote(AuthFormId::RemoteDirectory)) + } + UiAuthFormMsg::S3NewPathStyleBlurUp => { + self.activate_component(Id::Remote(AuthFormId::S3SessionToken)) + } + UiAuthFormMsg::KubeClientCertBlurDown => { + self.activate_component(Id::Remote(AuthFormId::KubeClientKey)) + } + UiAuthFormMsg::KubeClientCertBlurUp => { + self.activate_component(Id::Remote(AuthFormId::KubeUsername)) + } + UiAuthFormMsg::KubeClientKeyBlurDown => { + self.activate_component(Id::Remote(AuthFormId::RemoteDirectory)) + } + UiAuthFormMsg::KubeClientKeyBlurUp => { + self.activate_component(Id::Remote(AuthFormId::KubeClientCert)) + } + UiAuthFormMsg::KubeNamespaceBlurDown => { + self.activate_component(Id::Remote(AuthFormId::KubeClusterUrl)) + } + UiAuthFormMsg::KubeNamespaceBlurUp => { + self.activate_component(Id::Remote(AuthFormId::Protocol)) + } + UiAuthFormMsg::KubeClusterUrlBlurDown => { + self.activate_component(Id::Remote(AuthFormId::KubeUsername)) + } + UiAuthFormMsg::KubeClusterUrlBlurUp => { + self.activate_component(Id::Remote(AuthFormId::KubeNamespace)) + } + UiAuthFormMsg::KubeUsernameBlurDown => { + self.activate_component(Id::Remote(AuthFormId::KubeClientCert)) + } + UiAuthFormMsg::KubeUsernameBlurUp => { + self.activate_component(Id::Remote(AuthFormId::KubeClusterUrl)) + } + UiAuthFormMsg::SmbShareBlurDown => { + self.activate_component(Id::Remote(AuthFormId::Username)) + } + UiAuthFormMsg::SmbShareBlurUp => { + let id = if cfg!(windows) && self.remote_input_mask() == InputMask::Smb { + Id::Remote(AuthFormId::Address) + } else { + Id::Remote(AuthFormId::Port) + }; + self.activate_component(id); + } + #[cfg(posix)] + UiAuthFormMsg::SmbWorkgroupDown => { + self.activate_component(Id::Remote(AuthFormId::RemoteDirectory)) + } + #[cfg(posix)] + UiAuthFormMsg::SmbWorkgroupUp => { + self.activate_component(Id::Remote(AuthFormId::Password)) + } + UiAuthFormMsg::UsernameBlurDown => { + self.activate_component(Id::Remote(AuthFormId::Password)) + } + UiAuthFormMsg::UsernameBlurUp => { + let id = match self.remote_input_mask() { + InputMask::Localhost => unreachable!(), + InputMask::Generic => Id::Remote(AuthFormId::Port), + InputMask::Smb => Id::Remote(AuthFormId::SmbShare), + InputMask::Kube => unreachable!("this shouldn't happen (username on kube)"), + InputMask::AwsS3 => unreachable!("this shouldn't happen (username on s3)"), + InputMask::WebDAV => Id::Remote(AuthFormId::WebDAVUri), + }; + self.activate_component(id); + } + UiAuthFormMsg::WebDAVUriBlurDown => { + self.activate_component(Id::Remote(AuthFormId::Username)) + } + UiAuthFormMsg::WebDAVUriBlurUp => { + self.activate_component(Id::Remote(AuthFormId::Protocol)) + } + } + } + + fn activate_component(&mut self, id: Id) { + if let Err(err) = self.app.active(&id) { + error!("Failed to activate component: {err}"); + } + } + + fn umount_component(&mut self, id: Id) { + if let Err(err) = self.app.umount(&id) { + error!("Failed to umount component: {err}"); + } + } }