delete values.node;
}
+ if (!isCreate) {
+ // 'mailnotification' is deprecated in favor of 'notification-policy'
+ // -> Migration to the new parameter happens in init, so we are
+ // safe to remove the old parameter here.
+ Proxmox.Utils.assemble_field_data(values, { 'delete': 'mailnotification' });
+
+ // If sending notifications via mail, remove the current value of
+ // 'notification-target'
+ if (values['notification-mode'] === "mailto") {
+ Proxmox.Utils.assemble_field_data(
+ values,
+ { 'delete': 'notification-target' },
+ );
+ } else {
+ // and vice versa...
+ Proxmox.Utils.assemble_field_data(
+ values,
+ { 'delete': 'mailto' },
+ );
+ }
+ }
+
+ delete values['notification-mode'];
+
if (!values.id && isCreate) {
values.id = 'backup-' + Ext.data.identifier.Uuid.Global.generate().slice(0, 13);
}
success: function(response, _options) {
let data = response.result.data;
+ // 'mailnotification' is deprecated. Let's automatically
+ // migrate to the compatible 'notification-policy' parameter
+ if (data.mailnotification) {
+ if (!data["notification-policy"]) {
+ data["notification-policy"] = data.mailnotification;
+ }
+
+ delete data.mailnotification;
+ }
+
+ if (data['notification-target']) {
+ data['notification-mode'] = 'notification-target';
+ } else if (data.mailto) {
+ data['notification-mode'] = 'mailto';
+ }
+
if (data.exclude) {
data.vmid = data.exclude;
data.selMode = 'exclude';
viewModel: {
data: {
selMode: 'include',
+ notificationMode: 'notification-target',
},
formulas: {
poolMode: (get) => get('selMode') === 'pool',
disableVMSelection: (get) => get('selMode') !== 'include' && get('selMode') !== 'exclude',
+ mailNotificationSelected: (get) => get('notificationMode') === 'mailto',
},
},
},
],
column2: [
- {
- xtype: 'textfield',
- fieldLabel: gettext('Send email to'),
- name: 'mailto',
- },
{
xtype: 'pveEmailNotificationSelector',
- fieldLabel: gettext('Email'),
- name: 'mailnotification',
+ fieldLabel: gettext('Notify'),
+ name: 'notification-policy',
cbind: {
value: (get) => get('isCreate') ? 'always' : '',
deleteEmpty: '{!isCreate}',
},
},
+ {
+ xtype: 'pveNotificationModeSelector',
+ fieldLabel: gettext('Notify via'),
+ name: 'notification-mode',
+ bind: {
+ value: '{notificationMode}',
+ },
+ },
+ {
+ xtype: 'pveNotificationTargetSelector',
+ fieldLabel: gettext('Notification Target'),
+ name: 'notification-target',
+ allowBlank: true,
+ editable: true,
+ autoSelect: false,
+ bind: {
+ hidden: '{mailNotificationSelected}',
+ disabled: '{mailNotificationSelected}',
+ },
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ {
+ xtype: 'textfield',
+ fieldLabel: gettext('Send email to'),
+ name: 'mailto',
+ hidden: true,
+ bind: {
+ hidden: '{!mailNotificationSelected}',
+ disabled: '{!mailNotificationSelected}',
+ },
+ },
{
xtype: 'pveCompressionSelector',
reference: 'compressionSelector',
--- /dev/null
+Ext.define('PVE.form.NotificationTargetSelector', {
+ extend: 'Proxmox.form.ComboGrid',
+ alias: ['widget.pveNotificationTargetSelector'],
+
+ // set default value to empty array, else it inits it with
+ // null and after the store load it is an empty array,
+ // triggering dirtychange
+ value: [],
+ valueField: 'name',
+ displayField: 'name',
+ deleteEmpty: true,
+ skipEmptyText: true,
+
+ store: {
+ fields: ['name', 'type', 'comment'],
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json/cluster/notifications/targets',
+ },
+ sorters: [
+ {
+ property: 'name',
+ direction: 'ASC',
+ },
+ ],
+ autoLoad: true,
+ },
+
+ listConfig: {
+ columns: [
+ {
+ header: gettext('Target'),
+ dataIndex: 'name',
+ sortable: true,
+ hideable: false,
+ flex: 1,
+ },
+ {
+ header: gettext('Type'),
+ dataIndex: 'type',
+ sortable: true,
+ hideable: false,
+ flex: 1,
+ },
+ {
+ header: gettext('Comment'),
+ dataIndex: 'comment',
+ sortable: true,
+ hideable: false,
+ flex: 2,
+ },
+ ],
+ },
+});