From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 3A5A41FF17C
	for <inbox@lore.proxmox.com>; Wed, 11 Jun 2025 14:59:37 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id C08CE8B11;
	Wed, 11 Jun 2025 14:59:58 +0200 (CEST)
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Wed, 11 Jun 2025 14:59:26 +0200
Message-Id: <20250611125927.272238-1-l.wagner@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.018 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH manager 1/2] ui: backup job edit: move
 notification related settings to separate tab
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

The notification settings in the 'General' tab were unfortunately a
source of regular confusion for many people. This was primarily due to
the behavior of the 'motification mode'. The notification mode can
one of the following:
  - notification-system: Emit a notification event to the global
    notification system, where it can be matched on by notification
    matchers and then sent to one or more targets.
  - legacy-sendmail: Old-style notifications, where one can directly
    enter some email address. The system uses 'sendmail' to
    send the notification to the specified address, circumventing
    the regular notification stack.
  - auto: Use legacy-sendmail if an email is entered and the
    notification system if not

The behavior of 'auto' is quite surprising for many users, and therefore
we remove it from the UI altogether.

In the new 'Notifications' tab one can now choose between
  ( ) Use global notification settings
  (x) Use sendmail to send an email
      Recipients: [              ]
      When:       [Always/On Error]

'Recipients' and 'When' are disabled if the first radio box is selected.

The new tab can later also be used to house other controls. For example,
we could display all matchers that could potentially match this backup
job, or maybe even allow to create a new matcher with a pre-populated
match-field rule.

We also stop using the term 'Notification System' altogether in the UI.
It is not necessarily clear to a user that this refers to the settings
in Datacenter > Notifications.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 www/manager6/Makefile                         |   1 +
 www/manager6/dc/Backup.js                     |  65 ++---------
 .../panel/BackupNotificationOptions.js        | 103 ++++++++++++++++++
 3 files changed, 111 insertions(+), 58 deletions(-)
 create mode 100644 www/manager6/panel/BackupNotificationOptions.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index fdf0e816..5eb17edb 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -100,6 +100,7 @@ JSSRC= 							\
 	grid/ResourceGrid.js				\
 	panel/ConfigPanel.js				\
 	panel/BackupAdvancedOptions.js			\
+	panel/BackupNotificationOptions.js		\
 	panel/BackupJobPrune.js				\
 	panel/HealthWidget.js				\
 	panel/IPSet.js					\
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index 381402ca..f861ed3d 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -224,24 +224,12 @@ Ext.define('PVE.dc.BackupEdit', {
     viewModel: {
 	data: {
 	    selMode: 'include',
-	    notificationMode: '__default__',
-	    mailto: '',
-	    mailNotification: 'always',
 	},
 
 	formulas: {
 	    poolMode: (get) => get('selMode') === 'pool',
 	    disableVMSelection: (get) => get('selMode') !== 'include' &&
 		get('selMode') !== 'exclude',
-	    showMailtoFields: (get) =>
-		['auto', 'legacy-sendmail', '__default__'].includes(get('notificationMode')),
-	    enableMailnotificationField: (get) => {
-		let mode = get('notificationMode');
-		let mailto = get('mailto');
-
-		return (['auto', '__default__'].includes(mode) && mailto) ||
-		    mode === 'legacy-sendmail';
-	    },
 	},
     },
 
@@ -331,52 +319,6 @@ Ext.define('PVE.dc.BackupEdit', {
 				},
 			    ],
 			    column2: [
-				{
-				    xtype: 'proxmoxKVComboBox',
-				    comboItems: [
-					[
-					    '__default__',
-					    Ext.String.format(
-						gettext('{0} (Auto)'), Proxmox.Utils.defaultText,
-					    ),
-					],
-					['auto', gettext('Auto')],
-					['legacy-sendmail', gettext('Email (legacy)')],
-					['notification-system', gettext('Notification system')],
-				    ],
-				    fieldLabel: gettext('Notification mode'),
-				    name: 'notification-mode',
-				    value: '__default__',
-				    cbind: {
-					deleteEmpty: '{!isCreate}',
-				    },
-				    bind: {
-					value: '{notificationMode}',
-				    },
-				},
-				{
-				    xtype: 'textfield',
-				    fieldLabel: gettext('Send email to'),
-				    name: 'mailto',
-				    bind: {
-					hidden: '{!showMailtoFields}',
-					value: '{mailto}',
-				    },
-				},
-				{
-				    xtype: 'pveEmailNotificationSelector',
-				    fieldLabel: gettext('Send email'),
-				    name: 'mailnotification',
-				    cbind: {
-					value: (get) => get('isCreate') ? 'always' : '',
-					deleteEmpty: '{!isCreate}',
-				    },
-				    bind: {
-					hidden: '{!showMailtoFields}',
-					disabled: '{!enableMailnotificationField}',
-					value: '{mailNotification}',
-				    },
-				},
 				{
 				    xtype: 'pveBackupCompressionSelector',
 				    reference: 'compressionSelector',
@@ -439,6 +381,13 @@ Ext.define('PVE.dc.BackupEdit', {
 			},
 		    ],
 		},
+		{
+		    xtype: 'pveBackupNotificationOptionsPanel',
+		    title: gettext('Notifications'),
+		    cbind: {
+			isCreate: '{isCreate}',
+		    },
+		},
 		{
 		    xtype: 'pveBackupJobPrunePanel',
 		    title: gettext('Retention'),
diff --git a/www/manager6/panel/BackupNotificationOptions.js b/www/manager6/panel/BackupNotificationOptions.js
new file mode 100644
index 00000000..f0b2bf33
--- /dev/null
+++ b/www/manager6/panel/BackupNotificationOptions.js
@@ -0,0 +1,103 @@
+/*
+ * Input panel for notification options of backup jobs.
+ */
+Ext.define('PVE.panel.BackupNotificationOptions', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pveBackupNotificationOptionsPanel',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    onlineHelp: 'chapter_notifications',
+
+    cbindData: function() {
+	let me = this;
+	me.isCreate = !!me.isCreate;
+	return {};
+    },
+
+    viewModel: {
+	data: {
+	    notificationMode: undefined,
+	},
+	formulas: {
+	    showMailtoFields: (get) => {
+		let mode = get('notificationMode');
+		return mode['notification-mode'] === 'legacy-sendmail';
+	    },
+	},
+    },
+
+    onSetValues: function(values) {
+	let me = this;
+
+	let mode = values['notification-mode'] ?? 'auto';
+	let mailto = values.mailto;
+
+	let mappedMode = 'legacy-sendmail';
+
+	// The 'auto' mode is a bit annoying and confusing, so we try
+	// to map it to the equivalent behavior.
+	if ((mode === 'auto' && !mailto) || mode === 'notification-system') {
+	    mappedMode = 'notification-system';
+	}
+
+	me.getViewModel().set('notificationMode', { 'notification-mode': mappedMode });
+
+	values['notification-mode'] = mappedMode;
+	return values;
+    },
+
+    items: [
+	{
+	    xtype: 'radiogroup',
+	    height: '15px',
+	    layout: {
+		type: 'vbox',
+	    },
+	    bind: {
+		value: '{notificationMode}',
+	    },
+	    items: [
+		{
+		    xtype: 'radiofield',
+		    name: 'notification-mode',
+		    inputValue: 'notification-system',
+		    boxLabel: 'Use global notification settings',
+		    cbind: {
+			checked: '{isCreate}',
+		    },
+		},
+		{
+		    xtype: 'radiofield',
+		    name: 'notification-mode',
+		    inputValue: 'legacy-sendmail',
+		    boxLabel: 'Use sendmail to send an email',
+		},
+	    ],
+	},
+	{
+	    xtype: 'textfield',
+	    fieldLabel: gettext('Recipents'),
+	    emptyText: 'test@example.com, ...',
+	    name: 'mailto',
+	    padding: '0 0 0 50',
+	    disabled: true,
+	    bind: {
+		disabled: '{!showMailtoFields}',
+	    },
+	},
+	{
+	    xtype: 'pveEmailNotificationSelector',
+	    fieldLabel: gettext('When'),
+	    name: 'mailnotification',
+	    padding: '0 0 0 50',
+	    disabled: true,
+	    value: 'always',
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	    bind: {
+		disabled: '{!showMailtoFields}',
+	    },
+	},
+    ],
+});
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel