[pdm-devel] [PATCH datacenter-manager 4/4] ui: dashboard: subscriptions details: add a 'force refresh' button

Michael Köppl m.koeppl at proxmox.com
Thu Nov 27 17:13:09 CET 2025


1 nit inline

On Thu Nov 27, 2025 at 3:03 PM CET, Dominik Csapak wrote:
>  pub fn create_subscription_panel(
> diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs
> index 2adcee53..2791277b 100644
> --- a/ui/src/dashboard/view.rs
> +++ b/ui/src/dashboard/view.rs
> @@ -95,6 +95,7 @@ pub enum Msg {
>      ShowSubscriptionsDialog(bool),
>      LayoutUpdate(ViewLayout),
>      UpdateResult(Result<(), Error>),
> +    ForceSubscriptionUpdate,
>  }
>  
>  struct ViewComp {
> @@ -425,6 +426,22 @@ impl Component for ViewComp {
>              Msg::UpdateResult(res) => {
>                  self.update_result.update(res);
>              }
> +            Msg::ForceSubscriptionUpdate => {
> +                let link = ctx.link().clone();
> +                let view = ctx.props().view.clone();
> +                self.render_args.subscriptions.write().clear();

nit: Clearing here means that if fetching the subscriptions takes longer
for some reason, the user will look at an empty box until the data could
be fetched. Could it make sense to move clearing this to after the
request is done by perhaps tracking the loading state in some way?

> +                self.async_pool.spawn(async move {
> +                    let mut params = json!({
> +                        "verbose": true,
> +                        "max-age": 0,
> +                    });
> +                    if let Some(view) = view {
> +                        params["view"] = view.to_string().into();
> +                    }
> +                    let res = http_get("/resources/subscription", Some(params)).await;

here

> +                    link.send_message(Msg::LoadingResult(LoadingResult::SubscriptionInfo(res)));
> +                });
> +            }
>          }
>          true
>      }
> @@ -547,14 +564,14 @@ impl Component for ViewComp {
>                  .on_submit(move |ctx| crate::remotes::create_remote(ctx, remote_type))
>          }));
>  
> -        view.add_optional_child(if self.subscriptions_dialog {
> -            create_subscriptions_dialog(
> -                self.render_args.subscriptions.clone(),
> -                ctx.link().callback(|_| Msg::ShowSubscriptionsDialog(false)),
> -            )
> -        } else {
> -            None
> -        });
> +        view.add_optional_child(
> +            self.subscriptions_dialog
> +                .then_some(create_subscriptions_dialog(
> +                    self.render_args.subscriptions.clone(),
> +                    ctx.link().callback(|_| Msg::ShowSubscriptionsDialog(false)),
> +                    ctx.link().callback(|_| Msg::ForceSubscriptionUpdate),
> +                )),
> +        );
>  
>          let view_context = ViewContext {
>              name: props.view.clone(),
> diff --git a/ui/src/load_result.rs b/ui/src/load_result.rs
> index 4f3e6d5a..55436fd1 100644
> --- a/ui/src/load_result.rs
> +++ b/ui/src/load_result.rs
> @@ -33,6 +33,12 @@ impl<T, E> LoadResult<T, E> {
>      pub fn has_data(&self) -> bool {
>          self.data.is_some() || self.error.is_some()
>      }
> +
> +    /// Clears both data and the error from the result.
> +    pub fn clear(&mut self) {
> +        self.data = None;
> +        self.error = None;
> +    }
>  }
>  
>  impl<T, E> Default for LoadResult<T, E> {





More information about the pdm-devel mailing list