[pbs-devel] [PATCH proxmox-backup v3 31/42] ui: datastore options: add 'notification-mode' parameter

Lukas Wagner l.wagner at proxmox.com
Mon Apr 22 09:50:19 CEST 2024


Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
Tested-by: Gabriel Goller <g.goller at proxmox.com>
Reviewed-by: Gabriel Goller <g.goller at proxmox.com>
---
 www/datastore/OptionView.js | 15 +++++++++++++++
 www/window/NotifyOptions.js | 38 +++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/www/datastore/OptionView.js b/www/datastore/OptionView.js
index 6f1be969..e1f38af6 100644
--- a/www/datastore/OptionView.js
+++ b/www/datastore/OptionView.js
@@ -159,6 +159,21 @@ Ext.define('PBS.Datastore.Options', {
     },
 
     rows: {
+	"notification-mode": {
+	    required: true,
+	    defaultValue: 'legacy-sendmail',
+	    header: gettext('Notification mode'),
+	    renderer: function(value) {
+		if (value === 'notification-system') {
+		    return gettext('Notification system');
+		} else {
+		    return gettext('Email (legacy)');
+		}
+	    },
+	    editor: {
+		xtype: 'pbsNotifyOptionEdit',
+	    },
+	},
 	"notify": {
 	    required: true,
 	    header: gettext('Notify'),
diff --git a/www/window/NotifyOptions.js b/www/window/NotifyOptions.js
index 11765b43..95323486 100644
--- a/www/window/NotifyOptions.js
+++ b/www/window/NotifyOptions.js
@@ -44,6 +44,15 @@ Ext.define('PBS.window.NotifyOptions', {
 	labelWidth: 120,
     },
 
+    viewModel: {
+	data: {
+	    notificationMode: 'notification-system',
+	},
+	formulas: {
+	    notificationSystemSelected: (get) => get('notificationMode') === 'notification-system',
+	},
+    },
+
     items: {
 	xtype: 'inputpanel',
 	onGetValues: function(values) {
@@ -60,6 +69,18 @@ Ext.define('PBS.window.NotifyOptions', {
 	    return values;
 	},
 	items: [
+	    {
+		xtype: 'proxmoxKVComboBox',
+		comboItems: [
+		    ['legacy-sendmail', gettext('Email (legacy)')],
+		    ['notification-system', gettext('Notification system')],
+		],
+		fieldLabel: gettext('Notification mode'),
+		name: 'notification-mode',
+		bind: {
+		    value: '{notificationMode}',
+		},
+	    },
 	    {
 		xtype: 'pmxUserSelector',
 		name: 'notify-user',
@@ -69,6 +90,9 @@ Ext.define('PBS.window.NotifyOptions', {
 		allowBlank: true,
 		renderer: Ext.String.htmlEncode,
 		deleteEmpty: true,
+		bind: {
+		    disabled: "{notificationSystemSelected}",
+		},
 	    },
 	    {
 		xtype: 'pbsNotifyType',
@@ -76,6 +100,9 @@ Ext.define('PBS.window.NotifyOptions', {
 		fieldLabel: gettext('Verification Jobs'),
 		value: '__default__',
 		deleteEmpty: false,
+		bind: {
+		    disabled: "{notificationSystemSelected}",
+		},
 	    },
 	    {
 		xtype: 'pbsNotifyType',
@@ -83,6 +110,9 @@ Ext.define('PBS.window.NotifyOptions', {
 		fieldLabel: gettext('Sync Jobs'),
 		value: '__default__',
 		deleteEmpty: false,
+		bind: {
+		    disabled: "{notificationSystemSelected}",
+		},
 	    },
 	    {
 		xtype: 'pbsNotifyErrorDefaultType',
@@ -90,6 +120,9 @@ Ext.define('PBS.window.NotifyOptions', {
 		fieldLabel: gettext('Prune Jobs'),
 		value: '__default__',
 		deleteEmpty: false,
+		bind: {
+		    disabled: "{notificationSystemSelected}",
+		},
 	    },
 	    {
 		xtype: 'pbsNotifyType',
@@ -97,6 +130,9 @@ Ext.define('PBS.window.NotifyOptions', {
 		fieldLabel: gettext('Garbage Collection'),
 		value: '__default__',
 		deleteEmpty: false,
+		bind: {
+		    disabled: "{notificationSystemSelected}",
+		},
 	    },
 	],
     },
@@ -107,6 +143,8 @@ Ext.define('PBS.window.NotifyOptions', {
 	let options = {
 	    'notify-user': values['notify-user'],
 	    'verify-new': values['verify-new'],
+	    'notification-mode':
+		values['notification-mode'] ? values['notification-mode'] : 'legacy-sendmail',
 	};
 
 	let notify = {};
-- 
2.39.2





More information about the pbs-devel mailing list