all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>,
	Dominik Csapak <d.csapak@proxmox.com>
Subject: [pdm-devel] applied: [PATCH yew-comp 1/1] status: replace `to_fa_icon` with From implementatio
Date: Wed, 30 Apr 2025 11:24:37 +0200 (CEST)	[thread overview]
Message-ID: <1831405307.8277.1746005077059@webmail.proxmox.com> (raw)
In-Reply-To: <20250430072936.447054-2-d.csapak@proxmox.com>

applied

> On 30.4.2025 09:29 CEST Dominik Csapak <d.csapak@proxmox.com> wrote:
> 
>  
> this is a much nicer interface, and more idiomatic rust. To not break
> all sites that use it, simply deprecate the old `to_fa_icon` for now
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/status.rs | 64 ++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 56 insertions(+), 8 deletions(-)
> 
> diff --git a/src/status.rs b/src/status.rs
> index a2866d1..1004012 100644
> --- a/src/status.rs
> +++ b/src/status.rs
> @@ -16,13 +16,25 @@ pub enum Status {
>  }
>  
>  impl Status {
> +    #[deprecated]
> +    /// Deprecated, please use [`Fa::from`] or `.into()` instead.
>      pub fn to_fa_icon(&self) -> Fa {
> -        let (icon, class): (&str, Classes) = match self {
> +        (*self).into()
> +    }
> +
> +    fn get_icon_classes(&self) -> (&str, Classes) {
> +        match self {
>              Status::Success => ("check", FontColor::Success.into()),
>              Status::Warning => ("exclamation-triangle", FontColor::Warning.into()),
>              Status::Error => ("times-circle", FontColor::Error.into()),
>              Status::Unknown => ("question-circle", Opacity::Quarter.into()),
> -        };
> +        }
> +    }
> +}
> +
> +impl From<Status> for Fa {
> +    fn from(value: Status) -> Self {
> +        let (icon, class) = value.get_icon_classes();
>          Fa::new(icon).class(class)
>      }
>  }
> @@ -36,12 +48,24 @@ pub enum NodeState {
>  }
>  
>  impl NodeState {
> +    #[deprecated]
> +    /// Deprecated, please use [`Fa::from`] or `.into()` instead.
>      pub fn to_fa_icon(&self) -> Fa {
> -        let (icon, class) = match self {
> +        (*self).into()
> +    }
> +
> +    fn get_icon_classes(&self) -> (&str, FontColor) {
> +        match self {
>              NodeState::Online => ("check-circle", FontColor::Success),
>              NodeState::Offline => ("times-circle", FontColor::Error),
>              NodeState::Unknown => ("question-circle", FontColor::Surface),
> -        };
> +        }
> +    }
> +}
> +
> +impl From<NodeState> for Fa {
> +    fn from(value: NodeState) -> Self {
> +        let (icon, class) = value.get_icon_classes();
>          Fa::new(icon).class(class)
>      }
>  }
> @@ -57,14 +81,26 @@ pub enum GuestState {
>  }
>  
>  impl GuestState {
> +    #[deprecated]
> +    /// Deprecated, please use [`Fa::from`] or `.into()` instead.
>      pub fn to_fa_icon(&self) -> Fa {
> -        let (icon, class): (&str, Classes) = match self {
> +        (*self).into()
> +    }
> +
> +    fn get_icon_classes(&self) -> (&str, Classes) {
> +        match self {
>              GuestState::Running => ("play", FontColor::Success.into()),
>              GuestState::Paused => ("pause", FontColor::Warning.into()),
>              GuestState::Stopped => ("stop", Opacity::Quarter.into()),
>              GuestState::Template => ("file-o", "".into()),
>              GuestState::Unknown => ("question-circle", Opacity::Quarter.into()),
> -        };
> +        }
> +    }
> +}
> +
> +impl From<GuestState> for Fa {
> +    fn from(value: GuestState) -> Self {
> +        let (icon, class) = value.get_icon_classes();
>          Fa::new(icon).class(class)
>      }
>  }
> @@ -78,12 +114,24 @@ pub enum StorageState {
>  }
>  
>  impl StorageState {
> +    #[deprecated]
> +    /// Deprecated, please use [`Fa::from`] or `.into()` instead.
>      pub fn to_fa_icon(&self) -> Fa {
> -        let (icon, class) = match self {
> +        (*self).into()
> +    }
> +
> +    fn get_icon_classes(&self) -> (&str, FontColor) {
> +        match self {
>              StorageState::Available => ("check-circle", FontColor::Success),
>              StorageState::Unavailable => ("times-circle", FontColor::Error),
>              StorageState::Unknown => ("question-circle", FontColor::Warning),
> -        };
> +        }
> +    }
> +}
> +
> +impl From<StorageState> for Fa {
> +    fn from(value: StorageState) -> Self {
> +        let (icon, class) = value.get_icon_classes();
>          Fa::new(icon).class(class)
>      }
>  }
> -- 
> 2.39.5
> 
> 
> 
> _______________________________________________
> pdm-devel mailing list
> pdm-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


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


  reply	other threads:[~2025-04-30  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  7:29 [pdm-devel] [PATCH datacenter-manager/yew-comp 0/2] refactor status structs and Fa interaction Dominik Csapak
2025-04-30  7:29 ` [pdm-devel] [PATCH yew-comp 1/1] status: replace `to_fa_icon` with From implementation Dominik Csapak
2025-04-30  9:24   ` Dietmar Maurer [this message]
2025-04-30  7:29 ` [pdm-devel] [PATCH datacenter-manager 1/1] ui: adapt to deprecation of `to_fa_icon` Dominik Csapak
2025-05-06 11:40   ` [pdm-devel] applied: " 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=1831405307.8277.1746005077059@webmail.proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pdm-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