all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-comp 4/4] login panel: use snackbar for errors when on mobile
Date: Tue,  1 Jul 2025 10:38:59 +0200	[thread overview]
Message-ID: <20250701083859.2088138-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250701083859.2088138-1-d.csapak@proxmox.com>

when mobile is set, use the snackbar for errors if a snackbar controller
is available. Otherwise show the erros like before.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/login_panel.rs | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/login_panel.rs b/src/login_panel.rs
index 3c16ed4..11c7ade 100644
--- a/src/login_panel.rs
+++ b/src/login_panel.rs
@@ -2,6 +2,7 @@ use std::rc::Rc;
 
 use pwt::props::PwtSpace;
 use pwt::state::PersistentState;
+use pwt::touch::{SnackBar, SnackBarContextExt};
 use yew::html::IntoEventCallback;
 use yew::prelude::*;
 use yew::virtual_dom::{VComp, VNode};
@@ -34,7 +35,8 @@ pub struct LoginPanel {
 
     /// Mobile Layout
     ///
-    /// Use special layout for mobile apps.
+    /// Use special layout for mobile apps. For example shows error in a [SnackBar]
+    /// if a [SnackBarController] context is available.
     ///
     /// Note: Always use saved userid to avoid additional checkbox.
     #[prop_or(false)]
@@ -450,6 +452,9 @@ impl Component for ProxmoxLoginPanel {
                 let realm = self.form_ctx.read().get_field_text("realm");
 
                 self.send_login(ctx, username, password, realm);
+                if let (true, Some(controller)) = (props.mobile, ctx.link().snackbar_controller()) {
+                    controller.dismiss_all()
+                }
                 true
             }
             Msg::Login(info) => {
@@ -465,7 +470,14 @@ impl Component for ProxmoxLoginPanel {
             Msg::LoginError(msg) => {
                 self.loading = false;
                 self.challenge = None;
-                self.login_error = Some(msg);
+                match (props.mobile, ctx.link().snackbar_controller()) {
+                    (true, Some(controller)) => {
+                        controller.show_snackbar(SnackBar::new().message(msg));
+                    }
+                    _ => {
+                        self.login_error = Some(msg);
+                    }
+                }
                 true
             }
         }
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


  parent reply	other threads:[~2025-07-01  8:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01  8:38 [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly Dominik Csapak
2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 2/4] http helpers: expose ticket refresh loop controls Dominik Csapak
2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 3/4] login panel/realm selector: make realm path configurable Dominik Csapak
2025-07-01  8:38 ` Dominik Csapak [this message]
2025-07-01  9:25 ` [yew-devel] applied: [PATCH yew-comp 1/4] expose subscription_note publicly Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250701083859.2088138-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal