public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH widget-toolkit v2] notify: sendmail: smtp: fix mailto/mailto-user parameter deletion
@ 2023-12-12  8:50 Lukas Wagner
  2024-01-04 12:41 ` Fiona Ebner
  0 siblings, 1 reply; 3+ messages in thread
From: Lukas Wagner @ 2023-12-12  8:50 UTC (permalink / raw)
  To: pve-devel

In the GUI, when a sendmail/smtp target is edited and either
'Additional Recipients' or 'Recipients' is completely removed (only
possible if the other field contains a value), parameter deletion did
not work properly. After applying the changes, the old value would
still be in place. The changes in this patch check if the field
is empty and add an appropriate 'delete' to the PUT request.

This error occurred because both fields were moved to a separate panel
at some point (regular Panel instead of InputPanel, to avoid
double-collection values on submit).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/panel/SendmailEditPanel.js | 7 +++++++
 src/panel/SmtpEditPanel.js     | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/src/panel/SendmailEditPanel.js b/src/panel/SendmailEditPanel.js
index 5a154c1..f943fa4 100644
--- a/src/panel/SendmailEditPanel.js
+++ b/src/panel/SendmailEditPanel.js
@@ -97,7 +97,14 @@ Ext.define('Proxmox.panel.SendmailEditPanel', {
 
 	if (values.mailto) {
 	    values.mailto = values.mailto.split(/[\s,;]+/);
+	} else if (!me.isCreate) {
+	    Proxmox.Utils.assemble_field_data(values, { 'delete': 'mailto' });
 	}
+
+	if (!values['mailto-user'] && !me.isCreate) {
+	    Proxmox.Utils.assemble_field_data(values, { 'delete': 'mailto-user' });
+	}
+
 	return values;
     },
 });
diff --git a/src/panel/SmtpEditPanel.js b/src/panel/SmtpEditPanel.js
index 8b258e0..128f1e3 100644
--- a/src/panel/SmtpEditPanel.js
+++ b/src/panel/SmtpEditPanel.js
@@ -173,6 +173,12 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
 
 	if (values.mailto) {
 	    values.mailto = values.mailto.split(/[\s,;]+/);
+	} else if (!me.isCreate) {
+	    Proxmox.Utils.assemble_field_data(values, { 'delete': 'mailto' });
+	}
+
+	if (!values['mailto-user'] && !me.isCreate) {
+	    Proxmox.Utils.assemble_field_data(values, { 'delete': 'mailto-user' });
 	}
 
 	if (!values.authentication && !me.isCreate) {
-- 
2.39.2





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

* Re: [pve-devel] [PATCH widget-toolkit v2] notify: sendmail: smtp: fix mailto/mailto-user parameter deletion
  2023-12-12  8:50 [pve-devel] [PATCH widget-toolkit v2] notify: sendmail: smtp: fix mailto/mailto-user parameter deletion Lukas Wagner
@ 2024-01-04 12:41 ` Fiona Ebner
  2024-01-04 13:01   ` Lukas Wagner
  0 siblings, 1 reply; 3+ messages in thread
From: Fiona Ebner @ 2024-01-04 12:41 UTC (permalink / raw)
  To: Proxmox VE development discussion, Lukas Wagner

Am 12.12.23 um 09:50 schrieb Lukas Wagner:
> In the GUI, when a sendmail/smtp target is edited and either
> 'Additional Recipients' or 'Recipients' is completely removed (only
> possible if the other field contains a value), parameter deletion did
> not work properly. After applying the changes, the old value would
> still be in place. The changes in this patch check if the field
> is empty and add an appropriate 'delete' to the PUT request.
> 
> This error occurred because both fields were moved to a separate panel
> at some point (regular Panel instead of InputPanel, to avoid
> double-collection values on submit).
> 
> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
> Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com>

Worked for me too :)

However, I noticed that there were already cbinds for deleteEmpty for
the mailto/mailto-user fields and wondered why that didn't have an
effect. Turns out, it's because they're nested in another widget and
that requires an additional cbind.

Alternative patch with that approach sent here:
https://lists.proxmox.com/pipermail/pve-devel/2024-January/061217.html




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

* Re: [pve-devel] [PATCH widget-toolkit v2] notify: sendmail: smtp: fix mailto/mailto-user parameter deletion
  2024-01-04 12:41 ` Fiona Ebner
@ 2024-01-04 13:01   ` Lukas Wagner
  0 siblings, 0 replies; 3+ messages in thread
From: Lukas Wagner @ 2024-01-04 13:01 UTC (permalink / raw)
  To: Fiona Ebner, Proxmox VE development discussion



On 1/4/24 13:41, Fiona Ebner wrote:
> 
> Worked for me too :)
> 
> However, I noticed that there were already cbinds for deleteEmpty for
> the mailto/mailto-user fields and wondered why that didn't have an
> effect. Turns out, it's because they're nested in another widget and
> that requires an additional cbind.
> 
> Alternative patch with that approach sent here:
> https://lists.proxmox.com/pipermail/pve-devel/2024-January/061217.html

I think your approach is the better solution for this problem, my
patch can be ignored.

-- 
- Lukas




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

end of thread, other threads:[~2024-01-04 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12  8:50 [pve-devel] [PATCH widget-toolkit v2] notify: sendmail: smtp: fix mailto/mailto-user parameter deletion Lukas Wagner
2024-01-04 12:41 ` Fiona Ebner
2024-01-04 13:01   ` Lukas Wagner

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