[pve-devel] [PATCH widget-toolkit v6 10/16] notification: matcher: match-field: show known fields/values

Fiona Ebner f.ebner at proxmox.com
Mon Apr 22 10:52:52 CEST 2024


Am 22.04.24 um 10:31 schrieb Lukas Wagner:
> @@ -416,10 +416,22 @@ Ext.define('Proxmox.panel.NotificationRulesEditPanel', {
>  		    let me = this;
>  		    let record = me.get('selectedRecord');
>  		    let currentData = record.get('data');
> +
> +		    let newValue = [];
> +
> +		    // Build equivalent regular expression if switching
> +		    // to 'regex' mode
> +		    if (value === 'regex') {
> +			let regexVal = "^(";
> +			regexVal += currentData.value.join('|') + ")$";

Can break the UI when you change the match type before there is a value:

> Uncaught TypeError: currentData.value.join is not a function

> +			newValue.push(regexVal);
> +		    }
> +

and nit: the above could/should be a separate patch

>  		    record.set({
>  			data: {
>  			    ...currentData,
>  			    type: value,
> +			    value: newValue,
>  			},
>  		    });
>  		},

---snip---

> +	let valueStore = Ext.create('Ext.data.Store', {
> +	    model: 'proxmox-notification-field-values',
> +	    autoLoad: true,
> +	    proxy: {
> +		type: 'proxmox',
> +
> +		url: `/api2/json/${me.baseUrl}/matcher-field-values`,
> +	    },
> +	    listeners: {
> +		'load': function() {
> +		    this.each(function(record) {
> +			if (record.get('field') === 'type') {
> +			    record.set({
> +				comment:

Nit: while the API does not return a comment for the 'type' field
currently, this would override the returned comment should there ever be
one in the future.

> +				    Proxmox.Utils.formatNotificationFieldValue(
> +					record.get('value'),
> +				    ),
> +			    });
> +			}
> +		    }, this, true);
> +
> +		    // Commit changes so that the description field is not marked
> +		    // as dirty
> +		    this.commitChanges();
> +		},
> +	    },
> +	});
> +




More information about the pve-devel mailing list