[pdm-devel] [PATCH datacenter-manager 2/2] ui: use on_activate for buttons

Dominik Csapak d.csapak at proxmox.com
Fri Jun 6 09:23:53 CEST 2025


While it's technically the same currently, 'on_activate' is the correct
interface from our widget-toolkit. 'onclick' behaves the same due to
browser behavior for buttons, but when seeing 'onclick' one could be
lead to use that also for e.g. ActionIcons, where 'onclick' and
'on_activate' is not the same. So for consistency, use on_activate for
buttons everywhere.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 ui/src/configuration/webauthn.rs      | 2 +-
 ui/src/dashboard/mod.rs               | 2 +-
 ui/src/pve/mod.rs                     | 2 +-
 ui/src/pve/tree.rs                    | 2 +-
 ui/src/remotes/config.rs              | 4 +++-
 ui/src/remotes/node_url_list.rs       | 2 +-
 ui/src/remotes/wizard_page_connect.rs | 2 +-
 ui/src/remotes/wizard_page_info.rs    | 2 +-
 ui/src/top_nav_bar.rs                 | 4 ++--
 9 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/ui/src/configuration/webauthn.rs b/ui/src/configuration/webauthn.rs
index e589c7d..82425f1 100644
--- a/ui/src/configuration/webauthn.rs
+++ b/ui/src/configuration/webauthn.rs
@@ -124,7 +124,7 @@ impl Component for PdmWebauthnConfigEditor {
                     Button::new(tr!("Auto-fill"))
                         .class(ColorScheme::Primary)
                         .icon_class("fa fa-fw fa-pencil-square-o")
-                        .onclick(ctx.link().callback(move |event: MouseEvent| {
+                        .on_activate(ctx.link().callback(move |event: MouseEvent| {
                             event.stop_propagation();
                             Msg::AutoFill
                         })),
diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 23ff6b7..044bc1a 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -255,7 +255,7 @@ impl Component for PdmDashboard {
                             .with_tool(
                                 Button::new(tr!("Add"))
                                     .icon_class("fa fa-plus-circle")
-                                    .onclick(ctx.link().callback(|_| Msg::CreateWizard(true))),
+                                    .on_activate(ctx.link().callback(|_| Msg::CreateWizard(true))),
                             )
                             .with_child(RemotePanel::new(
                                 (!self.loading).then_some(self.status.clone()),
diff --git a/ui/src/pve/mod.rs b/ui/src/pve/mod.rs
index c5a83cf..a3cf573 100644
--- a/ui/src/pve/mod.rs
+++ b/ui/src/pve/mod.rs
@@ -186,7 +186,7 @@ impl LoadableComponent for PveRemoteComp {
                     .with_tool(
                         Button::new(tr!("Open Web UI"))
                             .icon_class("fa fa-external-link")
-                            .onclick({
+                            .on_activate({
                                 let link = ctx.link().clone();
                                 let remote = ctx.props().remote.clone();
                                 move |_| {
diff --git a/ui/src/pve/tree.rs b/ui/src/pve/tree.rs
index 474c9f2..c4d1322 100644
--- a/ui/src/pve/tree.rs
+++ b/ui/src/pve/tree.rs
@@ -448,7 +448,7 @@ impl LoadableComponent for PveTreeComp {
                             .on_input(link.callback(Msg::Filter)),
                     )
                     .with_flex_spacer()
-                    .with_child(Button::refresh(ctx.props().loading).onclick({
+                    .with_child(Button::refresh(ctx.props().loading).on_activate({
                         let on_reload_click = ctx.props().on_reload_click.clone();
                         move |_| {
                             on_reload_click.emit(());
diff --git a/ui/src/remotes/config.rs b/ui/src/remotes/config.rs
index d9d16ae..db5646b 100644
--- a/ui/src/remotes/config.rs
+++ b/ui/src/remotes/config.rs
@@ -175,7 +175,9 @@ impl LoadableComponent for PbsRemoteConfigPanel {
             .with_child({
                 Button::new(tr!("Add Proxmox VE"))
                     .icon_class("fa fa-building")
-                    .onclick(link.change_view_callback(|_| Some(ViewState::Add(RemoteType::Pve))))
+                    .on_activate(
+                        link.change_view_callback(|_| Some(ViewState::Add(RemoteType::Pve))),
+                    )
                 // FIXME: add PBS support
                 //MenuButton::new(tr!("Add")).show_arrow(true).menu(
                 //    Menu::new()
diff --git a/ui/src/remotes/node_url_list.rs b/ui/src/remotes/node_url_list.rs
index 54dbfb9..a3de0dc 100644
--- a/ui/src/remotes/node_url_list.rs
+++ b/ui/src/remotes/node_url_list.rs
@@ -197,7 +197,7 @@ impl ManagedField for PdmNodeUrlField {
                 Button::new(tr!("Add"))
                     .class(css::ColorScheme::Primary)
                     .icon_class("fa fa-plus-circle")
-                    .onclick({
+                    .on_activate({
                         let nodes = self.store.clone();
                         move |_| {
                             let mut nodes = nodes.write();
diff --git a/ui/src/remotes/wizard_page_connect.rs b/ui/src/remotes/wizard_page_connect.rs
index 28f14bf..1fb865f 100644
--- a/ui/src/remotes/wizard_page_connect.rs
+++ b/ui/src/remotes/wizard_page_connect.rs
@@ -223,7 +223,7 @@ impl Component for PdmWizardPageConnect {
                         .with_child(
                             Button::new("Connect")
                                 .disabled(!self.form_valid)
-                                .onclick(ctx.link().callback(|_| Msg::Connect)),
+                                .on_activate(ctx.link().callback(|_| Msg::Connect)),
                         ),
                 ),
             );
diff --git a/ui/src/remotes/wizard_page_info.rs b/ui/src/remotes/wizard_page_info.rs
index b0a5ba2..b272be6 100644
--- a/ui/src/remotes/wizard_page_info.rs
+++ b/ui/src/remotes/wizard_page_info.rs
@@ -344,7 +344,7 @@ impl Component for PdmWizardPageInfo {
                     .with_child(
                         Button::new("Scan")
                             .disabled(self.credentials.is_none())
-                            .onclick(ctx.link().callback(|_| Msg::Connect)),
+                            .on_activate(ctx.link().callback(|_| Msg::Connect)),
                     ),
             );
         Mask::new(content)
diff --git a/ui/src/top_nav_bar.rs b/ui/src/top_nav_bar.rs
index 07b3b23..78aace5 100644
--- a/ui/src/top_nav_bar.rs
+++ b/ui/src/top_nav_bar.rs
@@ -197,12 +197,12 @@ impl Component for PdmTopNavBar {
                     .buttons(vec![
                         Button::new(tr!("Show Local Tasks"))
                             .class(ColorScheme::Primary)
-                            .onclick(move |_| {
+                            .on_activate(move |_| {
                                 set_location_href("#/administration/tasks");
                             }),
                         Button::new(tr!("Show Remote Tasks"))
                             .class(ColorScheme::Primary)
-                            .onclick(move |_| {
+                            .on_activate(move |_| {
                                 set_location_href("#/remotes/tasks");
                             }),
                     ])
-- 
2.39.5





More information about the pdm-devel mailing list