notification matcher: improve wording for mode

by removing the 'invert' checkbox and instead show the 4 modes possible,
we still assemble/parse the invert for the backend

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2023-11-16 12:57:53 +01:00 committed by Thomas Lamprecht
parent be5329512c
commit 1f8bfa3b30

View File

@ -516,35 +516,22 @@ Ext.define('Proxmox.panel.NotificationRulesEditPanel', {
let me = this;
let record = me.get('selectedRecord');
let currentData = record.get('data');
let invert = false;
if (value.startsWith('not')) {
value = value.substring(3);
invert = true;
}
record.set({
data: {
...currentData,
value,
invert,
},
});
},
get: function(record) {
return record?.get('data')?.value;
},
},
invertMatch: {
bind: {
bindTo: '{selectedRecord}',
deep: true,
},
set: function(value) {
let me = this;
let record = me.get('selectedRecord');
let currentData = record.get('data');
record.set({
data: {
...currentData,
invert: value,
},
});
},
get: function(record) {
return record?.get('data')?.invert;
let prefix = record?.get('data').invert ? 'not' : '';
return prefix + record?.get('data')?.value;
},
},
},
@ -791,8 +778,12 @@ Ext.define('Proxmox.panel.NotificationMatchRuleTree', {
matchCalendarStmts.push(data.value);
break;
case 'mode':
if (data.value.startsWith('not')) {
modeStmt = data.value.substring(3); // after 'not''
invertMatchStmt = true;
} else {
modeStmt = data.value;
invertMatchStmt = data.invert;
}
break;
}
@ -1004,9 +995,13 @@ Ext.define('Proxmox.panel.NotificationMatchRuleSettings', {
allowBlank: false,
isFormField: false,
matchFieldWidth: false,
comboItems: [
['all', gettext('All rules match')],
['any', gettext('Any rule matches')],
['notall', gettext('At least one rule does not match')],
['notany', gettext('No rule matches')],
],
bind: {
hidden: '{!showMatchingMode}',
@ -1014,19 +1009,6 @@ Ext.define('Proxmox.panel.NotificationMatchRuleSettings', {
value: '{rootMode}',
},
},
{
xtype: 'proxmoxcheckbox',
fieldLabel: gettext('Invert match'),
isFormField: false,
uncheckedValue: 0,
defaultValue: 0,
bind: {
hidden: '{!showMatchingMode}',
disabled: '{!showMatchingMode}',
value: '{invertMatch}',
},
},
{
xtype: 'proxmoxKVComboBox',
fieldLabel: gettext('Node type'),