From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-yew-comp 2/2] confirm_button: use confirm dialog and always spawn a dialog
Date: Thu, 19 Dec 2024 12:00:58 +0100 [thread overview]
Message-ID: <20241219110059.166895-2-s.sterz@proxmox.com> (raw)
In-Reply-To: <20241219110059.166895-1-s.sterz@proxmox.com>
this uses the new `ConfirmDialog` component from pwt and now always
spawns a dialog, even if no explicit confirm message was set.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/confirm_button.rs | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/src/confirm_button.rs b/src/confirm_button.rs
index 95b2b6d..9406d4b 100644
--- a/src/confirm_button.rs
+++ b/src/confirm_button.rs
@@ -1,8 +1,8 @@
use yew::html::{IntoEventCallback, IntoPropValue};
+use pwt::prelude::*;
use pwt::props::IntoOptionalInlineHtml;
-use pwt::widget::{Button, Column, MessageBoxButtons};
-use pwt::{prelude::*, widget::MessageBox};
+use pwt::widget::{Button, Column, ConfirmDialog};
use pwt_macros::{builder, widget};
@@ -122,25 +122,15 @@ impl Component for ProxmoxConfirmButton {
let props = ctx.props();
match msg {
Msg::Request => {
- if let Some(message) = &props.confirm_message {
- if self.dialog.is_some() {
- return false;
- }
-
- let dialog = MessageBox::new(tr!("Confirm"), message.clone())
- .buttons(MessageBoxButtons::YesNo)
- .on_close(ctx.link().callback(|confirm| {
- if confirm {
- Msg::Activate
- } else {
- Msg::CloseDialog
- }
- }));
-
- self.dialog = Some(dialog.into());
- } else {
- ctx.link().send_message(Msg::Activate);
+ let mut dialog = ConfirmDialog::default()
+ .on_confirm(ctx.link().callback(|_| Msg::Activate))
+ .on_close(ctx.link().callback(|_| Msg::CloseDialog));
+
+ if let Some(confirm_message) = &props.confirm_message {
+ dialog.set_confirm_message(confirm_message.clone())
}
+
+ self.dialog = Some(dialog.into());
true
}
Msg::Activate => {
--
2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2024-12-19 11:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 11:00 [pdm-devel] [PATCH datacenter-manager] ui: remotes: use ConfirmButton component instead of ConfirmDialog Shannon Sterz
2024-12-19 11:00 ` Shannon Sterz [this message]
2025-01-08 10:25 ` [pdm-devel] applied: [PATCH proxmox-yew-comp 2/2] confirm_button: use confirm dialog and always spawn a dialog Dietmar Maurer
2024-12-19 11:00 ` [pdm-devel] [PATCH yew-widget-toolkit] widget: confirm_dialog: refactor to use message box Shannon Sterz
2025-01-08 9:25 ` [pdm-devel] applied: " Dietmar Maurer
2024-12-19 12:32 ` [pdm-devel] [PATCH datacenter-manager] ui: remotes: use ConfirmButton component instead of ConfirmDialog Dominik Csapak
2025-01-08 10:24 ` [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=20241219110059.166895-2-s.sterz@proxmox.com \
--to=s.sterz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox