[pve-devel] [PATCH widget-toolkit v2] notify: sendmail: smtp: fix mailto/mailto-user parameter deletion

Lukas Wagner l.wagner at proxmox.com
Tue Dec 12 09:50:42 CET 2023


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 at proxmox.com>
Tested-by: Maximiliano Sandoval <m.sandoval at 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





More information about the pve-devel mailing list