public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH yew-comp] user panel: handle expire property on edit properly
@ 2026-03-25 12:15 Shannon Sterz
  2026-03-26 23:24 ` applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Shannon Sterz @ 2026-03-25 12:15 UTC (permalink / raw)
  To: yew-devel

setting expire to "0" is a special case meaning "never expires". while
this was honored in the user management overview, the edit panel
rendered this as 01.01.1970 00:00:00 UTC, or the Unix epoch. this had
minimal functional impact, but it may be confusing to users. set
expire to `Value::Null` in this special case, rendering a cleared date
picker.

also the expire field is typically an `Option<i64>` [1]. so instead of
interpreting it as a `f64` and then casting it back to an `i64` when
rendering the input date, interpret it as an `i64` straight away.

[1]:
https://git.proxmox.com/?p=proxmox.git;a=blob;f=proxmox-access-control/src/types.rs;h=78eafb4c9d1e652f4d69c203aa2117cfe65544c2;hb=HEAD#l218

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
 src/user_panel.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/user_panel.rs b/src/user_panel.rs
index 547fdfe..75a442f 100644
--- a/src/user_panel.rs
+++ b/src/user_panel.rs
@@ -40,8 +40,12 @@ async fn load_user(userid: Key) -> Result<ApiResponseData<Value>, Error> {
     let mut resp: ApiResponseData<Value> = crate::http_get_full(&url, None).await?;
 
     if let Value::Number(number) = &resp.data["expire"] {
-        if let Some(epoch) = number.as_f64() {
-            resp.data["expire"] = Value::String(epoch_to_input_value(epoch as i64));
+        if let Some(epoch) = number.as_i64() {
+            if epoch == 0 {
+                resp.data["expire"] = Value::Null;
+            } else {
+                resp.data["expire"] = Value::String(epoch_to_input_value(epoch));
+            }
         }
     }
 
-- 
2.47.3





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-26 23:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-25 12:15 [PATCH yew-comp] user panel: handle expire property on edit properly Shannon Sterz
2026-03-26 23:24 ` applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal